Skip to content

Latest commit

Β 

History

18 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– DataAgent Pro

Stateful Multi-Agent Data Analysis with LangGraph

An Agentic AI Data Analysis System for Reliable Analytical Workflows

Analyze CSV datasets using natural language through a stateful LangGraph workflow that combines LLM reasoning, deterministic execution, safe validation, and interactive visualizations.

Generate grounded analytical insights with validated SQL, Python execution, and persistent conversational memory.


Python FastAPI React TypeScript LangGraph AGENTIC AI DuckDB PostgreSQL


Plotly MCP DuckDB Docker MIT


πŸ“Έ Product Preview

The following screenshots demonstrate the complete workflowβ€”from dataset upload and conversational analysis to validated results, interactive visualizations, generated SQL, and execution analytics.

1️⃣ Dataset Upload

Upload a CSV dataset to start a new analysis session. The agent automatically profiles the dataset, identifies its schema, and prepares it for downstream analytical tasks.


2️⃣ Main Analysis Workspace

The primary workspace where users ask analytical questions in natural language. The agent plans the workflow, generates SQL or Python when required, validates execution, and presents grounded analytical results in real time.


3️⃣ Example Analysis β€” Monthly Sales Trend

A complete analytical report including:

  • Executive Summary
  • Query Results
  • Interactive Visualization
  • Statistical Insights


4️⃣ Conversational Follow-up Analysis

The agent maintains conversation state using LangGraph checkpointing, allowing follow-up questions without re-uploading the dataset.

Example:

"Show the top 3"

The system automatically understands the previous analytical context.


5️⃣ Explainable AI & Debug Information

Every analytical result is fully transparent.

The agent exposes:

  • Generated SQL
  • LLM reasoning
  • Execution plan
  • Runtime metadata

allowing users to inspect exactly how every answer was produced.


6️⃣ Analytics & Observability Dashboard

The built-in analytics dashboard tracks system performance, execution latency, retry rates, recovery statistics, and historical execution metrics for monitoring agent behavior.


⚑ Why This Project is Different

Many AI data analysis tools primarily generate SQL or Python using an LLM and return the result directly. DataAgent Pro combines LLM reasoning with deterministic execution, stateful workflows, and validation pipelines to produce more reliable analytical results.

Capability Typical AI Data Assistant DataAgent Pro
Workflow Single-step LLM response Stateful LangGraph multi-agent workflow
Calculations Performed or generated by the LLM Executed deterministically using DuckDB, Pandas & NumPy
Conversation Memory Limited chat history Persistent LangGraph checkpoints with PostgreSQL
Error Recovery Stops on failures Validation, reflection, and automatic retries
Execution Safety Limited validation SQL validation and Python AST security checks
Explainability Final answer only Generated SQL, execution plan, reasoning, and reports
Observability Minimal execution visibility Pipeline timeline, execution metrics, and analytics dashboard
Tool Integration Direct tool calls MCP-based tool architecture with fallback support

πŸ› οΈ Core Engineering Highlights

  • LangGraph Supervisor – Routes requests to specialized workers for modular execution.
  • Persistent Memory – PostgreSQL checkpoints preserve conversation state across sessions.
  • Safe Code Execution – SQL validation and Python AST checks improve reliability and security.
  • MCP Tool Integration – Analytical capabilities are exposed through Model Context Protocol with automatic fallback to local implementations.
  • Grounded AI Reports – The LLM explains deterministic results instead of generating numbers.
  • Session Isolation – Each analysis runs in an independent DuckDB session with automatic cleanup.

πŸ—οΈ System Architecture

DataAgent Pro follows a stateful multi-agent architecture built with LangGraph. A central Supervisor coordinates specialized workers for planning, execution, validation, visualization, and reporting, while PostgreSQL preserves workflow state across sessions.

System Architecture


πŸ” Validation, Reflection & Retry Loop

Every generated SQL or Python script is validated before execution. If validation fails or the results are unreliable, the system automatically reflects on the failure, regenerates the query, and retries execution. After the retry limit is reached, it returns a structured failure report instead of an incorrect response.

Validation Reflection Retry Loop


πŸ›‘οΈ Safe Execution

Generated SQL and Python code are validated before execution.

  • SQL validation prevents common query errors.
  • Python AST validation blocks unsafe imports and dangerous functions.
  • Code runs inside isolated subprocesses with execution timeouts for safer execution.

πŸ“Š Observability

The system records execution metrics and workflow traces, allowing users to monitor:

  • Execution success rate
  • Retry and recovery statistics
  • Execution timeline
  • System performance metrics

These insights are displayed through an integrated analytics dashboard.


πŸ“¦ Tech Stack

Category Technologies
Frontend React, TypeScript, Tailwind CSS, Vite
Backend FastAPI, Python
AI Framework LangGraph, LangChain
LLMs Groq (Llama 3.3 70B), Gemini 2.5 Flash
Database PostgreSQL, DuckDB
Data Processing Pandas, NumPy
Visualization Plotly
Reporting ReportLab
Tool Integration Model Context Protocol (MCP)

πŸ“‚ Project Structure

autonomous-data-analyst-agent/
β”‚
β”œβ”€β”€ backend/          # FastAPI + LangGraph workflow
β”œβ”€β”€ frontend/         # React application
β”œβ”€β”€ screenshots/      # README images
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ requirements.txt
└── README.md

πŸš€ Getting Started

1. Clone the Repository

git clone <repository-url>
cd autonomous-data-analyst-agent

2. Start PostgreSQL

docker-compose up -d

3. Backend Setup

python -m venv .venv

# Activate environment
# Windows
.venv\Scripts\activate

# Linux / macOS
source .venv/bin/activate

pip install -r requirements.txt

cp .env.example .env

Configure your API keys inside .env.

Start the backend:

uvicorn backend.main:app --reload

4. Frontend Setup

cd frontend

npm install

npm run dev

Open:

  • Frontend β†’ http://localhost:5173
  • Backend β†’ http://localhost:8000

πŸ’¬ Example Queries

  • "Show the top 7 customers by total sales."
  • "Show monthly sales trends."
  • "Calculate the correlation between sales and quantity."
  • "Detect outliers in sales."
  • "Show the percentage contribution by deal size."

πŸ”’ Limitations

  • Supports CSV datasets only.
  • Python code runs inside subprocess-based sandboxes rather than containers.
  • MCP communication currently uses local stdio transport.

⭐ Key Takeaways

This project demonstrates practical AI engineering concepts including:

  • Multi-agent orchestration with LangGraph
  • Stateful workflows and checkpointing
  • Safe SQL and Python execution
  • MCP-based tool integration
  • Reflection and retry mechanisms
  • Interactive analytics and reporting

πŸ“„ License

This project is licensed under the MIT License.

πŸ‘¨β€πŸ’» Author

Chetan VK

B.Tech in Artificial Intelligence & Data Science

About

Stateful multi-agent AI data analysis system built with LangGraph, FastAPI, DuckDB, PostgreSQL, React, and MCP.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages