# yanhuo8024/data-tool architecture

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

- Interactive diagram: https://gitdiagram.com/yanhuo8024/data-tool
- Repository: https://github.com/yanhuo8024/data-tool

## Overview

data.tool is a local Flask data workbench. Users bring in files or external data, prepare and analyze it, then build models, run financial and causal analyses, and generate reports; AI assistants and knowledge retrieval provide an additional path through the same workspace. The graph preserves the README’s major capability areas. Several subsystem links are documented at product level rather than demonstrated in sampled implementation, so those edges cite the README.

Main entry points: [`routes`](https://github.com/yanhuo8024/data-tool/tree/main/routes) (API routes), [`ai_agent.py`](https://github.com/yanhuo8024/data-tool/blob/main/ai_agent.py) (Tool-using agent), [`llm_client.py`](https://github.com/yanhuo8024/data-tool/blob/main/llm_client.py) (LLM provider client), [`agent_pipeline.py`](https://github.com/yanhuo8024/data-tool/blob/main/agent_pipeline.py) (Agent pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web workspace"]
  node_webui["Web interface<br/>[core.js]"]
  node_routes["API routes"]
end

subgraph group_data["Data workflow"]
  node_ingest["Data acquisition<br/>[scraper.py]"]
  node_prepare["Data preparation<br/>[clean_advanced.py]"]
  node_lineage["Data lineage<br/>[data_lineage.py]"]
end

subgraph group_analysis["Analytics and finance"]
  node_analytics["Statistical analysis"]
  node_charts["Chart insights"]
  node_ml["Machine learning<br/>[ml_module.py]"]
  node_finance["Quant and valuation<br/>[finance_quant.py]"]
  node_causal["DID analysis<br/>[did.py]"]
  node_reports["Company reports"]
end

subgraph group_ai["AI and knowledge"]
  node_assistant["AI assistant<br/>[ai_assistant.py]"]
  node_agent["Tool-using agent<br/>[ai_agent.py]"]
  node_multiagent["Agent pipeline<br/>[agent_pipeline.py]"]
  node_debate["Agent debate<br/>[debate_engine.py]"]
  node_knowledge["Knowledge RAG<br/>[knowledge_rag.py]"]
  node_nlq["Natural-language SQL<br/>[nlq_engine.py]"]
end

subgraph group_platform["Shared platform"]
  node_llm["LLM provider client<br/>[llm_client.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_storage[("Local data store<br/>[database.py]")]
end

node_user(("Workbench user"))

node_user -->|"uses"| node_webui
node_webui -.->|"requests"| node_routes
node_routes -->|"guards"| node_auth
node_routes -.->|"offers acquisition"| node_ingest
node_routes -.->|"offers cleaning"| node_prepare
node_routes -.->|"runs analysis"| node_analytics
node_routes -->|"requests insights"| node_charts
node_routes -->|"runs models"| node_ml
node_routes -->|"serves finance"| node_finance
node_routes -.->|"serves DID"| node_causal
node_routes -->|"requests reports"| node_reports
node_routes -->|"serves assistant"| node_assistant
node_routes -->|"starts agent"| node_agent
node_routes -->|"starts pipeline"| node_multiagent
node_routes -.->|"serves NLQ"| node_nlq
node_routes -->|"uses lineage"| node_lineage
node_prepare -.->|"persists data"| node_storage
node_lineage -.->|"records provenance"| node_storage
node_analytics -->|"runs regressions"| node_causal
node_assistant -->|"requests completion"| node_llm
node_agent -.->|"requests completion"| node_llm
node_agent -->|"retrieves knowledge"| node_knowledge
node_multiagent -.->|"requests completion"| node_llm
node_multiagent -.->|"runs agent stages"| node_agent
node_debate -->|"calls roles"| node_llm
node_reports -->|"uses valuation"| node_finance

click node_webui "https://github.com/yanhuo8024/data-tool/blob/main/static/static/js/core.js"
click node_routes "https://github.com/yanhuo8024/data-tool/tree/main/routes"
click node_ingest "https://github.com/yanhuo8024/data-tool/blob/main/scraper.py"
click node_prepare "https://github.com/yanhuo8024/data-tool/blob/main/clean_advanced.py"
click node_lineage "https://github.com/yanhuo8024/data-tool/blob/main/data_lineage.py"
click node_analytics "https://github.com/yanhuo8024/data-tool/blob/main/ai_analysis_engine.py"
click node_charts "https://github.com/yanhuo8024/data-tool/blob/main/chart_insight_engine.py"
click node_ml "https://github.com/yanhuo8024/data-tool/blob/main/ml_module.py"
click node_finance "https://github.com/yanhuo8024/data-tool/blob/main/finance_quant.py"
click node_causal "https://github.com/yanhuo8024/data-tool/blob/main/did.py"
click node_reports "https://github.com/yanhuo8024/data-tool/blob/main/company_analysis.py"
click node_assistant "https://github.com/yanhuo8024/data-tool/blob/main/ai_assistant.py"
click node_agent "https://github.com/yanhuo8024/data-tool/blob/main/ai_agent.py"
click node_multiagent "https://github.com/yanhuo8024/data-tool/blob/main/agent_pipeline.py"
click node_debate "https://github.com/yanhuo8024/data-tool/blob/main/debate_engine.py"
click node_knowledge "https://github.com/yanhuo8024/data-tool/blob/main/knowledge_rag.py"
click node_nlq "https://github.com/yanhuo8024/data-tool/blob/main/nlq_engine.py"
click node_llm "https://github.com/yanhuo8024/data-tool/blob/main/llm_client.py"
click node_auth "https://github.com/yanhuo8024/data-tool/blob/main/auth.py"
click node_storage "https://github.com/yanhuo8024/data-tool/blob/main/database.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_webui,node_routes,node_user toneBlue
class node_ingest,node_prepare,node_lineage toneAmber
class node_analytics,node_charts,node_ml,node_finance,node_causal,node_reports toneMint
class node_assistant,node_agent,node_multiagent,node_debate,node_knowledge,node_nlq toneRose
class node_llm,node_auth,node_storage toneIndigo
```

## Components

### Web workspace

- [Web interface](https://github.com/yanhuo8024/data-tool/blob/main/static/static/js/core.js): `static/static/js/core.js`
- [API routes](https://github.com/yanhuo8024/data-tool/tree/main/routes): `routes`

### Data workflow

- [Data acquisition](https://github.com/yanhuo8024/data-tool/blob/main/scraper.py): `scraper.py`
- [Data preparation](https://github.com/yanhuo8024/data-tool/blob/main/clean_advanced.py): `clean_advanced.py`
- [Data lineage](https://github.com/yanhuo8024/data-tool/blob/main/data_lineage.py): `data_lineage.py`

### Analytics and finance

- [Statistical analysis](https://github.com/yanhuo8024/data-tool/blob/main/ai_analysis_engine.py): `ai_analysis_engine.py`
- [Chart insights](https://github.com/yanhuo8024/data-tool/blob/main/chart_insight_engine.py): `chart_insight_engine.py`
- [Machine learning](https://github.com/yanhuo8024/data-tool/blob/main/ml_module.py): `ml_module.py`
- [Quant and valuation](https://github.com/yanhuo8024/data-tool/blob/main/finance_quant.py): `finance_quant.py`
- [DID analysis](https://github.com/yanhuo8024/data-tool/blob/main/did.py): `did.py`
- [Company reports](https://github.com/yanhuo8024/data-tool/blob/main/company_analysis.py): `company_analysis.py`

### AI and knowledge

- [AI assistant](https://github.com/yanhuo8024/data-tool/blob/main/ai_assistant.py): `ai_assistant.py`
- [Tool-using agent](https://github.com/yanhuo8024/data-tool/blob/main/ai_agent.py): `ai_agent.py`
- [Agent pipeline](https://github.com/yanhuo8024/data-tool/blob/main/agent_pipeline.py): `agent_pipeline.py`
- [Agent debate](https://github.com/yanhuo8024/data-tool/blob/main/debate_engine.py): `debate_engine.py`
- [Knowledge RAG](https://github.com/yanhuo8024/data-tool/blob/main/knowledge_rag.py): `knowledge_rag.py`
- [Natural-language SQL](https://github.com/yanhuo8024/data-tool/blob/main/nlq_engine.py): `nlq_engine.py`

### Shared platform

- [LLM provider client](https://github.com/yanhuo8024/data-tool/blob/main/llm_client.py): `llm_client.py`
- [Authentication](https://github.com/yanhuo8024/data-tool/blob/main/auth.py): `auth.py`
- [Local data store](https://github.com/yanhuo8024/data-tool/blob/main/database.py): `database.py`

### Other components

- **Workbench user**

## Connections

- Workbench user → Web interface: uses
- Web interface → API routes: requests
- API routes → Authentication: guards (evidence: `routes/ai_assistant_routes.py`)
- API routes → Data acquisition: offers acquisition
- API routes → Data preparation: offers cleaning
- API routes → Statistical analysis: runs analysis (evidence: `routes/ai_assistant_routes.py`)
- API routes → Chart insights: requests insights (evidence: `routes/data_routes.py`)
- API routes → Machine learning: runs models (evidence: `routes/ml_routes.py`)
- API routes → Quant and valuation: serves finance (evidence: `routes/finance_routes.py`)
- API routes → DID analysis: serves DID
- API routes → Company reports: requests reports (evidence: `routes/system_routes.py`)
- API routes → AI assistant: serves assistant (evidence: `routes/ai_assistant_routes.py`)
- API routes → Tool-using agent: starts agent (evidence: `routes/ai_assistant_routes.py`)
- API routes → Agent pipeline: starts pipeline (evidence: `routes/ai_assistant_routes.py`)
- API routes → Natural-language SQL: serves NLQ
- API routes → Data lineage: uses lineage (evidence: `routes/data_routes.py`)
- Data preparation → Local data store: persists data
- Data lineage → Local data store: records provenance
- Statistical analysis → DID analysis: runs regressions (evidence: `ai_analysis_engine.py`)
- AI assistant → LLM provider client: requests completion (evidence: `ai_assistant.py`)
- Tool-using agent → LLM provider client: requests completion (evidence: `ai_agent.py`)
- Tool-using agent → Knowledge RAG: retrieves knowledge (evidence: `ai_agent.py`)
- Agent pipeline → LLM provider client: requests completion (evidence: `agent_pipeline.py`)
- Agent pipeline → Tool-using agent: runs agent stages (evidence: `agent_pipeline.py`)
- Agent debate → LLM provider client: calls roles (evidence: `debate_engine.py`)
- Company reports → Quant and valuation: uses valuation (evidence: `company_analysis.py`)
