# researai/deepscientist architecture

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

- Interactive diagram: https://gitdiagram.com/researai/deepscientist
- Repository: https://github.com/researai/deepscientist

## Overview

1. **What this repository is**
   DeepScientist is a local-first autonomous research system, not a single app. Its core architectural idea is “one quest, one repository”: each research effort becomes a durable Git-backed workspace that can accumulate baselines, experiments, notes, artifacts, and writing over time.

2. **Primary runtime and entry points**
   The main backend is the Python package under `src/deepscientist`, exposed through the `ds` CLI. That CLI starts and manages the local daemon, launches quests, coordinates runners, and provides diagnostics and shutdown. The repo also ships separate frontends in `src/ui` and `src/tui`.

3. **Backend control plane**
   The `daemon` package is the control plane. It exposes an API for the UI/TUI, manages sessions, and emits events for long-running operations. This is where the system’s central state transitions happen: project setup, quest lifecycle, task progress, and operational health.

4. **Quest/workspace domain**
   The `quest`, `team`, `memory`, `gitops`, and `runtime_storage` modules define the main research-domain boundary. They model a quest as a structured workspace, track state across stages, map work into Git branches/worktrees, and persist accumulated findings so later runs can reuse prior work instead of restarting from scratch.

5. **Execution layer for agent work**
   Agent actions are executed through runner abstractions in `runners`, shell execution in `bash_exec`, and tool/runtime services in `runtime_tools` and `mcp`. This layer is the boundary between “planning” and “doing”: it runs code, checks environment state, captures logs, and feeds results back into the quest loop.

6. **External coding-tool integrations**
   DeepScientist is designed to plug into existing coding CLIs rather than replace them. The built-in runners target Codex, Claude Code, Kimi Code, and OpenCode. That means the system’s model/execution boundary is intentionally externalized: DeepScientist orchestrates, while the chosen CLI performs many of the actual code-generation and agent steps.

7. **Web workspace frontend**
   `src/ui` is the primary browser workspace. It is a React/Vite application with a plugin-based surface model: project pages, workspace views, settings, lab/canvas views, file and diff viewers, PDF/markdown/notebook viewers, and a chat/coplilot experience. It talks to the daemon and realtime channels to render quest progress and manipulate local project state.

8. **Terminal frontend**
   `src/tui` provides a terminal-native interface for the same backend system. It is useful when the machine is remote or when the user wants a lower-friction operational view. Architecturally, it mirrors the web client’s role: a presentation layer over the daemon and quest services.

9. **Connector boundary**
   The `channels`, `bridges`, and `connector` packages integrate external collaboration surfaces such as QQ, Telegram, Slack, Discord, Weixin, WhatsApp, and Lingzhu/Feishu-style flows. These connectors convert inbound messages and attachments into internal events, and they send status updates or responses back out through the same channel adapters.

10. **Research-content and artifact pipeline**
    The `artifact` and `arxiv_library` modules handle paper-facing inputs and outputs: papers, PDFs, annotations, figures, metrics, and guidance artifacts. This pipeline connects the “research object” side of the system to the workspace, so imported literature and generated outputs live alongside code and experiment traces.

11. **BenchStore and scientific catalogs**
    `benchstore` plus the large `AISB/catalog` tree support benchmark/task catalogs and prompt assembly for research workflows. This is a distinct content layer: curated YAML definitions and generated markdown/prompt material that drive repeatable benchmark-style or challenge-style research runs.

12. **Skills and prompts as operating policies**
    The large `skills` and `src/prompts` trees are the system’s behavior library. They encode stage-specific procedures for idea generation, experiments, review, writing, figure polish, rebuttal, and science workflows. In diagram terms, this is a policy/recipe layer consumed by agents and runners, not just documentation.

13. **Operations, diagnostics, and safety**
    `admin`, `doctor`, `diagnostics`, and related settings modules provide system inspection, repair, metrics, and logging. The web UI surfaces these through dedicated settings and control-center pages, which makes operational health part of the product rather than a separate ops tool.

14. **Persistence and local boundary**
    The system is strongly local in its data model: Git repos, worktrees, caches, runtime state, and browser-side indexed storage all matter. That makes the key architectural boundary the local machine or server itself, with external services limited to model CLIs, chat platforms, paper sources, and optional web/search integrations.

