An AI-powered data analysis assistant that allows users to query the Olist Brazilian E-commerce dataset using natural, plain English. The application automatically translates questions into SQL, executes them securely, generates interactive visualizations, and provides deep analytical insights-all wrapped in a beautiful, responsive, Neo-brutalist web interface.
- 🗣️ Natural Language Interface: Ask complex business questions without knowing SQL.
- ⚡ AI-Powered Pipeline: Utilizes LangGraph and advanced LLMs to map queries to database schemas and generate accurate SQL.
- 📊 Automated Visualizations: Automatically detects when data should be visualized and generates dynamic interactive charts.
- 🧠 Deep Insights: The AI doesn't just return numbers; it analyzes the data and provides written business insights.
- 🔄 Dynamic Follow-ups: Automatically suggests 3 context-aware follow-up questions based on the current analysis.
- 👨💻 Transparent Execution: Users can click to view the exact SQL query generated by the AI to verify correctness.
The application executes the query and returns a beautiful response card containing key insights and a detailed breakdown.

When the AI detects visualizable data (like trends or comparisons), it automatically generates interactive charts right in the chat.

Curious about how the AI got the answer? Click the "View SQL" button to see the exact query executed against the database.

The backend is driven by a robust state machine built with LangGraph, ensuring reliable multi-step reasoning and error handling.
graph TD
A[User Input] -->|Plain English| B(Gradio UI)
B --> C{LangGraph Pipeline}
subgraph Agentic Backend
C --> D[SQL Generator Agent]
D --> E[(Database Exec)]
E -->|Validation Check| D
E -->|Raw Data| F[Chart/Plot Generator]
E -->|Raw Data| G[Insight Analysis Agent]
E -->|Raw Data| H[Follow-Up Agent]
end
F --> I((Final Output))
G --> I
H --> I
I -->|JSON & Markdown| B
- Python 3.9+
- A configured environment with your preferred LLM API keys (e.g., OpenAI, Anthropic).
-
Clone the repository:
git clone https://github.com/yourusername/Analyst-Agent.git cd Analyst-Agent -
Set up a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows use: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Environment Variables: Create a
.envfile in the root directory and add your API keys.OPENAI_API_KEY=your_api_key_here GRADIO_SERVER_PORT=7860
Start the Gradio web server by running:
python app.pyThe application will be accessible at http://localhost:7860.
- Frontend: Gradio with custom Svelte CSS injections for a Neo-brutalist aesthetic.
- State Management: LangGraph for robust pipeline orchestration.
- Database: SQLite / PostgreSQL (Olist dataset).
- LLM Integration: LangChain.
Analyst Agent Documentation
