# shenbageshwaran/data-analysis-agent architecture

> Architecture diagram of the GitHub repository shenbageshwaran/data-analysis-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shenbageshwaran/data-analysis-agent
- Repository: https://github.com/shenbageshwaran/data-analysis-agent

## Overview

This repository is a CSV question-answering agent with two runtime variants: a Streamlit dashboard backed by a LangChain agent with session-scoped conversation memory, and an earlier command-line OpenAI Responses API loop. In both, the model selects among six predefined EDA tools; Python functions perform the calculations and return results for the model to explain. The dashboard loads the uploaded CSV and passes it to the agent. The README documents all six analysis capabilities; the examples agent and sample CSV are peripheral. Connections to framework-managed dispatch are shown only where the excerpts support them.

Main entry points: [`data_analysis_agent.py`](https://github.com/shenbageshwaran/data-analysis-agent/blob/main/data_analysis_agent.py) (Responses API Loop), [`data_analysis_agent_langchain_v2.py`](https://github.com/shenbageshwaran/data-analysis-agent/blob/main/data_analysis_agent_langchain_v2.py) (Tool Adapters), [`app.py`](https://github.com/shenbageshwaran/data-analysis-agent/blob/main/app.py) (Streamlit Dashboard), [`data_analysis_agent_functions.py`](https://github.com/shenbageshwaran/data-analysis-agent/blob/main/data_analysis_agent_functions.py) (Dataset Inspection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User Interfaces"]
  node_dashboard["Streamlit Dashboard<br/>[app.py]"]
  node_session["Dataset and Chat State<br/>[app.py]"]
end

subgraph group_orchestration["Agent Orchestration"]
  node_langchain_agent["LangChain Agent"]
  node_memory["Conversation Memory"]
  node_tool_adapters["Tool Adapters"]
end

subgraph group_analysis["EDA Tools"]
  node_inspect["Dataset Inspection"]
  node_describe["Variable Summaries"]
  node_plot["Distribution Plots"]
  node_correlation["Pair Correlation"]
  node_matrix["Correlation Matrix"]
  node_groupby["Grouped Summaries"]
end

subgraph group_legacy["First Version"]
  node_legacy_agent["Responses API Loop"]
  node_tool_schema["Function Schemas<br/>[da_tools_schema.py]"]
  node_toy_agent["Toy Agent Example<br/>[agent.py]"]
end

node_user(("Analyst"))
node_csv["Uploaded CSV"]
node_llm["OpenAI Model"]
node_openai_api["OpenAI Responses API"]

node_user -->|"asks questions"| node_dashboard
node_csv -->|"uploads"| node_dashboard
node_dashboard -->|"loads and tracks"| node_session
node_dashboard -->|"sets data, runs"| node_langchain_agent
node_langchain_agent -->|"invokes"| node_llm
node_langchain_agent -->|"configures checkpoint"| node_memory
node_langchain_agent -->|"registers tools"| node_tool_adapters
node_tool_adapters -->|"calls"| node_inspect
node_tool_adapters -->|"calls"| node_describe
node_tool_adapters -->|"calls"| node_plot
node_tool_adapters -->|"calls"| node_correlation
node_tool_adapters -->|"calls"| node_matrix
node_tool_adapters -->|"calls"| node_groupby
node_legacy_agent -->|"supplies definitions"| node_tool_schema
node_legacy_agent -->|"requests responses"| node_openai_api
node_legacy_agent -->|"dispatches"| node_inspect
node_legacy_agent -->|"dispatches"| node_describe
node_legacy_agent -->|"dispatches"| node_plot
node_legacy_agent -->|"dispatches"| node_correlation
node_legacy_agent -->|"dispatches"| node_matrix
node_legacy_agent -->|"dispatches"| node_groupby

click node_dashboard "https://github.com/shenbageshwaran/data-analysis-agent/blob/main/app.py"
click node_session "https://github.com/shenbageshwaran/data-analysis-agent/blob/main/app.py"
click node_langchain_agent "https://github.com/shenbageshwaran/data-analysis-agent/blob/main/data_analysis_agent_langchain_v2.py"
click node_memory "https://github.com/shenbageshwaran/data-analysis-agent/blob/main/data_analysis_agent_langchain_v2.py"
click node_tool_adapters "https://github.com/shenbageshwaran/data-analysis-agent/blob/main/data_analysis_agent_langchain_v2.py"
click node_inspect "https://github.com/shenbageshwaran/data-analysis-agent/blob/main/data_analysis_agent_functions.py"
click node_describe "https://github.com/shenbageshwaran/data-analysis-agent/blob/main/data_analysis_agent_functions.py"
click node_plot "https://github.com/shenbageshwaran/data-analysis-agent/blob/main/data_analysis_agent_functions.py"
click node_correlation "https://github.com/shenbageshwaran/data-analysis-agent/blob/main/data_analysis_agent_functions.py"
click node_matrix "https://github.com/shenbageshwaran/data-analysis-agent/blob/main/data_analysis_agent_functions.py"
click node_groupby "https://github.com/shenbageshwaran/data-analysis-agent/blob/main/data_analysis_agent_functions.py"
click node_legacy_agent "https://github.com/shenbageshwaran/data-analysis-agent/blob/main/data_analysis_agent.py"
click node_tool_schema "https://github.com/shenbageshwaran/data-analysis-agent/blob/main/da_tools_schema.py"
click node_toy_agent "https://github.com/shenbageshwaran/data-analysis-agent/blob/main/examples/agent.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dashboard,node_session toneBlue
class node_langchain_agent,node_memory,node_tool_adapters toneAmber
class node_inspect,node_describe,node_plot,node_correlation,node_matrix,node_groupby,node_openai_api toneMint
class node_legacy_agent,node_tool_schema,node_toy_agent toneRose
class node_user,node_csv,node_llm toneIndigo
```

## Components

### User Interfaces

- [Streamlit Dashboard](https://github.com/shenbageshwaran/data-analysis-agent/blob/main/app.py): `app.py`
- [Dataset and Chat State](https://github.com/shenbageshwaran/data-analysis-agent/blob/main/app.py): `app.py`

### Agent Orchestration

- [LangChain Agent](https://github.com/shenbageshwaran/data-analysis-agent/blob/main/data_analysis_agent_langchain_v2.py): `data_analysis_agent_langchain_v2.py`
- [Conversation Memory](https://github.com/shenbageshwaran/data-analysis-agent/blob/main/data_analysis_agent_langchain_v2.py): `data_analysis_agent_langchain_v2.py`
- [Tool Adapters](https://github.com/shenbageshwaran/data-analysis-agent/blob/main/data_analysis_agent_langchain_v2.py): `data_analysis_agent_langchain_v2.py`

### EDA Tools

- [Dataset Inspection](https://github.com/shenbageshwaran/data-analysis-agent/blob/main/data_analysis_agent_functions.py): `data_analysis_agent_functions.py`
- [Variable Summaries](https://github.com/shenbageshwaran/data-analysis-agent/blob/main/data_analysis_agent_functions.py): `data_analysis_agent_functions.py`
- [Distribution Plots](https://github.com/shenbageshwaran/data-analysis-agent/blob/main/data_analysis_agent_functions.py): `data_analysis_agent_functions.py`
- [Pair Correlation](https://github.com/shenbageshwaran/data-analysis-agent/blob/main/data_analysis_agent_functions.py): `data_analysis_agent_functions.py`
- [Correlation Matrix](https://github.com/shenbageshwaran/data-analysis-agent/blob/main/data_analysis_agent_functions.py): `data_analysis_agent_functions.py`
- [Grouped Summaries](https://github.com/shenbageshwaran/data-analysis-agent/blob/main/data_analysis_agent_functions.py): `data_analysis_agent_functions.py`

### First Version

- [Responses API Loop](https://github.com/shenbageshwaran/data-analysis-agent/blob/main/data_analysis_agent.py): `data_analysis_agent.py`
- [Function Schemas](https://github.com/shenbageshwaran/data-analysis-agent/blob/main/da_tools_schema.py): `da_tools_schema.py`
- [Toy Agent Example](https://github.com/shenbageshwaran/data-analysis-agent/blob/main/examples/agent.py): `examples/agent.py`

### Other components

- **Analyst**
- **Uploaded CSV**
- **OpenAI Model**
- **OpenAI Responses API**

## Connections

- Analyst → Streamlit Dashboard: asks questions (evidence: `app.py`)
- Uploaded CSV → Streamlit Dashboard: uploads (evidence: `app.py`)
- Streamlit Dashboard → Dataset and Chat State: loads and tracks (evidence: `app.py`)
- Streamlit Dashboard → LangChain Agent: sets data, runs (evidence: `app.py`)
- LangChain Agent → OpenAI Model: invokes (evidence: `data_analysis_agent_langchain_v2.py`)
- LangChain Agent → Conversation Memory: configures checkpoint (evidence: `data_analysis_agent_langchain_v2.py`)
- LangChain Agent → Tool Adapters: registers tools (evidence: `data_analysis_agent_langchain_v2.py`)
- Tool Adapters → Dataset Inspection: calls (evidence: `data_analysis_agent_langchain_v2.py`)
- Tool Adapters → Variable Summaries: calls (evidence: `data_analysis_agent_langchain_v2.py`)
- Tool Adapters → Distribution Plots: calls (evidence: `data_analysis_agent_langchain_v2.py`)
- Tool Adapters → Pair Correlation: calls (evidence: `data_analysis_agent_langchain_v2.py`)
- Tool Adapters → Correlation Matrix: calls (evidence: `data_analysis_agent_langchain_v2.py`)
- Tool Adapters → Grouped Summaries: calls (evidence: `data_analysis_agent_langchain_v2.py`)
- Responses API Loop → Function Schemas: supplies definitions (evidence: `data_analysis_agent.py`)
- Responses API Loop → OpenAI Responses API: requests responses (evidence: `data_analysis_agent.py`)
- Responses API Loop → Dataset Inspection: dispatches (evidence: `data_analysis_agent.py`)
- Responses API Loop → Variable Summaries: dispatches (evidence: `data_analysis_agent.py`)
- Responses API Loop → Distribution Plots: dispatches (evidence: `data_analysis_agent.py`)
- Responses API Loop → Pair Correlation: dispatches (evidence: `data_analysis_agent.py`)
- Responses API Loop → Correlation Matrix: dispatches (evidence: `data_analysis_agent.py`)
- Responses API Loop → Grouped Summaries: dispatches (evidence: `data_analysis_agent.py`)
