An AI-powered Text-to-SQL Analytics Engine that converts natural language into SQL, executes it on a MySQL database, visualizes results with interactive dashboards, and automatically generates AI-powered business insights.
InsightSQL enables users to interact with relational databases using natural language instead of writing SQL manually.
Users simply ask questions such as:
"Show the top 10 states by total sales revenue."
The system automatically:
- Understands the question using Gemini 2.5 Flash
- Generates optimized SQL
- Executes the query on MySQL
- Displays the results as an interactive table
- Creates dynamic visualizations
- Produces AI-generated business insights
- Evaluates SQL quality using RAGAS
- Natural Language → SQL
- Powered by Gemini 2.5 Flash
- LangChain prompt engineering
- Automatic SQL cleaning & validation
- MySQL backend
- SQLAlchemy engine
- Automatic schema discovery
- Dynamic table explorer
- Interactive Data Tables
- Plotly Visualizations
- Bar Charts
- Line Charts
- Area Charts
- Automatic chart selection
After executing a query, the application automatically generates:
- Executive summary
- Key trends
- Business observations
- Actionable insights
- RAGAS Metrics
- SQL correctness
- Answer relevance
- Semantic evaluation
- LLM-as-a-Judge (Llama-3 via Groq)
Natural Language Query
│
▼
Streamlit User Interface
│
▼
LangChain Prompt Pipeline
│
▼
Database Schema Retrieval
│
▼
Gemini 2.5 Flash LLM
│
▼
SQL Query Generation
│
▼
SQL Validation & Cleaning
│
▼
SQLAlchemy + MySQL Engine
│
▼
Pandas DataFrame
│
┌────────────────┴────────────────┐
▼ ▼
Interactive Data Table Plotly Visualizations
│ │
└────────────────┬────────────────┘
▼
AI Business Insights
│
▼
RAGAS Evaluation
| Category | Technology |
|---|---|
| Programming Language | Python |
| Frontend | Streamlit |
| LLM | Gemini 2.5 Flash |
| AI Framework | LangChain |
| Database | MySQL |
| ORM | SQLAlchemy |
| Data Processing | Pandas |
| Visualization | Plotly |
| Evaluation | RAGAS |
| Judge Model | Llama-3 (Groq) |
InsightSQL
│
├── Data/
│ ├── Customers.csv
│ ├── Products.csv
│ ├── Regions.csv
│ ├── sales_order.csv
│ ├── State_Regions.csv
│ └── 2017_Budgets.csv
│
├── images/
│
├── notebooks/
│
├── app.py
├── sql_engine.py
├── requirements.txt
├── README.md
├── .env.example
└── docker-compose.yml
git clone https://github.com/VisheshJain28/InsightSQL.gitcd InsightSQLpip install -r requirements.txtCreate a .env file.
GOOGLE_API_KEY=YOUR_GOOGLE_API_KEY
DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=your_databasestreamlit run app.py- Show the top 7 states by total sales revenue.
- Find the products with the highest sales.
- Display total revenue generated by each region.
- Which customers generated the highest revenue?
- Compare state-wise sales.
- Show the monthly sales trend.
- List all available products.
- Find the budget allocated to Product 12.
- Query History
- Download Results as CSV/Excel
- User Authentication
- Dashboard Customization
- Conversational Memory
- Voice-to-SQL
- Multi-turn Analytics