15. **How data flows end-to-end**
    Typical flow is: user starts a quest in the UI/TUI or via connectors; the daemon creates/loads the quest workspace; runners and shell tools execute work inside Git-backed repos; memory/artifact/gitops services record the outcomes; the UI reflects progress in real time; and the resulting outputs remain available for later continuation, review, or publication.

Main entry points: [`src/deepscientist/quest`](https://github.com/researai/deepscientist/tree/main/src/deepscientist/quest) (Quest model), [`src/deepscientist/runners`](https://github.com/researai/deepscientist/tree/main/src/deepscientist/runners) (Runners), [`src/deepscientist/daemon`](https://github.com/researai/deepscientist/tree/main/src/deepscientist/daemon) (Daemon), [`src/ui`](https://github.com/researai/deepscientist/tree/main/src/ui) (Web UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_backend["Backend core"]
  node_node_cli["ds CLI<br/>entrypoint<br/>[cli.py]"]
  node_node_daemon["Daemon<br/>control plane"]
  node_node_quest["Quest model<br/>workspace domain"]
  node_node_team_memory[("Team memory<br/>state services")]
  node_node_gitops{{"Git ops<br/>workspace git"}}
  node_node_runtime_storage[("Runtime storage<br/>local persistence<br/>[runtime_storage.py]")]
  node_node_bash_exec["Bash exec<br/>shell runtime"]
  node_node_runtime_tools["Runtime tools<br/>tool service"]
  node_node_runners["Runners<br/>agent adapters"]
  node_node_mcp{{"MCP<br/>tool protocol"}}
end

subgraph group_group_frontend["User surfaces"]
  node_node_ui["Web UI<br/>react workspace"]
  node_node_tui["TUI<br/>terminal workspace"]
end

subgraph group_group_integrations["Integrations"]
  node_node_channels["Channels<br/>message adapters"]
  node_node_bridges["Bridges<br/>connector glue"]
  node_node_connector_profiles["Connector profiles<br/>integration config"]
end

subgraph group_group_content["Content layer"]
  node_node_prompts["Prompts<br/>policy library"]
  node_node_skills["Skills<br/>workflow recipes"]
  node_node_benchstore[("BenchStore<br/>catalog service")]
  node_node_artifact[("Artifacts<br/>paper pipeline")]
end

subgraph group_group_ops["Operations"]
  node_node_admin["Admin<br/>ops services"]
  node_node_diagnostics(("Diagnostics<br/>health checks"))
end

node_node_cli -->|"starts/manages"| node_node_daemon
node_node_cli -->|"launches quest"| node_node_quest
node_node_daemon -->|"orchestrates"| node_node_quest
node_node_daemon -->|"serves API"| node_node_ui
node_node_daemon -->|"serves API"| node_node_tui
node_node_quest -->|"persists state"| node_node_team_memory
node_node_quest -->|"maps to git"| node_node_gitops
node_node_quest -->|"stores locally"| node_node_runtime_storage
node_node_quest -->|"executes via"| node_node_runners
node_node_runners -->|"runs shell"| node_node_bash_exec
node_node_runners -->|"uses tools"| node_node_runtime_tools
node_node_runners -->|"protocol bridge"| node_node_mcp
node_node_runners -->|"integrates CLIs"| node_node_connector_profiles
node_node_channels -->|"normalizes events"| node_node_bridges
node_node_bridges -->|"feeds events"| node_node_daemon
node_node_ui -->|"views artifacts"| node_node_artifact
node_node_ui -->|"browses catalog"| node_node_benchstore
node_node_ui -->|"shows ops"| node_node_admin
node_node_tui -->|"shows ops"| node_node_admin
node_node_artifact -->|"guided by"| node_node_prompts
node_node_skills -->|"policy for"| node_node_runners
node_node_prompts -->|"drives copy"| node_node_ui
node_node_admin -->|"reports health"| node_node_diagnostics

click node_node_cli "https://github.com/researai/deepscientist/blob/main/src/deepscientist/cli.py"
click node_node_daemon "https://github.com/researai/deepscientist/tree/main/src/deepscientist/daemon"
click node_node_quest "https://github.com/researai/deepscientist/tree/main/src/deepscientist/quest"
click node_node_team_memory "https://github.com/researai/deepscientist/tree/main/src/deepscientist/team"
click node_node_gitops "https://github.com/researai/deepscientist/tree/main/src/deepscientist/gitops"
click node_node_runtime_storage "https://github.com/researai/deepscientist/blob/main/src/deepscientist/runtime_storage.py"
click node_node_bash_exec "https://github.com/researai/deepscientist/tree/main/src/deepscientist/bash_exec"
click node_node_runtime_tools "https://github.com/researai/deepscientist/tree/main/src/deepscientist/runtime_tools"
click node_node_runners "https://github.com/researai/deepscientist/tree/main/src/deepscientist/runners"
click node_node_prompts "https://github.com/researai/deepscientist/tree/main/src/deepscientist/prompts"
click node_node_skills "https://github.com/researai/deepscientist/tree/main/src/deepscientist/skills"
click node_node_benchstore "https://github.com/researai/deepscientist/tree/main/src/deepscientist/benchstore"
click node_node_artifact "https://github.com/researai/deepscientist/tree/main/src/deepscientist/artifact"
click node_node_ui "https://github.com/researai/deepscientist/tree/main/src/ui"
click node_node_tui "https://github.com/researai/deepscientist/tree/main/src/tui"
click node_node_channels "https://github.com/researai/deepscientist/tree/main/src/deepscientist/channels"
click node_node_bridges "https://github.com/researai/deepscientist/tree/main/src/deepscientist/bridges"
click node_node_connector_profiles "https://github.com/researai/deepscientist/tree/main/src/deepscientist/connector"
click node_node_mcp "https://github.com/researai/deepscientist/tree/main/src/deepscientist/mcp"
click node_node_admin "https://github.com/researai/deepscientist/tree/main/src/deepscientist/admin"
click node_node_diagnostics "https://github.com/researai/deepscientist/tree/main/src/deepscientist/diagnostics"

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_node_cli,node_node_daemon,node_node_quest,node_node_team_memory,node_node_gitops,node_node_runtime_storage,node_node_bash_exec,node_node_runtime_tools,node_node_runners,node_node_mcp toneBlue
class node_node_ui,node_node_tui toneAmber
class node_node_channels,node_node_bridges,node_node_connector_profiles toneMint
class node_node_prompts,node_node_skills,node_node_benchstore,node_node_artifact toneRose
class node_node_admin,node_node_diagnostics toneIndigo
```

## Components

### Backend core

Python package that owns daemon control plane, quest domain, execution, persistence, and services.

- [ds CLI](https://github.com/researai/deepscientist/blob/main/src/deepscientist/cli.py): entrypoint · Main command-line entry for launching and managing the system. · `src/deepscientist/cli.py`
- [Daemon](https://github.com/researai/deepscientist/tree/main/src/deepscientist/daemon): control plane · API, session, and event hub for quests and long-running operations. · `src/deepscientist/daemon`
- [Quest model](https://github.com/researai/deepscientist/tree/main/src/deepscientist/quest): workspace domain · Quest lifecycle, layout, and stage views for a durable research workspace. · `src/deepscientist/quest`
- [Team memory](https://github.com/researai/deepscientist/tree/main/src/deepscientist/team): state services · Shared state, frontmatter, and cross-run memory for accumulated findings. · `src/deepscientist/team`
- [Git ops](https://github.com/researai/deepscientist/tree/main/src/deepscientist/gitops): workspace git · Branch, diff, and graph helpers for Git-backed worktrees and progress tracking. · `src/deepscientist/gitops`
- [Runtime storage](https://github.com/researai/deepscientist/blob/main/src/deepscientist/runtime_storage.py): local persistence · Local caches, logs, and storage boundary for quest state and artifacts. · `src/deepscientist/runtime_storage.py`
- [Bash exec](https://github.com/researai/deepscientist/tree/main/src/deepscientist/bash_exec): shell runtime · Shell execution, monitoring, and runtime control for doing work locally. · `src/deepscientist/bash_exec`
- [Runtime tools](https://github.com/researai/deepscientist/tree/main/src/deepscientist/runtime_tools): tool service · Tool registry and service layer exposed to agents during execution. · `src/deepscientist/runtime_tools`
- [Runners](https://github.com/researai/deepscientist/tree/main/src/deepscientist/runners): agent adapters · Execution adapters for Codex, Claude Code, Kimi, and OpenCode. · `src/deepscientist/runners`
- [MCP](https://github.com/researai/deepscientist/tree/main/src/deepscientist/mcp): tool protocol · Context and server layer for model/tool protocol integration. · `src/deepscientist/mcp`

### User surfaces

Web and terminal clients that present quests and control the daemon.

- [Web UI](https://github.com/researai/deepscientist/tree/main/src/ui): react workspace · Browser workspace with project, lab, settings, file, diff, and chat surfaces. · `src/ui`
- [TUI](https://github.com/researai/deepscientist/tree/main/src/tui): terminal workspace · Terminal-native presentation layer over the same backend services. · `src/tui`

### Integrations

External connectors and coding-tool adapters.

- [Channels](https://github.com/researai/deepscientist/tree/main/src/deepscientist/channels): message adapters · Inbound/outbound adapters for QQ, Telegram, Slack, Discord, Weixin, and WhatsApp. · `src/deepscientist/channels`
- [Bridges](https://github.com/researai/deepscientist/tree/main/src/deepscientist/bridges): connector glue · Registry and bridge layer that normalizes external collaboration flows. · `src/deepscientist/bridges`
- [Connector profiles](https://github.com/researai/deepscientist/tree/main/src/deepscientist/connector): integration config · Profiles and support modules for platform-specific connector behavior. · `src/deepscientist/connector`

### Content layer

Prompts, skills, and benchmark/catalog material used by workflows.

- [Prompts](https://github.com/researai/deepscientist/tree/main/src/deepscientist/prompts): policy library · Prompt builder and system/contracts prompts consumed by clients and agents. · `src/deepscientist/prompts`
- [Skills](https://github.com/researai/deepscientist/tree/main/src/deepscientist/skills): workflow recipes · Stage-specific procedures and templates for research, writing, and review. · `src/deepscientist/skills`
- [BenchStore](https://github.com/researai/deepscientist/tree/main/src/deepscientist/benchstore): catalog service · Prompt/catalog assembly for benchmark-style research workflows. · `src/deepscientist/benchstore`
- [Artifacts](https://github.com/researai/deepscientist/tree/main/src/deepscientist/artifact): paper pipeline · Paper, PDF, annotation, guidance, and metrics artifact handling. · `src/deepscientist/artifact`

### Operations

Diagnostics, admin, and safety tooling.

- [Admin](https://github.com/researai/deepscientist/tree/main/src/deepscientist/admin): ops services · System charts, logs, repairs, and tool metrics. · `src/deepscientist/admin`
- [Diagnostics](https://github.com/researai/deepscientist/tree/main/src/deepscientist/diagnostics): health checks · Doctor and runner failure diagnostics for inspection and recovery. · `src/deepscientist/diagnostics`

## Connections

- ds CLI → Daemon: starts/manages · CLI controls daemon lifecycle and exposes operational commands.
- ds CLI → Quest model: launches quest · CLI initiates quest creation and continuation.
- Daemon → Quest model: orchestrates · Daemon owns quest state transitions and session coordination.
- Daemon → Web UI: serves API · Web UI talks to daemon APIs and realtime events.
- Daemon → TUI: serves API · TUI uses the same backend API and event stream.
- Quest model → Team memory: persists state · Quest data accumulates in shared memory and frontmatter services.
- Quest model → Git ops: maps to git · Quest work is organized as branches, diffs, and worktrees.
- Quest model → Runtime storage: stores locally · Quest runtime state and caches live on the local machine.
- Quest model → Runners: executes via · Quest actions are handed off to runner adapters.
- Runners → Bash exec: runs shell · Runners depend on shell execution and monitoring for local work.
- Runners → Runtime tools: uses tools · Runners consume runtime tools and service registry.
- Runners → MCP: protocol bridge · Runner/tool interactions can flow through MCP services.
- Runners → Connector profiles: integrates CLIs · Adapters target external coding-tool ecosystems and profiles.
- Channels → Bridges: normalizes events · Channel adapters are bridged into internal event flows.
- Bridges → Daemon: feeds events · External messages and attachments become daemon-visible events.
- Web UI → Artifacts: views artifacts · Browser UI renders papers, PDFs, annotations, and outputs.
- Web UI → BenchStore: browses catalog · Web UI exposes benchmark and prompt catalog workflows.
- Web UI → Admin: shows ops · Settings and control-center pages surface admin state.
- TUI → Admin: shows ops · Terminal UI includes operational and diagnostic views.
- Artifacts → Prompts: guided by · Artifact workflows use prompts and contracts for paper-facing tasks.
- Skills → Runners: policy for · Skills define stage procedures consumed by agents and runners.
- Prompts → Web UI: drives copy · UI surfaces use shared prompt text and interaction contracts.
- Admin → Diagnostics: reports health · Admin tools rely on diagnostics and repair signals.
