Turn database schema dumps into natural-language SQL queries using AI.
Upload your database schema catalog, ask questions in plain English, and get safe, schema-aware SQL you can run immediately.
This web app allows users to:
- Upload a database schema catalog dump (SQL Server / Azure SQL supported first)
- Visualize the schema in a clean, navigable tree
- Ask questions like:
"Get all flight numbers from the last 2 weeks"
- Receive:
- Valid SQL queries
- Generated only from the uploaded schema
- With zero database access required
The AI never touches your database β it only reasons over your schema.
- π Schema upload (catalog dump)
- π³ Interactive schema explorer
- π§ Natural language β SQL generation
- π Schema-safe AI (no hallucinated tables/columns)
- π§Ύ SQL Server / Azure SQL dialect support
- π§© Foreign-keyβaware joins
- π§ͺ Query validation before output
User Input (English)
β
Intent Extraction
β
Relevant Table Detection
β
Schema Subset Selection
β
AI SQL Generation
β
Static Validation
β
Final SQL Output
This project does NOT fine-tune a model.
Instead, it uses a RAG-style prompting strategy:
- The uploaded schema is parsed into structured JSON
- Only relevant tables and columns are injected into the prompt
- The AI is strictly instructed to:
- Use only provided schema
- Ask for clarification if ambiguous
- Output SQL only (no explanations unless requested)
This makes the system:
- Safer
- Cheaper
- Easier to maintain
- Legacy databases with hundreds of tables
- Non-SQL users (PMs, analysts, ops)
- Onboarding new engineers
- Exploring unfamiliar schemas
- Generating safe ad-hoc queries
- Next.js (App Router)
- TypeScript
- Tailwind CSS
- Schema Tree Viewer (custom or Radix)
- Monaco Editor (SQL preview)
- Next.js API Routes / Server Actions
- Schema parser (custom)
- JSON-based schema store
- OpenAI / Anthropic / compatible LLM
- Prompt-based RAG (no fine-tuning)
The interface follows a ChatGPT-inspired layout with a clean, dual-panel design:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β β
β βββββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββ β
β β SCHEMA VIEWER β β CHAT INTERFACE β β
β β β β β β
β β βββββββββββββββββββββββββββββ β β βββββββββββββββββββββββββββ β β
β β β π Search tables... β β β β User: β β β
β β βββββββββββββββββββββββββββββ€ β β β "Get all flight numbers β β β
β β β βΌ t_batch β β β β from the last 2 weeks" β β β
β β β ββ flightNumber β β β βββββββββββββββββββββββββββ β β
β β β ββ flightDateTime β β β βββββββββββββββββββββββββββ β β
β β β ββ flightStatus β β β β AI: β β β
β β β βΌ t_customer β β β β SELECT DISTINCT β β β
β β β ββ customerId β β β β flightNumber β β β
β β β ββ customerName β β β β FROM t_batch β β β
β β β ββ customerEmail β β β β WHERE flightDateTime β β β
β β β βΆ t_booking β β β β >= DATEADD(day, -14, β β β
β β β βΆ t_aircraft β β β β GETDATE()); β β β
β β β ... β β β βββββββββββββββββββββββββββ β β
β β βββββββββββββββββββββββββββββ€ β β β β
β β β [βΌ Expand All] [β² Collapse]β β β βββββββββββββββββββββββββββ β β
β β β [Copy Selected] β β β β User: β β β
β β βββββββββββββββββββββββββββββ β β β [Type your query...] β β β
β β β β βββββββββββββββββββββββββββ β β
β β [Schema Stats: 5 tables] β β β β
β βββββββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββββ β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Schema Viewer Panel (Left)
- Hierarchical tree view of database tables and columns
- Search/filter functionality for quick navigation
- Click to expand/collapse individual tables
- Bulk controls: "Expand All" / "Collapse All"
- Copy selected table/column names to clipboard
- Schema statistics display (table count, etc.)
Chat Interface Panel (Right)
- ChatGPT-style conversation interface
- User messages aligned left, AI responses aligned right
- AI responses include:
- Generated SQL queries with syntax highlighting
- Brief explanations (when requested)
- Input box at bottom for natural language queries
- Conversation history with scrollable view
- Copy SQL button on generated queries
- Individual Tables: Click triangle icon (βΆ/βΌ) to toggle
- Bulk Actions:
- "Expand All" - Opens all tables showing all columns
- "Collapse All" - Closes all tables to show only names
- Persistent State: Panel state saved between sessions
- Responsive: On smaller screens, panels stack vertically
- Split Control: Drag handle between panels to resize (optional)
- Clean, minimal design focused on usability
- Dark/light mode support
- Keyboard shortcuts (e.g., Cmd+K for search)
- Mobile-responsive with collapsible schema panel
- Syntax highlighting for SQL output
- Copy-to-clipboard for easy query extraction
/app
/upload
/schema
/query
/history
/lib
ai/
promptBuilder.ts
sqlValidator.ts
schema/
parser.ts
normalizer.ts
matcher.ts
/api
upload-schema
generate-sql
/types
schema.ts
query.ts
I want all flight numbers between the last 2 weeks
- Table:
t_batch - Columns:
flightNumberflightDateTime
SELECT DISTINCT flightNumber
FROM t_batch
WHERE flightDateTime >= DATEADD(day, -14, GETDATE())
AND flightNumber IS NOT NULL;The AI is constrained by:
- β No unknown tables
- β No guessed columns
- β No destructive queries (DROP, DELETE, UPDATE by default)
- β SELECT-only for MVP
- β SQL Serverβcompatible syntax
- Schema upload
- Schema viewer
- Natural language β SELECT SQL
- JOINs & aggregates
- Query explanation
- Ambiguity resolution
- Multi-database support
- Query optimization hints
- Saved prompts & history
- Role-based access
- No database credentials required
- No query execution on server
- Schema data isolated per user/project
- Prompt injection mitigation via strict templates
- Does not execute SQL
- Requires reasonably clean schema dumps
- Ambiguous language may require clarification
PRs are welcome!
Ideas to contribute:
- New schema parsers
- Better intent detection
- More SQL dialects
- Visualization improvements
MIT License
Databases shouldnβt be locked behind SQL fluency.
This project aims to make complex schemas understandable and queryable by anyone β safely, transparently, and intelligently.
If you plan to open-source this, this README is already structured for GitHub. If you want, I can:
- Add badges
- Make a SaaS version README
- Write pitch copy for landing page
- Generate API docs
Just say the word π