# mahadyrayhan/otr architecture

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

- Interactive diagram: https://gitdiagram.com/mahadyrayhan/otr
- Repository: https://github.com/mahadyrayhan/otr

## Overview

This is a multi-agent research assistant: a user submits a question, the orchestrator decomposes it into dependent tasks, routes work to specialist agents, and returns a synthesized answer. A separate RAG service exposes search and topic-discovery capabilities, backed by biomedical literature retrieval and configurable LLM providers. The graph preserves the documented specialist roles and RAG reasoning modes. Some agent dispatch and RAG internals are unsampled, so uncertain connections are omitted or marked dashed.

Main entry points: [`orchestrator/engine.py`](https://github.com/mahadyrayhan/otr/blob/main/orchestrator/engine.py) (Orchestrator engine), [`rag_agent/main.py`](https://github.com/mahadyrayhan/otr/blob/main/rag_agent/main.py) (RAG API), [`rag_agent/llm_provider.py`](https://github.com/mahadyrayhan/otr/blob/main/rag_agent/llm_provider.py) (LLM providers), [`rag_agent/knowledge_base.py`](https://github.com/mahadyrayhan/otr/blob/main/rag_agent/knowledge_base.py) (Literature retrieval)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orchestration["Task orchestration"]
  node_engine["Orchestrator engine<br/>[engine.py]"]
  node_decomposer["Task decomposers<br/>[decomposers.py]"]
  node_dag["DAG construction<br/>[dag_builders.py]"]
  node_config["System configuration<br/>[config.py]"]
end

subgraph group_specialists["Specialist agents"]
  node_rag_agent["Knowledge agent<br/>[agent.py]"]
  node_scholar["Scholar agent<br/>[agent.py]"]
  node_code["Code agent<br/>[agent.py]"]
  node_cloud["Cloud agent<br/>[agent.py]"]
  node_profiler["User profiler<br/>[agent.py]"]
end

subgraph group_rag["RAG service"]
  node_rag_api["RAG API<br/>[main.py]"]
  node_knowledge["Literature retrieval<br/>[knowledge_base.py]"]
  node_reasoning["Reasoning strategies<br/>[react_agent.py]"]
  node_responder["Answer enrichment<br/>[rag_responder.py]"]
  node_provider["LLM providers<br/>[llm_provider.py]"]
  node_provider_config["RAG settings<br/>[rag_config.py]"]
end

subgraph group_observability["Communication tracking"]
  node_comm_log["Communication tracker"]
  node_comm_eval["Communication evaluator"]
end

node_user(("Researcher"))
node_cli["Interactive CLI<br/>[main.py]"]
node_literature_services["PubMed and Semantic Scholar"]
node_llm_services["External LLM services"]

node_user -->|"asks"| node_cli
node_cli -->|"submits query"| node_engine
node_engine -->|"decomposes"| node_decomposer
node_engine -->|"builds task graph"| node_dag
node_engine -->|"reads settings"| node_config
node_engine -->|"dispatches query"| node_rag_agent
node_engine -.->|"dispatches task"| node_scholar
node_engine -.->|"dispatches task"| node_code
node_engine -.->|"dispatches task"| node_cloud
node_engine -->|"updates profile"| node_profiler
node_engine -.->|"records exchanges"| node_comm_log
node_comm_eval -.->|"scores exchanges"| node_comm_log
node_rag_api -->|"queries topics"| node_knowledge
node_rag_api -->|"benchmarks providers"| node_provider
node_rag_api -.->|"uses for search"| node_reasoning
node_rag_api -.->|"enriches results"| node_responder
node_reasoning -.->|"retrieves evidence"| node_knowledge
node_responder -->|"requests completions"| node_provider
node_knowledge -->|"fetches papers"| node_literature_services
node_provider -->|"sends completions"| node_llm_services
node_provider_config -->|"configures providers"| node_provider

click node_cli "https://github.com/mahadyrayhan/otr/blob/main/main.py"
click node_engine "https://github.com/mahadyrayhan/otr/blob/main/orchestrator/engine.py"
click node_decomposer "https://github.com/mahadyrayhan/otr/blob/main/orchestrator/decomposers.py"
click node_dag "https://github.com/mahadyrayhan/otr/blob/main/orchestrator/dag_builders.py"
click node_config "https://github.com/mahadyrayhan/otr/blob/main/config.py"
click node_rag_agent "https://github.com/mahadyrayhan/otr/blob/main/rag_agent/agent.py"
click node_scholar "https://github.com/mahadyrayhan/otr/blob/main/scholar_agent/agent.py"
click node_code "https://github.com/mahadyrayhan/otr/blob/main/code_agent/agent.py"
click node_cloud "https://github.com/mahadyrayhan/otr/blob/main/cloud_agent/agent.py"
click node_profiler "https://github.com/mahadyrayhan/otr/blob/main/profiler_agent/agent.py"
click node_rag_api "https://github.com/mahadyrayhan/otr/blob/main/rag_agent/main.py"
click node_knowledge "https://github.com/mahadyrayhan/otr/blob/main/rag_agent/knowledge_base.py"
click node_reasoning "https://github.com/mahadyrayhan/otr/blob/main/rag_agent/react_agent.py"
click node_responder "https://github.com/mahadyrayhan/otr/blob/main/rag_agent/rag_responder.py"
click node_provider "https://github.com/mahadyrayhan/otr/blob/main/rag_agent/llm_provider.py"
click node_provider_config "https://github.com/mahadyrayhan/otr/blob/main/rag_agent/rag_config.py"
click node_comm_log "https://github.com/mahadyrayhan/otr/blob/main/orchestrator/evaluation/communication_log.py"
click node_comm_eval "https://github.com/mahadyrayhan/otr/blob/main/orchestrator/evaluation/communication_evaluator.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_engine,node_decomposer,node_dag,node_config toneBlue
class node_rag_agent,node_scholar,node_code,node_cloud,node_profiler toneAmber
class node_rag_api,node_knowledge,node_reasoning,node_responder,node_provider,node_provider_config toneMint
class node_comm_log,node_comm_eval toneRose
class node_user,node_literature_services,node_llm_services toneIndigo
class node_cli toneTeal
```

## Components

### Task orchestration

- [Orchestrator engine](https://github.com/mahadyrayhan/otr/blob/main/orchestrator/engine.py): `orchestrator/engine.py`
- [Task decomposers](https://github.com/mahadyrayhan/otr/blob/main/orchestrator/decomposers.py): `orchestrator/decomposers.py`
- [DAG construction](https://github.com/mahadyrayhan/otr/blob/main/orchestrator/dag_builders.py): `orchestrator/dag_builders.py`
- [System configuration](https://github.com/mahadyrayhan/otr/blob/main/config.py): `config.py`

### Specialist agents

- [Knowledge agent](https://github.com/mahadyrayhan/otr/blob/main/rag_agent/agent.py): `rag_agent/agent.py`
- [Scholar agent](https://github.com/mahadyrayhan/otr/blob/main/scholar_agent/agent.py): `scholar_agent/agent.py`
- [Code agent](https://github.com/mahadyrayhan/otr/blob/main/code_agent/agent.py): `code_agent/agent.py`
- [Cloud agent](https://github.com/mahadyrayhan/otr/blob/main/cloud_agent/agent.py): `cloud_agent/agent.py`
- [User profiler](https://github.com/mahadyrayhan/otr/blob/main/profiler_agent/agent.py): `profiler_agent/agent.py`

### RAG service

- [RAG API](https://github.com/mahadyrayhan/otr/blob/main/rag_agent/main.py): `rag_agent/main.py`
- [Literature retrieval](https://github.com/mahadyrayhan/otr/blob/main/rag_agent/knowledge_base.py): `rag_agent/knowledge_base.py`
- [Reasoning strategies](https://github.com/mahadyrayhan/otr/blob/main/rag_agent/react_agent.py): `rag_agent/react_agent.py`
- [Answer enrichment](https://github.com/mahadyrayhan/otr/blob/main/rag_agent/rag_responder.py): `rag_agent/rag_responder.py`
- [LLM providers](https://github.com/mahadyrayhan/otr/blob/main/rag_agent/llm_provider.py): `rag_agent/llm_provider.py`
- [RAG settings](https://github.com/mahadyrayhan/otr/blob/main/rag_agent/rag_config.py): `rag_agent/rag_config.py`

### Communication tracking

- [Communication tracker](https://github.com/mahadyrayhan/otr/blob/main/orchestrator/evaluation/communication_log.py): `orchestrator/evaluation/communication_log.py`
- [Communication evaluator](https://github.com/mahadyrayhan/otr/blob/main/orchestrator/evaluation/communication_evaluator.py): `orchestrator/evaluation/communication_evaluator.py`

### Other components

- **Researcher**
- [Interactive CLI](https://github.com/mahadyrayhan/otr/blob/main/main.py): `main.py`
- **PubMed and Semantic Scholar**
- **External LLM services**

## Connections

- Researcher → Interactive CLI: asks (evidence: `main.py`)
- Interactive CLI → Orchestrator engine: submits query (evidence: `main.py`)
- Orchestrator engine → Task decomposers: decomposes (evidence: `orchestrator/engine.py`)
- Orchestrator engine → DAG construction: builds task graph (evidence: `orchestrator/engine.py`)
- Orchestrator engine → System configuration: reads settings (evidence: `orchestrator/engine.py`)
- Orchestrator engine → Knowledge agent: dispatches query (evidence: `orchestrator/engine.py`)
- Orchestrator engine → Scholar agent: dispatches task (evidence: `orchestrator/engine.py`)
- Orchestrator engine → Code agent: dispatches task (evidence: `orchestrator/engine.py`)
- Orchestrator engine → Cloud agent: dispatches task (evidence: `orchestrator/engine.py`)
- Orchestrator engine → User profiler: updates profile (evidence: `orchestrator/engine.py`)
- Orchestrator engine → Communication tracker: records exchanges (evidence: `orchestrator/engine.py`)
- Communication evaluator → Communication tracker: scores exchanges
- RAG API → Literature retrieval: queries topics (evidence: `rag_agent/main.py`)
- RAG API → LLM providers: benchmarks providers (evidence: `rag_agent/main.py`)
- RAG API → Reasoning strategies: uses for search (evidence: `rag_agent/main.py`)
- RAG API → Answer enrichment: enriches results (evidence: `rag_agent/main.py`)
- Reasoning strategies → Literature retrieval: retrieves evidence (evidence: `rag_agent/react_agent.py`)
- Answer enrichment → LLM providers: requests completions (evidence: `rag_agent/rag_responder.py`)
- Literature retrieval → PubMed and Semantic Scholar: fetches papers (evidence: `rag_agent/knowledge_base.py`)
- LLM providers → External LLM services: sends completions (evidence: `rag_agent/llm_provider.py`)
- RAG settings → LLM providers: configures providers (evidence: `rag_agent/rag_config.py`)
