ai_schema
AI Schema exports Drupal’s complex data model into clean, structured, and LLM-friendly JSON. It helps developers and AI tools understand entities, fields, relationships, and database structure without deep Drupal knowledge.
Features
AI Schema transforms Drupal’s internal data model into multiple machine-readable formats designed for developers, data tools, and AI systems.
Key capabilities include:
-
LLM-friendly schema export
Generates a compact, token-efficient model (compact-model.json) optimized for AI tools like ChatGPT and Claude.
-
Entity relationship graph
Outputs a full relationship graph (relation-graph.json) showing how entities and bundles are connected.
-
Automatic SQL query generation
Creates ready-to-use SELECT queries with correct JOIN logic for Drupal field tables.
-
Full data model export
Includes entity types, bundles, fields, storage tables, and column mappings.
-
Per-entity context files
Combines schema, relations, and SQL into a single file per entity bundle.
-
AI semantic hints
Fields are automatically classified (label, content, taxonomy, media, etc.) to improve machine understanding.
When should you use this module?
- When you want to integrate Drupal with AI tools (LLMs)
- When you need to generate SQL queries without dealing with Drupal’s schema complexity
- When building data pipelines, BI tools, or external APIs
- When documenting or analyzing a Drupal data model
Post-Installation
After enabling the module, no UI configuration is required.
All functionality is available via Drush commands.
To generate the full export:
drush aischema:export-allThis will create a ai-schema/ directory in your project root containing:
compact-model.json(LLM-optimized schema)relation-graph.json(entity relationships)sql-queries.json(generated SQL queries)- Additional advanced exports
Typical workflow
- Run the export command
- Use
compact-model.jsonandrelation-graph.jsonas input for LLM tools - Use
sql-queries.jsonfor direct execution or integration
No configuration pages or UI setup are needed.
Additional Requirements
- Drupal 10.x or 11.x
- Drush 12.x or 13.x
No additional contributed modules or external libraries are required.
Recommended modules/libraries
This module works standalone.
However, it pairs well with:
- Headless Drupal setups (JSON:API, GraphQL)
- BI and analytics tools
- AI / LLM platforms (ChatGPT, Claude, etc.)
Similar projects
There are tools that export Drupal configuration or provide schema introspection, but AI Schema is different in key ways:
- Designed specifically for AI/LLM consumption
- Provides token-efficient compact schema representation
- Includes automatic SQL query generation
- Adds semantic meaning (AI hints) to fields
- Outputs relationship graphs
This makes it more than a schema export tool it is an AI integration layer for Drupal.
Supporting this Module
This module is developed and maintained by OctoHaus.
If you are interested in contributing, feedback, or collaboration, feel free to get in touch.