NL2SQL with Dynamic Schema Visualization
Natural Language to SQL generation engine with automated Mermaid.js entity-relationship mapping and query explanation

Overview
An enterprise Natural Language to SQL (NL2SQL) conversion engine that translates complex business questions in plain English into validated SQL queries while dynamically rendering Mermaid.js entity-relationship diagrams and visual query execution graphs.
The Problem
Enterprise business teams and product managers frequently need ad-hoc data insights but face key friction points:
- Data Engineering Bottlenecks: Business analysts wait hours or days for data engineers to write custom SQL queries.
- Black-Box AI Trust Issues: Standard NL2SQL tools return raw queries that non-technical users cannot verify, leading to reluctance in trusting the numbers.
- Complex Multi-Table Schemas: Hallucinations on table joins and foreign key relations cause incorrect aggregates and silent errors.
The Solution
- Schema-Aware Prompt Orchestration: Extracts dynamic database DDL, column indexes, and foreign key relationships to ground LLM reasoning with high accuracy.
- Mermaid.js Visual Graph Generation: Automatically renders interactive Mermaid.js ER diagrams highlighting exactly which tables, foreign keys, and joins are utilized in the generated query.
- Safe Read-Only Sandboxing: Executes queries in an isolated, read-only transaction environment with execution timeouts and syntax validation before returning tabular datasets.
- Plain-English Query Explanation: Accompanies each result with a step-by-step breakdown of how the metric was calculated.
Business Impact & Results
- Self-Serve Analytics: Enabled non-technical teams to query databases independently with zero SQL knowledge.
- Auditability: Visual ER mapping increased stakeholder trust in AI-generated numbers by 90%.
- Query Accuracy: Achieved 93%+ execution accuracy across complex multi-table join schemas.


