Skip to content

rutvik29/data-analyst-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📊 Data Analyst Agent

Python LangGraph Streamlit License: MIT

Ask questions about your data in plain English. The agent writes SQL, executes it, analyzes results with pandas, generates charts, and explains insights — all in one shot.

✨ Highlights

  • 🗣️ Natural language → SQL — powered by GPT-4o with schema-aware prompting
  • 🔁 Self-correcting loop — if SQL fails, the agent reads the error and tries again
  • 📈 Auto visualization — generates Plotly charts based on query results
  • 🧮 Pandas analysis — describes statistics, detects trends, flags anomalies
  • 🔌 Multi-DB support — PostgreSQL, MySQL, SQLite, BigQuery, Snowflake
  • 💬 Streamlit chat UI — interactive multi-turn conversation with your data

Demo

User: "Which product category had the highest revenue last quarter, broken down by month?"

Agent: [analyzes schema] → [writes SQL] → [executes] → [plots bar chart] →
       "Electronics led Q4 with $2.4M total revenue. December was the peak month (+31% MoM)
        driven by holiday promotions. Laptops alone accounted for 67% of category revenue."

Quick Start

git clone https://github.com/rutvik29/data-analyst-agent
cd data-analyst-agent
pip install -r requirements.txt
cp .env.example .env  # add OPENAI_API_KEY + DATABASE_URL

streamlit run ui/app.py

Architecture

User Question
      │
      ▼
┌───────────────┐   schema    ┌───────────────┐
│ Schema Loader │ ──────────▶ │  SQL Writer   │
└───────────────┘             └───────┬───────┘
                                      │ SQL
                                      ▼
                              ┌───────────────┐
                    error ◀── │   Executor    │ ──▶ DataFrame
                    (retry)   └───────────────┘
                                      │
                              ┌───────▼───────┐
                              │   Analyzer    │ ──▶ Stats + Insights
                              └───────┬───────┘
                                      │
                              ┌───────▼───────┐
                              │  Visualizer   │ ──▶ Plotly Chart
                              └───────────────┘

License

MIT © Rutvik Trivedi

About

AI data analyst: natural language to SQL, pandas analysis, and auto-generated charts with LangGraph reasoning loops

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages