saurabhanand/AI-Powered_SQL_Business_Intelligence_Assistant
0
๐ค AI-Powered SQL Business Intelligence Assistant
Ask business questions in plain English โ AI generates SQL โ results + charts + insights
     
๐ด Live Demo
๐ What This Project Does
A user types: "Which region has the highest profit margin?"
The app:
- Sends the question to Gemini AI API
- AI generates a valid SQL query
- Query runs on a SQLite database (9,994 orders)
- Results displayed as table + auto chart
- AI generates a plain English business insight
๐๏ธ Project Structure
AI-SQL-Business-Intelligence-Assistant/
โ
โโโ app.py # Main Streamlit application (4 pages)
โโโ superstore.csv # Superstore sales dataset (9,994 rows)
โโโ superstore.db # SQLite database (auto-created from CSV)
โโโ requirements.txt # Python dependencies
โโโ README.md๐ Dataset
Columns
๐ App Pages
๐ ๏ธ Tech Stack
๐ Run Locally
# 1. Clone the repo
git clone https://github.com/SaurabhAnand56/AI-SQL-Business-Intelligence-Assistant.git
cd AI-SQL-Business-Intelligence-Assistant
# 2. Install dependencies
pip install -r requirements.txt
# 3. Run the app
streamlit run app.pyGet a free Anthropic API key at console.anthropic.com and enter it in the app.
๐ SQL Examples Used
-- Year-over-year growth
SELECT strftime('%Y', order_date) as year,
ROUND(SUM(sales), 2) as total_sales,
COUNT(DISTINCT order_id) as orders
FROM sales
GROUP BY year ORDER BY year;
-- Profit margin by category
SELECT category,
ROUND(SUM(profit)/SUM(sales)*100, 2) as margin_pct
FROM sales GROUP BY category;
-- Window function: running total
SELECT order_date,
ROUND(SUM(SUM(sales)) OVER (ORDER BY order_date), 2) as running_total
FROM sales GROUP BY order_date ORDER BY order_date;๐ฌ Connect
 
