# langchain-samples/deep-life-sci architecture

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

- Interactive diagram: https://gitdiagram.com/langchain-samples/deep-life-sci
- Repository: https://github.com/langchain-samples/deep-life-sci

## Overview

Deep Life Sci is a research assistant for life-science users. A user asks a question in the chat UI or CLI; the server/runner builds the agent, which searches scientific sources and the web, can analyze uploaded data in a sandbox, and returns a response with generated artifacts. The graph preserves source-specific search, model/prompt and middleware layers, sandbox execution, and the browser interface. README capabilities inform coverage; unsampled frontend, web, and some source internals are represented only where their paths or documented roles are clear.

Main entry points: [`deep_life_sci/agent.py`](https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/agent.py) (Agent assembly), [`deep_life_sci/sources/pmc.py`](https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/sources/pmc.py) (PMC full text), [`deep_life_sci/graph.py`](https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/graph.py) (Graph server), [`deep_life_sci/sources/pubmed.py`](https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/sources/pubmed.py) (PubMed)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User interfaces"]
  node_chat["Research chat<br/>[index.tsx]"]
  node_cli["Command line<br/>[cli.py]"]
  node_server["Graph server<br/>[graph.py]"]
end

subgraph group_orchestration["Agent orchestration"]
  node_runner["Run coordinator<br/>[runner.py]"]
  node_agent["Agent assembly<br/>[agent.py]"]
  node_prompts["Research prompts<br/>[system.py]"]
  node_middleware["Run middleware"]
end

subgraph group_research["Research sources"]
  node_pubmed["PubMed<br/>[pubmed.py]"]
  node_pmc["PMC full text<br/>[pmc.py]"]
  node_ctgov["Trial registry<br/>[ctgov.py]"]
  node_trial_files["Trial files<br/>[trial_files.py]"]
  node_web["Web search<br/>[web.py]"]
  node_cache[("Source cache<br/>[cache_io.py]")]
end

subgraph group_execution["Analysis and files"]
  node_upload_probe["Upload analysis<br/>[upload_probe.py]"]
  node_upload_ingest["Upload handling<br/>[uploads.py]"]
  node_sandbox["Sandbox lifecycle<br/>[sandbox.py]"]
  node_artifacts["Artifact publishing<br/>[artifacts.py]"]
end

subgraph group_configuration["Identity and models"]
  node_paths["Data paths<br/>[paths.py]"]
  node_models["Model settings<br/>[models.py]"]
  node_auth["Sign-in ownership<br/>[auth.py]"]
end

node_researcher(("Researcher"))
node_langsmith["LangSmith sandbox"]
node_ncbi["NCBI services"]
node_web_service["Web search service"]
node_model_provider["Model provider"]

node_researcher -->|"asks via"| node_chat
node_researcher -->|"asks via"| node_cli
node_chat -.->|"connects to"| node_server
node_cli -.->|"runs"| node_runner
node_server -->|"builds"| node_agent
node_server -->|"acquires"| node_sandbox
node_runner -->|"builds"| node_agent
node_runner -->|"acquires"| node_sandbox
node_agent -->|"loads"| node_prompts
node_agent -->|"installs"| node_middleware
node_agent -->|"registers tools"| node_pubmed
node_agent -->|"registers tools"| node_pmc
node_agent -->|"registers tools"| node_ctgov
node_agent -->|"registers tools"| node_trial_files
node_agent -->|"registers tool"| node_web
node_agent -.->|"executes in"| node_sandbox
node_agent -.->|"configures roles"| node_models
node_upload_ingest -.->|"uses analysis"| node_upload_probe
node_upload_ingest -->|"uses paths"| node_paths
node_sandbox -->|"provisions"| node_langsmith
node_artifacts -->|"uses paths"| node_paths
node_pubmed -->|"reads and writes"| node_cache
node_pubmed -->|"requests records"| node_ncbi
node_pmc -->|"resolves identifiers"| node_pubmed
node_pmc -->|"reads and writes"| node_cache
node_pmc -->|"uses paths"| node_paths
node_ctgov -->|"reads and writes"| node_cache
node_ctgov -->|"uses paths"| node_paths
node_web -.->|"searches"| node_web_service
node_models -.->|"invokes models"| node_model_provider
node_auth -.->|"authenticates requests"| node_server

click node_chat "https://github.com/langchain-samples/deep-life-sci/blob/main/frontend/src/components/thread/index.tsx"
click node_cli "https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/cli.py"
click node_server "https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/graph.py"
click node_runner "https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/runner.py"
click node_agent "https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/agent.py"
click node_prompts "https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/prompts/system.py"
click node_middleware "https://github.com/langchain-samples/deep-life-sci/tree/main/deep_life_sci/middleware"
click node_upload_probe "https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/middleware/upload_probe.py"
click node_upload_ingest "https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/middleware/uploads.py"
click node_sandbox "https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/sandbox.py"
click node_artifacts "https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/middleware/artifacts.py"
click node_pubmed "https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/sources/pubmed.py"
click node_pmc "https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/sources/pmc.py"
click node_ctgov "https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/sources/ctgov.py"
click node_trial_files "https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/sources/trial_files.py"
click node_web "https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/sources/web.py"
click node_cache "https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/sources/cache_io.py"
click node_paths "https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/paths.py"
click node_models "https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/models.py"
click node_auth "https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/auth.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_chat,node_cli,node_server toneBlue
class node_runner,node_agent,node_prompts,node_middleware toneAmber
class node_pubmed,node_pmc,node_ctgov,node_trial_files,node_web,node_cache toneMint
class node_upload_probe,node_upload_ingest,node_sandbox,node_artifacts toneRose
class node_paths,node_models,node_auth,node_researcher,node_langsmith,node_ncbi,node_web_service,node_model_provider toneIndigo
```

## Components

### User interfaces

- [Research chat](https://github.com/langchain-samples/deep-life-sci/blob/main/frontend/src/components/thread/index.tsx): `frontend/src/components/thread/index.tsx`
- [Command line](https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/cli.py): `deep_life_sci/cli.py`
- [Graph server](https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/graph.py): `deep_life_sci/graph.py`

### Agent orchestration

- [Run coordinator](https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/runner.py): `deep_life_sci/runner.py`
- [Agent assembly](https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/agent.py): `deep_life_sci/agent.py`
- [Research prompts](https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/prompts/system.py): `deep_life_sci/prompts/system.py`
- [Run middleware](https://github.com/langchain-samples/deep-life-sci/tree/main/deep_life_sci/middleware): `deep_life_sci/middleware`

### Research sources

- [PubMed](https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/sources/pubmed.py): `deep_life_sci/sources/pubmed.py`
- [PMC full text](https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/sources/pmc.py): `deep_life_sci/sources/pmc.py`
- [Trial registry](https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/sources/ctgov.py): `deep_life_sci/sources/ctgov.py`
- [Trial files](https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/sources/trial_files.py): `deep_life_sci/sources/trial_files.py`
- [Web search](https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/sources/web.py): `deep_life_sci/sources/web.py`
- [Source cache](https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/sources/cache_io.py): `deep_life_sci/sources/cache_io.py`

### Analysis and files

- [Upload analysis](https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/middleware/upload_probe.py): `deep_life_sci/middleware/upload_probe.py`
- [Upload handling](https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/middleware/uploads.py): `deep_life_sci/middleware/uploads.py`
- [Sandbox lifecycle](https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/sandbox.py): `deep_life_sci/sandbox.py`
- [Artifact publishing](https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/middleware/artifacts.py): `deep_life_sci/middleware/artifacts.py`

### Identity and models

- [Data paths](https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/paths.py): `deep_life_sci/paths.py`
- [Model settings](https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/models.py): `deep_life_sci/models.py`
- [Sign-in ownership](https://github.com/langchain-samples/deep-life-sci/blob/main/deep_life_sci/auth.py): `deep_life_sci/auth.py`

### Other components

- **Researcher**
- **LangSmith sandbox**
- **NCBI services**
- **Web search service**
- **Model provider**

## Connections

- Researcher → Research chat: asks via (evidence: `README.md`)
- Researcher → Command line: asks via (evidence: `README.md`)
- Research chat → Graph server: connects to
- Command line → Run coordinator: runs
- Graph server → Agent assembly: builds (evidence: `deep_life_sci/graph.py`)
- Graph server → Sandbox lifecycle: acquires (evidence: `deep_life_sci/graph.py`)
- Run coordinator → Agent assembly: builds (evidence: `deep_life_sci/runner.py`)
- Run coordinator → Sandbox lifecycle: acquires (evidence: `deep_life_sci/runner.py`)
- Agent assembly → Research prompts: loads (evidence: `deep_life_sci/agent.py`)
- Agent assembly → Run middleware: installs (evidence: `deep_life_sci/agent.py`)
- Agent assembly → PubMed: registers tools (evidence: `deep_life_sci/agent.py`)
- Agent assembly → PMC full text: registers tools (evidence: `deep_life_sci/agent.py`)
- Agent assembly → Trial registry: registers tools (evidence: `deep_life_sci/agent.py`)
- Agent assembly → Trial files: registers tools (evidence: `deep_life_sci/agent.py`)
- Agent assembly → Web search: registers tool (evidence: `deep_life_sci/agent.py`)
- Agent assembly → Sandbox lifecycle: executes in
- Agent assembly → Model settings: configures roles (evidence: `deep_life_sci/agent.py`)
- Upload handling → Upload analysis: uses analysis
- Upload handling → Data paths: uses paths (evidence: `deep_life_sci/middleware/uploads.py`)
- Sandbox lifecycle → LangSmith sandbox: provisions (evidence: `deep_life_sci/sandbox.py`)
- Artifact publishing → Data paths: uses paths (evidence: `deep_life_sci/middleware/artifacts.py`)
- PubMed → Source cache: reads and writes (evidence: `deep_life_sci/sources/pubmed.py`)
- PubMed → NCBI services: requests records (evidence: `deep_life_sci/sources/pubmed.py`)
- PMC full text → PubMed: resolves identifiers (evidence: `deep_life_sci/sources/pmc.py`)
- PMC full text → Source cache: reads and writes (evidence: `deep_life_sci/sources/pmc.py`)
- PMC full text → Data paths: uses paths (evidence: `deep_life_sci/sources/pmc.py`)
- Trial registry → Source cache: reads and writes (evidence: `deep_life_sci/sources/ctgov.py`)
- Trial registry → Data paths: uses paths (evidence: `deep_life_sci/sources/ctgov.py`)
- Web search → Web search service: searches
- Model settings → Model provider: invokes models
- Sign-in ownership → Graph server: authenticates requests
