# langchain-ai/ollama-deep-researcher architecture

> Architecture diagram of the GitHub repository langchain-ai/ollama-deep-researcher, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/langchain-ai/ollama-deep-researcher
- Repository: https://github.com/langchain-ai/ollama-deep-researcher

## Overview

##### Main Components

a) Client Layer:
- LangGraph Studio UI (Web Interface)
- Configuration Interface

b) Application Layer:
- LangGraph Server (Core Runtime)
- Research Orchestration Engine

c) Service Components:
- Local LLM Service (Ollama)
- Web Search Services (Tavily/Perplexity)

d) Core Processing Components:
- Query Generator
- Web Search Handler
- Summary Generator
- Knowledge Gap Analyzer
- Research Iterator

##### Key Relationships to Highlight

- Initial query flow
- Research iteration cycle
- Data accumulation process
- Final output generation

##### Specific Implementation Details

**[User/Browser] → [LangGraph Studio UI]**
- ↓
**[Configuration Manager] → [LangGraph Server]**
- ↓
- [Research Cycle]
- ↙     ↓      ↘
- [Query Generator] [Search] [Summary Generator]
- ↓            ↓           ↓
- [Ollama LLM] [Search APIs] [Knowledge Gap Analyzer]
- ↓
- [State Manager]
- ↓
- [Output Generator]

##### Important Elements to Emphasize

a) State Management:
- How the src/assistant/state.py manages research progress
- Where sources and summaries are stored

b) Configuration Flow:
- How src/assistant/configuration.py handles setup
- Integration with external services

c) Graph Processing:
- How src/assistant/graph.py orchestrates the research cycle
- Iterative nature of the process

##### Technical Details

- API endpoints (http://127.0.0.1:2024)
- Environment variable configurations
- Integration points with Ollama
- Search API connections

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        UI[LangGraph Studio UI]:::ui
        Config[Configuration Interface]:::ui
    end

    subgraph Core
        LGS[LangGraph Server]:::core
        ROE[Research Orchestration Engine]:::core
        SMS[State Management System]:::core
        PMS[Prompt Management System]:::core
        Utils[Utility Services]:::core
    end

    subgraph Services
        OLLM[Local LLM Service]:::service
        WS[Web Search Services]:::service
    end

    subgraph Research_Process
        QG[Query Generator]:::process
        WSH[Web Search Handler]:::process
        SG[Summary Generator]:::process
        KGA[Knowledge Gap Analyzer]:::process
        RI[Research Iterator]:::process
        OG[Output Generator]:::process
    end

    UI --> Config
    Config --> LGS
    LGS --> ROE
    ROE --> QG
    QG --> OLLM
    OLLM --> WSH
    WSH --> WS
    WS --> SG
    SG --> KGA
    KGA --> RI
    RI --> QG
    KGA --> OG

    SMS --> ROE
    SMS --> QG
    SMS --> SG
    SMS --> KGA

    PMS --> QG
    PMS --> SG
    PMS --> KGA

    Utils --> ROE
    Utils --> WSH
    Utils --> OG

    %% Click events for component mapping
    click ROE "https://github.com/langchain-ai/ollama-deep-researcher/blob/main/src/assistant/graph.py"
    click SMS "https://github.com/langchain-ai/ollama-deep-researcher/blob/main/src/assistant/state.py"
    click Config "https://github.com/langchain-ai/ollama-deep-researcher/blob/main/src/assistant/configuration.py"
    click PMS "https://github.com/langchain-ai/ollama-deep-researcher/blob/main/src/assistant/prompts.py"
    click Utils "https://github.com/langchain-ai/ollama-deep-researcher/blob/main/src/assistant/utils.py"
    click LGS "https://github.com/langchain-ai/ollama-deep-researcher/blob/main/langgraph.json"

    %% Styling
    classDef ui fill:#2196F3,stroke:#1565C0,color:white
    classDef core fill:#4CAF50,stroke:#2E7D32,color:white
    classDef service fill:#FFC107,stroke:#FFA000,color:black
    classDef process fill:#9C27B0,stroke:#7B1FA2,color:white

    %% Legend
    subgraph Legend
        L1[User Interface]:::ui
        L2[Core Components]:::core
        L3[External Services]:::service
        L4[Process Steps]:::process
    end
```
