# ai-analyst-lab/ai-analyst architecture

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

- Interactive diagram: https://gitdiagram.com/ai-analyst-lab/ai-analyst
- Repository: https://github.com/ai-analyst-lab/ai-analyst

## Overview

AI Analyst is an AI data analyst that runs in Claude Code. The user connects a dataset and asks a question; the analyst’s multi-step pipeline coordinates configured model engines, while deterministic helpers support profiling, metric queries, statistics, validation, and provenance. It then produces shareable briefs, charts, or decks, and stores project context for reuse. The README also describes evaluation and reliability workflows. The tree and excerpts expose only part of the runtime wiring, so uncertain connections are omitted rather than inferred.

Main entry points: [`helpers/data/connection_manager.py`](https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/data/connection_manager.py) (Data connections), [`helpers/pipeline/controller.py`](https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/pipeline/controller.py) (Pipeline controller), [`helpers/data/metric_router.py`](https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/data/metric_router.py) (Metric router), [`helpers/knowledge/context_sync.py`](https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/knowledge/context_sync.py) (Context sync)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Analysis workflow"]
  node_pipeline["Pipeline controller<br/>[controller.py]"]
  node_engine_adapter["Claude engine adapter<br/>[claude_cli.py]"]
  node_engine_contract["Engine contracts<br/>[schema.py]"]
end

subgraph group_data_context["Data and context"]
  node_connections["Data connections"]
  node_dialects["SQL dialects<br/>[base.py]"]
  node_schema_guard["Schema guard<br/>[schema_guard.py]"]
  node_context_sync["Context sync<br/>[context_sync.py]"]
  node_context_manifest["Context manifest"]
  node_context_snapshot["Context snapshot"]
  node_connected_store[("Connected context store<br/>[store.py]")]
  node_connected_engine["Semantic query planner<br/>[engine.py]"]
end

