English2SQL is a production-ready interface that democratizes data access by allowing non-technical users to query complex SQL databases using plain English.
By leveraging Schema-Aware RAG (Retrieval Augmented Generation) and a refined LLM pipeline, this system achieves a 9% accuracy improvement over baseline text-to-SQL models, significantly reducing hallucination rates in enterprise environments.
- Natural Language Querying: Converts complex questions ("Show me top 5 users by spend in NY last month") into optimized SQL.
- Schema-Aware RAG: Dynamically retrieves relevant table schemas and context before generation, ensuring queries are syntactically and semantically correct.
- Enterprise Security:
- role-based access control (RBAC) via Firebase Auth.
- Sanitized inputs to prevent SQL injection.
- Interactive Data Visualization: Automatically renders results as dynamic tables or charts based on data type.
graph TD
User[User Question] -->|Natural Language| FE[React Frontend]
FE -->|Auth Token| API[FastAPI Backend]
subgraph "AI Core"
API -->|Context Retrieval| VectorDB[(Vector Store)]
VectorDB -->|Relevant Schema| IL[In-Context Learning]
IL -->|Prompt| LLM[LLM Engine]
LLM -->|Generated SQL| API
end
subgraph "Data Layer"
API -->|Execute SQL| DB[(PostgreSQL)]
DB -->|JSON Result| API
end
API -->|Result + Viz Config| FE
- Framework: React 18 (CRA)
- Styling: Bootstrap 5 + Custom CSS
- Authentication: Firebase (Google OAuth)
- State Management: Jotai
- API: FastAPI (Python)
- AI Orchestration: LangChain + OpenAI/Ollama
- Database: PostgreSQL (AWS RDS)
- Multi-Dialect Support: Add adapters for MySQL, Snowflake, and BigQuery.
- Advanced Visualization: Integrate Vega-Lite for more complex automated charting.
- Voice Interface: Add speech-to-text for hands-free querying.
See the system in action converting varied business questions into precise SQL.
To run this interface locally:
-
Clone the repository
git clone https://github.com/Rayhanpatel/English2SQL.git cd English2SQL -
Install Dependencies
npm install
-
Configure Environment Create a
.envfile with your Firebase config:REACT_APP_FIREBASE_API_KEY=your_key REACT_APP_FIREBASE_AUTH_DOMAIN=your_domain ...
-
Start the App
npm start
Open http://localhost:3000 to view it in the browser.
To make the "Architecture Diagram" real, you need to run the Python backend which creates a mock SQL environment.
-
Navigate to backend:
cd backend -
Install Python Dependencies:
pip install -r requirements.txt
-
Run the Server:
python server.py
The API will be available at
http://localhost:5001.
This project is licensed under the MIT License - see the LICENSE file for details.
Built by Rayhan Patel