# dzhng/deep-research architecture

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

- Interactive diagram: https://gitdiagram.com/dzhng/deep-research
- Repository: https://github.com/dzhng/deep-research

## Overview

Open Deep Research is an iterative research assistant exposed through an interactive CLI and an HTTP API. A user supplies a topic and breadth/depth; the CLI can first collect follow-up answers. The research engine generates search queries, searches and analyzes web results into learnings and follow-up directions, and recursively explores them until depth is exhausted. It then produces a report or concise answer. The README also documents parallel search processing and configurable model providers. Edges reflect shown calls or README workflows; unsampled implementation details are omitted.

Main entry points: [`src/deep-research.ts`](https://github.com/dzhng/deep-research/blob/main/src/deep-research.ts) (Research Orchestrator), [`src/ai/providers.ts`](https://github.com/dzhng/deep-research/blob/main/src/ai/providers.ts) (Model Selection), [`src/run.ts`](https://github.com/dzhng/deep-research/blob/main/src/run.ts) (Interactive CLI), [`src/api.ts`](https://github.com/dzhng/deep-research/blob/main/src/api.ts) (HTTP API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry Points"]
  node_cli["Interactive CLI<br/>[run.ts]"]
  node_api["HTTP API<br/>[api.ts]"]
end

subgraph group_research["Research Workflow"]
  node_feedback["Follow-up Questions<br/>[feedback.ts]"]
  node_engine["Research Orchestrator<br/>[deep-research.ts]"]
  node_querygen["Query Generation<br/>[deep-research.ts]"]
  node_websearch["Web Search<br/>[deep-research.ts]"]
  node_resultanalysis["Result Analysis<br/>[deep-research.ts]"]
  node_exploration["Recursive Exploration<br/>[deep-research.ts]"]
end

subgraph group_ai["AI Support"]
  node_modelconfig["Model Selection<br/>[providers.ts]"]
  node_prompttrim["Prompt Trimming<br/>[providers.ts]"]
  node_splitter["Text Splitting<br/>[text-splitter.ts]"]
  node_instructions["Research Instructions<br/>[prompt.ts]"]
end

subgraph group_outputs["Results"]
  node_report["Markdown Report<br/>[deep-research.ts]"]
  node_answer["Concise Answer<br/>[deep-research.ts]"]
end

node_user(("Researcher"))
node_modelservice["LLM Provider"]
node_firecrawl["Firecrawl Search"]

node_user -->|"enters query"| node_cli
node_user -->|"submits request"| node_api
node_cli -->|"requests questions"| node_feedback
node_cli -->|"starts research"| node_engine
node_cli -->|"requests report"| node_report
node_cli -->|"requests answer"| node_answer
node_api -->|"starts research"| node_engine
node_api -->|"requests report"| node_report
node_api -->|"requests answer"| node_answer
node_feedback -->|"gets model"| node_modelconfig
node_feedback -->|"uses instructions"| node_instructions
node_engine -->|"generates queries"| node_querygen
node_engine -->|"runs searches"| node_websearch
node_engine -->|"processes results"| node_resultanalysis
node_engine -->|"recurses by depth"| node_exploration
node_engine -->|"generates report"| node_report
node_engine -->|"generates answer"| node_answer
node_querygen -->|"gets model"| node_modelconfig
node_querygen -->|"uses instructions"| node_instructions
node_resultanalysis -->|"gets model"| node_modelconfig
node_resultanalysis -->|"uses instructions"| node_instructions
node_websearch -->|"searches and scrapes"| node_firecrawl
node_report -->|"gets model"| node_modelconfig
node_answer -->|"gets model"| node_modelconfig
node_modelconfig -->|"selects provider"| node_modelservice
node_modelconfig -->|"trims prompts"| node_prompttrim
node_prompttrim -->|"splits oversized text"| node_splitter

click node_cli "https://github.com/dzhng/deep-research/blob/main/src/run.ts"
click node_api "https://github.com/dzhng/deep-research/blob/main/src/api.ts"
click node_feedback "https://github.com/dzhng/deep-research/blob/main/src/feedback.ts"
click node_engine "https://github.com/dzhng/deep-research/blob/main/src/deep-research.ts"
click node_querygen "https://github.com/dzhng/deep-research/blob/main/src/deep-research.ts"
click node_websearch "https://github.com/dzhng/deep-research/blob/main/src/deep-research.ts"
click node_resultanalysis "https://github.com/dzhng/deep-research/blob/main/src/deep-research.ts"
click node_exploration "https://github.com/dzhng/deep-research/blob/main/src/deep-research.ts"
click node_modelconfig "https://github.com/dzhng/deep-research/blob/main/src/ai/providers.ts"
click node_prompttrim "https://github.com/dzhng/deep-research/blob/main/src/ai/providers.ts"
click node_splitter "https://github.com/dzhng/deep-research/blob/main/src/ai/text-splitter.ts"
click node_instructions "https://github.com/dzhng/deep-research/blob/main/src/prompt.ts"
click node_report "https://github.com/dzhng/deep-research/blob/main/src/deep-research.ts"
click node_answer "https://github.com/dzhng/deep-research/blob/main/src/deep-research.ts"

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,node_api toneBlue
class node_feedback,node_engine,node_querygen,node_websearch,node_resultanalysis,node_exploration toneAmber
class node_modelconfig,node_prompttrim,node_splitter,node_instructions toneMint
class node_report,node_answer toneRose
class node_user,node_modelservice,node_firecrawl toneIndigo
```

## Components

### Entry Points

- [Interactive CLI](https://github.com/dzhng/deep-research/blob/main/src/run.ts): `src/run.ts`
- [HTTP API](https://github.com/dzhng/deep-research/blob/main/src/api.ts): `src/api.ts`

### Research Workflow

- [Follow-up Questions](https://github.com/dzhng/deep-research/blob/main/src/feedback.ts): `src/feedback.ts`
- [Research Orchestrator](https://github.com/dzhng/deep-research/blob/main/src/deep-research.ts): `src/deep-research.ts`
- [Query Generation](https://github.com/dzhng/deep-research/blob/main/src/deep-research.ts): `src/deep-research.ts`
- [Web Search](https://github.com/dzhng/deep-research/blob/main/src/deep-research.ts): `src/deep-research.ts`
- [Result Analysis](https://github.com/dzhng/deep-research/blob/main/src/deep-research.ts): `src/deep-research.ts`
- [Recursive Exploration](https://github.com/dzhng/deep-research/blob/main/src/deep-research.ts): `src/deep-research.ts`

### AI Support

- [Model Selection](https://github.com/dzhng/deep-research/blob/main/src/ai/providers.ts): `src/ai/providers.ts`
- [Prompt Trimming](https://github.com/dzhng/deep-research/blob/main/src/ai/providers.ts): `src/ai/providers.ts`
- [Text Splitting](https://github.com/dzhng/deep-research/blob/main/src/ai/text-splitter.ts): `src/ai/text-splitter.ts`
- [Research Instructions](https://github.com/dzhng/deep-research/blob/main/src/prompt.ts): `src/prompt.ts`

### Results

- [Markdown Report](https://github.com/dzhng/deep-research/blob/main/src/deep-research.ts): `src/deep-research.ts`
- [Concise Answer](https://github.com/dzhng/deep-research/blob/main/src/deep-research.ts): `src/deep-research.ts`

### Other components

- **Researcher**
- **LLM Provider**
- **Firecrawl Search**

## Connections

- Researcher → Interactive CLI: enters query (evidence: `src/run.ts`)
- Researcher → HTTP API: submits request (evidence: `src/api.ts`)
- Interactive CLI → Follow-up Questions: requests questions (evidence: `src/run.ts`)
- Interactive CLI → Research Orchestrator: starts research (evidence: `src/run.ts`)
- Interactive CLI → Markdown Report: requests report (evidence: `src/run.ts`)
- Interactive CLI → Concise Answer: requests answer (evidence: `src/run.ts`)
- HTTP API → Research Orchestrator: starts research (evidence: `src/api.ts`)
- HTTP API → Markdown Report: requests report (evidence: `src/api.ts`)
- HTTP API → Concise Answer: requests answer (evidence: `src/api.ts`)
- Follow-up Questions → Model Selection: gets model (evidence: `src/feedback.ts`)
- Follow-up Questions → Research Instructions: uses instructions (evidence: `src/feedback.ts`)
- Research Orchestrator → Query Generation: generates queries (evidence: `src/deep-research.ts`)
- Research Orchestrator → Web Search: runs searches (evidence: `src/deep-research.ts`)
- Research Orchestrator → Result Analysis: processes results (evidence: `src/deep-research.ts`)
- Research Orchestrator → Recursive Exploration: recurses by depth (evidence: `src/deep-research.ts`)
- Research Orchestrator → Markdown Report: generates report (evidence: `src/deep-research.ts`)
- Research Orchestrator → Concise Answer: generates answer (evidence: `src/deep-research.ts`)
- Query Generation → Model Selection: gets model (evidence: `src/deep-research.ts`)
- Query Generation → Research Instructions: uses instructions (evidence: `src/deep-research.ts`)
- Result Analysis → Model Selection: gets model (evidence: `src/deep-research.ts`)
- Result Analysis → Research Instructions: uses instructions (evidence: `src/deep-research.ts`)
- Web Search → Firecrawl Search: searches and scrapes (evidence: `src/deep-research.ts`)
- Markdown Report → Model Selection: gets model (evidence: `src/deep-research.ts`)
- Concise Answer → Model Selection: gets model (evidence: `src/deep-research.ts`)
- Model Selection → LLM Provider: selects provider (evidence: `src/ai/providers.ts`)
- Model Selection → Prompt Trimming: trims prompts (evidence: `src/ai/providers.ts`)
- Prompt Trimming → Text Splitting: splits oversized text (evidence: `src/ai/providers.ts`)