subgraph group_analysis_trust["Analysis and trust"]
  node_metric_router["Metric router<br/>[metric_router.py]"]
  node_metric_compiler["Metric compiler<br/>[metric_compiler.py]"]
  node_statistics["Statistical analysis<br/>[power.py]"]
  node_validation["Analysis validation"]
  node_provenance["Evidence provenance<br/>[query_log.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_eval_controller["Evaluation controller<br/>[controller.py]"]
  node_reliability["Reliability statistics"]
end

subgraph group_outputs["Deliverables"]
  node_export["Document export<br/>[gdoc_builder.py]"]
  node_deck_export["Deck export<br/>[marp_export.py]"]
end

node_user(("Analyst user"))
node_claude(("Claude Code"))
node_warehouse[("Data source")]

node_user -->|"asks questions"| node_claude
node_claude -->|"runs workflows"| node_pipeline
node_pipeline -->|"launches workers"| node_engine_adapter
node_pipeline -->|"uses context"| node_context_manifest
node_engine_adapter -->|"implements contract"| node_engine_contract
node_connections -.->|"queries data"| node_warehouse
node_connections -.->|"checks schema"| node_schema_guard
node_connections -.->|"selects dialect"| node_dialects
node_metric_router -->|"routes compiled metrics"| node_metric_compiler
node_metric_compiler -->|"compiles queries for"| node_connections
node_metric_router -->|"loads metric context"| node_context_sync
node_context_manifest -->|"resolves context"| node_context_sync
node_context_sync -->|"checks drift"| node_schema_guard
node_context_snapshot -->|"checks eligibility"| node_connected_store
node_connected_engine -->|"reads definitions"| node_connected_store
node_user -.->|"resolves metric first"| node_metric_router
node_user -.->|"requests experiment analysis"| node_statistics
node_user -.->|"requests trust checks"| node_validation
node_user -->|"runs evaluation"| node_eval_controller
node_eval_controller -.->|"measures repeatability"| node_reliability
node_user -->|"requests document export"| node_export
node_user -->|"requests deck export"| node_deck_export
node_provenance -.->|"supports claim tracing"| node_user

click node_pipeline "https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/pipeline/controller.py"
click node_engine_adapter "https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/engines/claude_cli.py"
click node_engine_contract "https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/engines/schema.py"
click node_connections "https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/data/connection_manager.py"
click node_dialects "https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/data/dialects/base.py"
click node_schema_guard "https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/data/schema_guard.py"
click node_context_sync "https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/knowledge/context_sync.py"
click node_context_manifest "https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/knowledge/context_manifest.py"
click node_context_snapshot "https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/knowledge/context_snapshot.py"
click node_connected_store "https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/connected_context/store.py"
click node_connected_engine "https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/connected_context/engine.py"
click node_metric_router "https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/data/metric_router.py"
click node_metric_compiler "https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/data/metric_compiler.py"
click node_statistics "https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/stats/experiment_stats/power.py"
click node_validation "https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/validation/structural_validator.py"
click node_provenance "https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/provenance/query_log.py"
click node_eval_controller "https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/evals/controller.py"
click node_reliability "https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/stats/reliability_stats.py"
click node_export "https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/export/gdoc_builder.py"
click node_deck_export "https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/export/marp_export.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_pipeline,node_engine_adapter,node_engine_contract,node_user toneBlue
class node_connections,node_dialects,node_schema_guard,node_context_sync,node_context_manifest,node_context_snapshot,node_connected_store,node_connected_engine,node_warehouse toneAmber
class node_metric_router,node_metric_compiler,node_statistics,node_validation,node_provenance toneMint
class node_eval_controller,node_reliability toneRose
class node_export,node_deck_export,node_claude toneIndigo
```

## Components

### Analysis workflow

- [Pipeline controller](https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/pipeline/controller.py): `helpers/pipeline/controller.py`
- [Claude engine adapter](https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/engines/claude_cli.py): `helpers/engines/claude_cli.py`
- [Engine contracts](https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/engines/schema.py): `helpers/engines/schema.py`

### Data and context

- [Data connections](https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/data/connection_manager.py): `helpers/data/connection_manager.py`
- [SQL dialects](https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/data/dialects/base.py): `helpers/data/dialects/base.py`
- [Schema guard](https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/data/schema_guard.py): `helpers/data/schema_guard.py`
- [Context sync](https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/knowledge/context_sync.py): `helpers/knowledge/context_sync.py`
- [Context manifest](https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/knowledge/context_manifest.py): `helpers/knowledge/context_manifest.py`
- [Context snapshot](https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/knowledge/context_snapshot.py): `helpers/knowledge/context_snapshot.py`
- [Connected context store](https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/connected_context/store.py): `helpers/connected_context/store.py`
- [Semantic query planner](https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/connected_context/engine.py): `helpers/connected_context/engine.py`

### Analysis and trust

- [Metric router](https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/data/metric_router.py): `helpers/data/metric_router.py`
- [Metric compiler](https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/data/metric_compiler.py): `helpers/data/metric_compiler.py`
- [Statistical analysis](https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/stats/experiment_stats/power.py): `helpers/stats/experiment_stats/power.py`
- [Analysis validation](https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/validation/structural_validator.py): `helpers/validation/structural_validator.py`
- [Evidence provenance](https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/provenance/query_log.py): `helpers/provenance/query_log.py`

### Evaluation

- [Evaluation controller](https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/evals/controller.py): `helpers/evals/controller.py`
- [Reliability statistics](https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/stats/reliability_stats.py): `helpers/stats/reliability_stats.py`

### Deliverables

- [Document export](https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/export/gdoc_builder.py): `helpers/export/gdoc_builder.py`
- [Deck export](https://github.com/ai-analyst-lab/ai-analyst/blob/main/helpers/export/marp_export.py): `helpers/export/marp_export.py`

### Other components

- **Analyst user**
- **Claude Code**
- **Data source**

## Connections

- Analyst user → Claude Code: asks questions (evidence: `README.md`)
- Claude Code → Pipeline controller: runs workflows (evidence: `README.md`)
- Pipeline controller → Claude engine adapter: launches workers (evidence: `README.md`)
- Pipeline controller → Context manifest: uses context (evidence: `helpers/pipeline/controller.py`)
- Claude engine adapter → Engine contracts: implements contract (evidence: `helpers/engines/claude_cli.py`)
- Data connections → Data source: queries data
- Data connections → Schema guard: checks schema
- Data connections → SQL dialects: selects dialect
- Metric router → Metric compiler: routes compiled metrics (evidence: `helpers/data/metric_router.py`)
- Metric compiler → Data connections: compiles queries for (evidence: `helpers/data/metric_compiler.py`)
- Metric router → Context sync: loads metric context (evidence: `helpers/data/metric_router.py`)
- Context manifest → Context sync: resolves context (evidence: `helpers/knowledge/context_manifest.py`)
- Context sync → Schema guard: checks drift (evidence: `helpers/knowledge/context_sync.py`)
- Context snapshot → Connected context store: checks eligibility (evidence: `helpers/knowledge/context_snapshot.py`)
- Semantic query planner → Connected context store: reads definitions (evidence: `helpers/connected_context/engine.py`)
- Analyst user → Metric router: resolves metric first
- Analyst user → Statistical analysis: requests experiment analysis
- Analyst user → Analysis validation: requests trust checks
- Analyst user → Evaluation controller: runs evaluation (evidence: `README.md`)
- Evaluation controller → Reliability statistics: measures repeatability
- Analyst user → Document export: requests document export (evidence: `README.md`)
- Analyst user → Deck export: requests deck export (evidence: `README.md`)
- Evidence provenance → Analyst user: supports claim tracing
