# tuanduy35399/ml-research-agent architecture

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

- Interactive diagram: https://gitdiagram.com/tuanduy35399/ml-research-agent
- Repository: https://github.com/tuanduy35399/ml-research-agent

## Overview

This is a web application for multi-agent research: a user submits a question, the backend plans up to three subquestions, embeds and classifies them, runs web-search agents, and produces a sourced Markdown report. The interface also supports workflow monitoring, session history, report access, and an ML dashboard. The graph reflects documented API routes and sampled calls; some unsampled subsystem links are omitted rather than inferred.

Main entry points: [`frontend/src/main.tsx`](https://github.com/tuanduy35399/ml-research-agent/blob/main/frontend/src/main.tsx) (Application shell), [`agent_service/src/pipeline.py`](https://github.com/tuanduy35399/ml-research-agent/blob/main/agent_service/src/pipeline.py) (Research pipeline), [`agent_service/src/api.py`](https://github.com/tuanduy35399/ml-research-agent/blob/main/agent_service/src/api.py) (FastAPI endpoints), [`agent_service/src/ml_service.py`](https://github.com/tuanduy35399/ml-research-agent/blob/main/agent_service/src/ml_service.py) (ML service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web interface"]
  node_app["Application shell<br/>[main.tsx]"]
  node_research_ui["Research view<br/>[Research.tsx]"]
  node_workflow_ui["Workflow view<br/>[Workflow.tsx]"]
  node_history_ui["Session history<br/>[SessionHistory.tsx]"]
  node_reports_ui["Reports view<br/>[Reports.tsx]"]
  node_ml_ui["ML dashboard<br/>[MLDashboard.tsx]"]
  node_workspace["Workspace state<br/>[useWorkspace.ts]"]
  node_research_client["Research API client<br/>[researchService.ts]"]
  node_ml_client["ML API client<br/>[mlService.ts]"]
end

subgraph group_backend["Research backend"]
  node_api["FastAPI endpoints<br/>[api.py]"]
  node_session_service["Research session service"]
  node_pipeline["Research pipeline<br/>[pipeline.py]"]
  node_planning["Plan and task preparation<br/>[phases.py]"]
  node_search_agents["Research agents<br/>[phases.py]"]
  node_report_tools["Search and report tools<br/>[tools.py]"]
  node_llm["LLM access<br/>[llm.py]"]
end

subgraph group_ml["ML classification"]
  node_classifier_service["ML service<br/>[ml_service.py]"]
  node_embedding_classifier["Embedding and SVM"]
  node_topic_policy["Topic search policies<br/>[topics.py]"]
end

subgraph group_persistence["Session and reports"]
  node_store[("JSON session store<br/>[store.py]")]
  node_research_data[("Session and report files<br/>[settings.py]")]
end

node_user(("Research user"))
node_jina{{"Jina embeddings"}}
node_tavily{{"Tavily search"}}
node_llm_provider{{"LLM provider"}}

node_user -->|"submits question"| node_research_ui
node_app -->|"renders"| node_research_ui
node_app -->|"renders"| node_workflow_ui
node_app -->|"renders"| node_history_ui
node_app -->|"renders"| node_reports_ui
node_app -->|"renders"| node_ml_ui
node_app -->|"uses state"| node_workspace
node_workspace -->|"calls"| node_research_client
node_research_ui -->|"starts research"| node_research_client
node_ml_ui -->|"requests ML data"| node_ml_client
node_research_client -->|"calls research routes"| node_api
node_ml_client -->|"calls ML routes"| node_api
node_api -->|"dispatches sessions"| node_session_service
node_api -->|"serves ML endpoints"| node_classifier_service
node_session_service -->|"runs pipeline"| node_pipeline
node_session_service -->|"persists sessions"| node_store
node_pipeline -->|"prepares tasks"| node_planning
node_pipeline -->|"classifies tasks"| node_classifier_service
node_pipeline -->|"runs task agents"| node_search_agents
node_pipeline -->|"creates report"| node_report_tools
node_planning -->|"plans questions"| node_llm
node_search_agents -->|"uses search tools"| node_report_tools
node_classifier_service -->|"embeds and predicts"| node_embedding_classifier
node_classifier_service -->|"selects policy"| node_topic_policy
node_pipeline -->|"requests embeddings"| node_jina
node_report_tools -->|"searches web"| node_tavily
node_llm -.->|"sends prompts"| node_llm_provider
node_embedding_classifier -->|"requests vectors"| node_jina
node_store -->|"writes JSON"| node_research_data

click node_app "https://github.com/tuanduy35399/ml-research-agent/blob/main/frontend/src/main.tsx"
click node_research_ui "https://github.com/tuanduy35399/ml-research-agent/blob/main/frontend/src/components/Research.tsx"
click node_workflow_ui "https://github.com/tuanduy35399/ml-research-agent/blob/main/frontend/src/components/Workflow.tsx"
click node_history_ui "https://github.com/tuanduy35399/ml-research-agent/blob/main/frontend/src/components/SessionHistory.tsx"
click node_reports_ui "https://github.com/tuanduy35399/ml-research-agent/blob/main/frontend/src/components/Reports.tsx"
click node_ml_ui "https://github.com/tuanduy35399/ml-research-agent/blob/main/frontend/src/components/MLDashboard.tsx"
click node_workspace "https://github.com/tuanduy35399/ml-research-agent/blob/main/frontend/src/state/useWorkspace.ts"
click node_research_client "https://github.com/tuanduy35399/ml-research-agent/blob/main/frontend/src/services/researchService.ts"
click node_ml_client "https://github.com/tuanduy35399/ml-research-agent/blob/main/frontend/src/services/mlService.ts"
click node_api "https://github.com/tuanduy35399/ml-research-agent/blob/main/agent_service/src/api.py"
click node_session_service "https://github.com/tuanduy35399/ml-research-agent/blob/main/agent_service/src/research_service.py"
click node_pipeline "https://github.com/tuanduy35399/ml-research-agent/blob/main/agent_service/src/pipeline.py"
click node_planning "https://github.com/tuanduy35399/ml-research-agent/blob/main/agent_service/src/phases.py"
click node_search_agents "https://github.com/tuanduy35399/ml-research-agent/blob/main/agent_service/src/phases.py"
click node_report_tools "https://github.com/tuanduy35399/ml-research-agent/blob/main/agent_service/src/tools.py"
click node_llm "https://github.com/tuanduy35399/ml-research-agent/blob/main/agent_service/src/llm.py"
click node_classifier_service "https://github.com/tuanduy35399/ml-research-agent/blob/main/agent_service/src/ml_service.py"
click node_embedding_classifier "https://github.com/tuanduy35399/ml-research-agent/blob/main/ML/topic_classifier.py"
click node_topic_policy "https://github.com/tuanduy35399/ml-research-agent/blob/main/agent_service/src/topics.py"
click node_store "https://github.com/tuanduy35399/ml-research-agent/blob/main/agent_service/src/store.py"
click node_research_data "https://github.com/tuanduy35399/ml-research-agent/blob/main/agent_service/src/settings.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_app,node_research_ui,node_workflow_ui,node_history_ui,node_reports_ui,node_ml_ui,node_workspace,node_research_client,node_ml_client,node_user toneBlue
class node_api,node_session_service,node_pipeline,node_planning,node_search_agents,node_report_tools,node_llm toneAmber
class node_classifier_service,node_embedding_classifier,node_topic_policy toneMint
class node_store,node_research_data toneRose
class node_jina,node_tavily,node_llm_provider toneIndigo
```

## Components

### Web interface

- [Application shell](https://github.com/tuanduy35399/ml-research-agent/blob/main/frontend/src/main.tsx): `frontend/src/main.tsx`
- [Research view](https://github.com/tuanduy35399/ml-research-agent/blob/main/frontend/src/components/Research.tsx): `frontend/src/components/Research.tsx`
- [Workflow view](https://github.com/tuanduy35399/ml-research-agent/blob/main/frontend/src/components/Workflow.tsx): `frontend/src/components/Workflow.tsx`
- [Session history](https://github.com/tuanduy35399/ml-research-agent/blob/main/frontend/src/components/SessionHistory.tsx): `frontend/src/components/SessionHistory.tsx`
- [Reports view](https://github.com/tuanduy35399/ml-research-agent/blob/main/frontend/src/components/Reports.tsx): `frontend/src/components/Reports.tsx`
- [ML dashboard](https://github.com/tuanduy35399/ml-research-agent/blob/main/frontend/src/components/MLDashboard.tsx): `frontend/src/components/MLDashboard.tsx`
- [Workspace state](https://github.com/tuanduy35399/ml-research-agent/blob/main/frontend/src/state/useWorkspace.ts): `frontend/src/state/useWorkspace.ts`
- [Research API client](https://github.com/tuanduy35399/ml-research-agent/blob/main/frontend/src/services/researchService.ts): `frontend/src/services/researchService.ts`
- [ML API client](https://github.com/tuanduy35399/ml-research-agent/blob/main/frontend/src/services/mlService.ts): `frontend/src/services/mlService.ts`

### Research backend

- [FastAPI endpoints](https://github.com/tuanduy35399/ml-research-agent/blob/main/agent_service/src/api.py): `agent_service/src/api.py`
- [Research session service](https://github.com/tuanduy35399/ml-research-agent/blob/main/agent_service/src/research_service.py): `agent_service/src/research_service.py`
- [Research pipeline](https://github.com/tuanduy35399/ml-research-agent/blob/main/agent_service/src/pipeline.py): `agent_service/src/pipeline.py`
- [Plan and task preparation](https://github.com/tuanduy35399/ml-research-agent/blob/main/agent_service/src/phases.py): `agent_service/src/phases.py`
- [Research agents](https://github.com/tuanduy35399/ml-research-agent/blob/main/agent_service/src/phases.py): `agent_service/src/phases.py`
- [Search and report tools](https://github.com/tuanduy35399/ml-research-agent/blob/main/agent_service/src/tools.py): `agent_service/src/tools.py`
- [LLM access](https://github.com/tuanduy35399/ml-research-agent/blob/main/agent_service/src/llm.py): `agent_service/src/llm.py`

### ML classification

- [ML service](https://github.com/tuanduy35399/ml-research-agent/blob/main/agent_service/src/ml_service.py): `agent_service/src/ml_service.py`
- [Embedding and SVM](https://github.com/tuanduy35399/ml-research-agent/blob/main/ML/topic_classifier.py): `ML/topic_classifier.py`
- [Topic search policies](https://github.com/tuanduy35399/ml-research-agent/blob/main/agent_service/src/topics.py): `agent_service/src/topics.py`

### Session and reports

- [JSON session store](https://github.com/tuanduy35399/ml-research-agent/blob/main/agent_service/src/store.py): `agent_service/src/store.py`
- [Session and report files](https://github.com/tuanduy35399/ml-research-agent/blob/main/agent_service/src/settings.py): `agent_service/src/settings.py`

### Other components

- **Research user**
- **Jina embeddings**
- **Tavily search**
- **LLM provider**

## Connections

- Research user → Research view: submits question (evidence: `README.md`)
- Application shell → Research view: renders (evidence: `frontend/src/main.tsx`)
- Application shell → Workflow view: renders (evidence: `frontend/src/main.tsx`)
- Application shell → Session history: renders (evidence: `frontend/src/main.tsx`)
- Application shell → Reports view: renders (evidence: `frontend/src/main.tsx`)
- Application shell → ML dashboard: renders (evidence: `frontend/src/main.tsx`)
- Application shell → Workspace state: uses state (evidence: `frontend/src/main.tsx`)
- Workspace state → Research API client: calls (evidence: `frontend/src/state/useWorkspace.ts`)
- Research view → Research API client: starts research (evidence: `frontend/src/components/Research.tsx`)
- ML dashboard → ML API client: requests ML data (evidence: `frontend/src/components/MLDashboard.tsx`)
- Research API client → FastAPI endpoints: calls research routes (evidence: `README.md`)
- ML API client → FastAPI endpoints: calls ML routes (evidence: `README.md`)
- FastAPI endpoints → Research session service: dispatches sessions (evidence: `agent_service/src/api.py`)
- FastAPI endpoints → ML service: serves ML endpoints (evidence: `agent_service/src/api.py`)
- Research session service → Research pipeline: runs pipeline (evidence: `agent_service/src/research_service.py`)
- Research session service → JSON session store: persists sessions (evidence: `agent_service/src/research_service.py`)
- Research pipeline → Plan and task preparation: prepares tasks (evidence: `agent_service/src/pipeline.py`)
- Research pipeline → ML service: classifies tasks (evidence: `agent_service/src/pipeline.py`)
- Research pipeline → Research agents: runs task agents (evidence: `agent_service/src/pipeline.py`)
- Research pipeline → Search and report tools: creates report (evidence: `agent_service/src/pipeline.py`)
- Plan and task preparation → LLM access: plans questions (evidence: `agent_service/src/phases.py`)
- Research agents → Search and report tools: uses search tools (evidence: `agent_service/src/phases.py`)
- ML service → Embedding and SVM: embeds and predicts (evidence: `agent_service/src/ml_service.py`)
- ML service → Topic search policies: selects policy (evidence: `agent_service/src/ml_service.py`)
- Research pipeline → Jina embeddings: requests embeddings (evidence: `agent_service/src/pipeline.py`)
- Search and report tools → Tavily search: searches web (evidence: `README.md`)
- LLM access → LLM provider: sends prompts (evidence: `README.md`)
- Embedding and SVM → Jina embeddings: requests vectors (evidence: `README.md`)
- JSON session store → Session and report files: writes JSON (evidence: `agent_service/src/store.py`)
