# aammartufail/data_analysis_ai_agent_01 architecture

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

- Interactive diagram: https://gitdiagram.com/aammartufail/data_analysis_ai_agent_01
- Repository: https://github.com/aammartufail/data_analysis_ai_agent_01

## Overview

This is a LangGraph data-analysis agent: a user supplies a dataset and question, and the agent produces an auditable Markdown report with computed results, charts, cleaning notes, and interpretation. Its workflow loads and profiles data, then fans out into deterministic cleaning and LLM planning. Analysis code is generated, run in a subprocess, and may loop through repair before interpretation and report assembly. The graph wiring and sampled node code support the main workflow; some subsystem details, including cleaning and reporting branches, are documented in the README rather than fully sampled.

Main entry points: [`agent/graph.py`](https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/graph.py) (Graph Orchestrator), [`agent/nodes/llm_integration.py`](https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/nodes/llm_integration.py) (LLM Stages), [`agent/llm.py`](https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/llm.py) (LLM Backend Factory), [`agent/nodes/analysis.py`](https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/nodes/analysis.py) (Analysis Controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User Interface"]
  node_cli["Command Line<br/>[cli.py]"]
end

subgraph group_workflow["Analysis Workflow"]
  node_orchestrator["Graph Orchestrator<br/>[graph.py]"]
  node_ingest["Dataset Ingest<br/>[ingest.py]"]
  node_profiling["Load + Profile<br/>[profiling.py]"]
  node_cleaning["Data Cleaning<br/>[cleaning.py]"]
  node_llm_stage["LLM Stages<br/>[llm_integration.py]"]
  node_report["Report Assembly<br/>[report.py]"]
end

subgraph group_execution["Analysis Execution"]
  node_analysis["Analysis Controller<br/>[analysis.py]"]
  node_sandbox["Code Sandbox<br/>[sandbox.py]"]
end

subgraph group_foundation["Shared Runtime"]
  node_state["Shared State<br/>[state.py]"]
  node_prompts["Prompt Templates<br/>[prompts.py]"]
  node_llm_factory["LLM Backend Factory<br/>[llm.py]"]
  node_config["Runtime Settings<br/>[config.py]"]
end

node_user(("Dataset + Question"))
node_ollama["Ollama"]
node_openai["OpenAI API"]

node_user -->|"submits request"| node_cli
node_cli -->|"runs workflow"| node_orchestrator
node_orchestrator -->|"dispatches first"| node_ingest
node_orchestrator -->|"fans out"| node_cleaning
node_orchestrator -->|"fans out"| node_llm_stage
node_orchestrator -->|"routes branches"| node_analysis
node_orchestrator -->|"routes completion"| node_report
node_ingest -->|"loads and profiles"| node_profiling
node_cleaning -->|"cleans data"| node_profiling
node_llm_stage -->|"formats requests"| node_prompts
node_llm_stage -->|"requests completions"| node_llm_factory
node_llm_factory -->|"reads settings"| node_config
node_llm_factory -.->|"invokes model"| node_ollama
node_llm_factory -.->|"invokes API"| node_openai
node_analysis -->|"executes code"| node_sandbox
node_analysis -->|"requests code or repair"| node_llm_stage
node_llm_stage -->|"routes generated code"| node_analysis
node_llm_stage -->|"routes interpretation"| node_report
node_report -.->|"returns report path"| node_cli

click node_cli "https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/cli.py"
click node_orchestrator "https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/graph.py"
click node_state "https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/state.py"
click node_ingest "https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/nodes/ingest.py"
click node_profiling "https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/profiling.py"
click node_cleaning "https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/nodes/cleaning.py"
click node_llm_stage "https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/nodes/llm_integration.py"
click node_prompts "https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/prompts.py"
click node_llm_factory "https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/llm.py"
click node_config "https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/config.py"
click node_analysis "https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/nodes/analysis.py"
click node_sandbox "https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/sandbox.py"
click node_report "https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/nodes/report.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_cli toneBlue
class node_orchestrator,node_ingest,node_profiling,node_cleaning,node_llm_stage,node_report toneAmber
class node_analysis,node_sandbox,node_openai toneMint
class node_state,node_prompts,node_llm_factory,node_config toneRose
class node_user,node_ollama toneIndigo
```

## Components

### User Interface

- [Command Line](https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/cli.py): `agent/cli.py`

### Analysis Workflow

- [Graph Orchestrator](https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/graph.py): `agent/graph.py`
- [Dataset Ingest](https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/nodes/ingest.py): `agent/nodes/ingest.py`
- [Load + Profile](https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/profiling.py): `agent/profiling.py`
- [Data Cleaning](https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/nodes/cleaning.py): `agent/nodes/cleaning.py`
- [LLM Stages](https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/nodes/llm_integration.py): `agent/nodes/llm_integration.py`
- [Report Assembly](https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/nodes/report.py): `agent/nodes/report.py`

### Analysis Execution

- [Analysis Controller](https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/nodes/analysis.py): `agent/nodes/analysis.py`
- [Code Sandbox](https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/sandbox.py): `agent/sandbox.py`

### Shared Runtime

- [Shared State](https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/state.py): `agent/state.py`
- [Prompt Templates](https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/prompts.py): `agent/prompts.py`
- [LLM Backend Factory](https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/llm.py): `agent/llm.py`
- [Runtime Settings](https://github.com/aammartufail/data_analysis_ai_agent_01/blob/main/agent/config.py): `agent/config.py`

### Other components

- **Dataset + Question**
- **Ollama**
- **OpenAI API**

## Connections

- Dataset + Question → Command Line: submits request (evidence: `README.md`)
- Command Line → Graph Orchestrator: runs workflow (evidence: `agent/cli.py`)
- Graph Orchestrator → Dataset Ingest: dispatches first (evidence: `agent/graph.py`)
- Graph Orchestrator → Data Cleaning: fans out (evidence: `agent/graph.py`)
- Graph Orchestrator → LLM Stages: fans out (evidence: `agent/graph.py`)
- Graph Orchestrator → Analysis Controller: routes branches (evidence: `agent/graph.py`)
- Graph Orchestrator → Report Assembly: routes completion (evidence: `agent/graph.py`)
- Dataset Ingest → Load + Profile: loads and profiles (evidence: `agent/nodes/ingest.py`)
- Data Cleaning → Load + Profile: cleans data (evidence: `agent/nodes/cleaning.py`)
- LLM Stages → Prompt Templates: formats requests (evidence: `agent/nodes/llm_integration.py`)
- LLM Stages → LLM Backend Factory: requests completions (evidence: `agent/nodes/llm_integration.py`)
- LLM Backend Factory → Runtime Settings: reads settings (evidence: `agent/llm.py`)
- LLM Backend Factory → Ollama: invokes model (evidence: `README.md`)
- LLM Backend Factory → OpenAI API: invokes API (evidence: `README.md`)
- Analysis Controller → Code Sandbox: executes code (evidence: `agent/nodes/analysis.py`)
- Analysis Controller → LLM Stages: requests code or repair
- LLM Stages → Analysis Controller: routes generated code (evidence: `agent/nodes/llm_integration.py`)
- LLM Stages → Report Assembly: routes interpretation (evidence: `agent/nodes/llm_integration.py`)
- Report Assembly → Command Line: returns report path (evidence: `README.md`)
