# salahabdelkhabir/autonomous-research-assistant- architecture

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

- Interactive diagram: https://gitdiagram.com/salahabdelkhabir/autonomous-research-assistant-
- Repository: https://github.com/salahabdelkhabir/autonomous-research-assistant-

## Overview

The product is a streamed, multi-agent research assistant: a user submits a topic through the SPA, the API runs a checkpointed LangGraph workflow, and the UI receives progress and a reviewed, cited report with factorized confidence. The graph preserves the separate search, retrieval, evidence-check, writing, and review stages, plus the provider and retrieval strategy layers. Workflow and module links follow the README and SOURCE INDEX; unsampled implementation details are not inferred.

Main entry points: [`graph/workflow.py`](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/graph/workflow.py) (LangGraph workflow), [`llm/factory.py`](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/llm/factory.py) (LLM selector), [`app/api.py`](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/app/api.py) (FastAPI), [`retrieval/factory.py`](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/retrieval/factory.py) (Retriever selector)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Request interface"]
  node_frontend["Research SPA<br/>[app.js]"]
  node_api["FastAPI<br/>[api.py]"]
  node_serializer["Response serializer<br/>[serialize.py]"]
end

subgraph group_orchestration["Research workflow"]
  node_workflow["LangGraph workflow<br/>[workflow.py]"]
  node_evidence_check["Evidence check<br/>[checks.py]"]
  node_instrument["Node instrumentation<br/>[instrument.py]"]
end

subgraph group_evidence["Sources and retrieval"]
  node_search["Source search<br/>[search.py]"]
  node_arxiv["arXiv source<br/>[arxiv_source.py]"]
  node_retrieve["Evidence retrieval<br/>[retrieve.py]"]
  node_retriever_factory["Retriever selector<br/>[factory.py]"]
  node_dense["Dense retrieval<br/>[dense.py]"]
  node_sparse["Sparse retrieval<br/>[sparse.py]"]
  node_hybrid["Hybrid retrieval<br/>[hybrid.py]"]
end

subgraph group_generation["Agents and models"]
  node_writer_node["Writer graph node<br/>[writer.py]"]
  node_writer_agent["Writer agent<br/>[writer.py]"]
  node_reviewer_node["Reviewer graph node<br/>[reviewer.py]"]
  node_reviewer_agent["Reviewer agent<br/>[reviewer.py]"]
  node_llm_factory["LLM selector<br/>[factory.py]"]
  node_llm_base["LLM interface<br/>[base.py]"]
  node_gemini["Gemini provider<br/>[gemini.py]"]
  node_ollama["Ollama provider<br/>[ollama.py]"]
  node_openrouter["OpenRouter provider<br/>[openrouter.py]"]
end

subgraph group_shared["State and reporting"]
  node_state["Workflow state<br/>[state.py]"]
  node_schemas["Report schemas<br/>[schemas.py]"]
  node_confidence["Confidence scoring<br/>[confidence.py]"]
end

node_user(("Researcher"))

node_user -->|"submits topic"| node_frontend
node_frontend -->|"posts query"| node_api
node_api -->|"streams research"| node_workflow
node_workflow -->|"dispatches"| node_search
node_search -->|"searches papers"| node_arxiv
node_workflow -->|"dispatches"| node_retrieve
node_retrieve -->|"selects retriever"| node_retriever_factory
node_retriever_factory -->|"selects strategy"| node_dense
node_retriever_factory -->|"selects strategy"| node_sparse
node_retriever_factory -->|"selects strategy"| node_hybrid
node_hybrid -->|"fuses results"| node_dense
node_hybrid -->|"fuses results"| node_sparse
node_workflow -->|"checks evidence"| node_evidence_check
node_evidence_check -->|"retries if insufficient"| node_search
node_evidence_check -->|"continues if sufficient"| node_writer_node
node_workflow -->|"dispatches"| node_writer_node
node_writer_node -->|"invokes"| node_writer_agent
node_writer_agent -->|"gets provider"| node_llm_factory
node_workflow -->|"dispatches"| node_reviewer_node
node_reviewer_node -->|"invokes"| node_reviewer_agent
node_reviewer_agent -->|"gets provider"| node_llm_factory
node_llm_factory -->|"returns provider"| node_llm_base
node_llm_factory -->|"selects provider"| node_gemini
node_llm_factory -->|"selects provider"| node_ollama
node_llm_factory -->|"selects provider"| node_openrouter
node_workflow -->|"wraps graph nodes"| node_instrument
node_instrument -->|"records metrics"| node_state
node_workflow -->|"initializes state"| node_state
node_state -->|"holds report data"| node_schemas
node_workflow -->|"computes final score"| node_confidence
node_confidence -->|"scores final state"| node_state
node_api -->|"serializes response"| node_serializer
node_api -->|"streams progress and result"| node_frontend

click node_frontend "https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/frontend/app.js"
click node_api "https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/app/api.py"
click node_serializer "https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/app/serialize.py"
click node_workflow "https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/graph/workflow.py"
click node_search "https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/graph/nodes/search.py"
click node_arxiv "https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/sources/arxiv_source.py"
click node_retrieve "https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/graph/nodes/retrieve.py"
click node_retriever_factory "https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/retrieval/factory.py"
click node_dense "https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/retrieval/dense.py"
click node_sparse "https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/retrieval/sparse.py"
click node_hybrid "https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/retrieval/hybrid.py"
click node_evidence_check "https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/graph/nodes/checks.py"
click node_writer_node "https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/graph/nodes/writer.py"
click node_writer_agent "https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/agents/writer.py"
click node_reviewer_node "https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/graph/nodes/reviewer.py"
click node_reviewer_agent "https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/agents/reviewer.py"
click node_llm_factory "https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/llm/factory.py"
click node_llm_base "https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/llm/base.py"
click node_gemini "https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/llm/gemini.py"
click node_ollama "https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/llm/ollama.py"
click node_openrouter "https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/llm/openrouter.py"
click node_instrument "https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/graph/nodes/instrument.py"
click node_state "https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/graph/state.py"
click node_schemas "https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/graph/schemas.py"
click node_confidence "https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/graph/confidence.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_frontend,node_api,node_serializer toneBlue
class node_workflow,node_evidence_check,node_instrument toneAmber
class node_search,node_arxiv,node_retrieve,node_retriever_factory,node_dense,node_sparse,node_hybrid toneMint
class node_writer_node,node_writer_agent,node_reviewer_node,node_reviewer_agent,node_llm_factory,node_llm_base,node_gemini,node_ollama,node_openrouter toneRose
class node_state,node_schemas,node_confidence,node_user toneIndigo
```

## Components

### Request interface

- [Research SPA](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/frontend/app.js): `frontend/app.js`
- [FastAPI](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/app/api.py): `app/api.py`
- [Response serializer](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/app/serialize.py): `app/serialize.py`

### Research workflow

- [LangGraph workflow](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/graph/workflow.py): `graph/workflow.py`
- [Evidence check](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/graph/nodes/checks.py): `graph/nodes/checks.py`
- [Node instrumentation](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/graph/nodes/instrument.py): `graph/nodes/instrument.py`

### Sources and retrieval

- [Source search](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/graph/nodes/search.py): `graph/nodes/search.py`
- [arXiv source](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/sources/arxiv_source.py): `sources/arxiv_source.py`
- [Evidence retrieval](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/graph/nodes/retrieve.py): `graph/nodes/retrieve.py`
- [Retriever selector](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/retrieval/factory.py): `retrieval/factory.py`
- [Dense retrieval](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/retrieval/dense.py): `retrieval/dense.py`
- [Sparse retrieval](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/retrieval/sparse.py): `retrieval/sparse.py`
- [Hybrid retrieval](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/retrieval/hybrid.py): `retrieval/hybrid.py`

### Agents and models

- [Writer graph node](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/graph/nodes/writer.py): `graph/nodes/writer.py`
- [Writer agent](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/agents/writer.py): `agents/writer.py`
- [Reviewer graph node](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/graph/nodes/reviewer.py): `graph/nodes/reviewer.py`
- [Reviewer agent](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/agents/reviewer.py): `agents/reviewer.py`
- [LLM selector](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/llm/factory.py): `llm/factory.py`
- [LLM interface](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/llm/base.py): `llm/base.py`
- [Gemini provider](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/llm/gemini.py): `llm/gemini.py`
- [Ollama provider](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/llm/ollama.py): `llm/ollama.py`
- [OpenRouter provider](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/llm/openrouter.py): `llm/openrouter.py`

### State and reporting

- [Workflow state](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/graph/state.py): `graph/state.py`
- [Report schemas](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/graph/schemas.py): `graph/schemas.py`
- [Confidence scoring](https://github.com/salahabdelkhabir/autonomous-research-assistant-/blob/main/graph/confidence.py): `graph/confidence.py`

### Other components

- **Researcher**

## Connections

- Researcher → Research SPA: submits topic (evidence: `README.md`)
- Research SPA → FastAPI: posts query (evidence: `README.md`)
- FastAPI → LangGraph workflow: streams research (evidence: `app/api.py`)
- LangGraph workflow → Source search: dispatches (evidence: `graph/workflow.py`)
- Source search → arXiv source: searches papers (evidence: `graph/nodes/search.py`)
- LangGraph workflow → Evidence retrieval: dispatches (evidence: `graph/workflow.py`)
- Evidence retrieval → Retriever selector: selects retriever (evidence: `graph/nodes/retrieve.py`)
- Retriever selector → Dense retrieval: selects strategy (evidence: `retrieval/factory.py`)
- Retriever selector → Sparse retrieval: selects strategy (evidence: `retrieval/factory.py`)
- Retriever selector → Hybrid retrieval: selects strategy (evidence: `retrieval/factory.py`)
- Hybrid retrieval → Dense retrieval: fuses results (evidence: `retrieval/hybrid.py`)
- Hybrid retrieval → Sparse retrieval: fuses results (evidence: `retrieval/hybrid.py`)
- LangGraph workflow → Evidence check: checks evidence (evidence: `graph/workflow.py`)
- Evidence check → Source search: retries if insufficient (evidence: `graph/workflow.py`)
- Evidence check → Writer graph node: continues if sufficient (evidence: `graph/workflow.py`)
- LangGraph workflow → Writer graph node: dispatches (evidence: `graph/workflow.py`)
- Writer graph node → Writer agent: invokes (evidence: `graph/nodes/writer.py`)
- Writer agent → LLM selector: gets provider (evidence: `agents/writer.py`)
- LangGraph workflow → Reviewer graph node: dispatches (evidence: `graph/workflow.py`)
- Reviewer graph node → Reviewer agent: invokes (evidence: `graph/nodes/reviewer.py`)
- Reviewer agent → LLM selector: gets provider (evidence: `agents/reviewer.py`)
- LLM selector → LLM interface: returns provider (evidence: `llm/factory.py`)
- LLM selector → Gemini provider: selects provider (evidence: `llm/factory.py`)
- LLM selector → Ollama provider: selects provider (evidence: `llm/factory.py`)
- LLM selector → OpenRouter provider: selects provider (evidence: `llm/factory.py`)
- LangGraph workflow → Node instrumentation: wraps graph nodes (evidence: `graph/nodes/instrument.py`)
- Node instrumentation → Workflow state: records metrics (evidence: `graph/nodes/instrument.py`)
- LangGraph workflow → Workflow state: initializes state (evidence: `graph/workflow.py`)
- Workflow state → Report schemas: holds report data (evidence: `graph/state.py`)
- LangGraph workflow → Confidence scoring: computes final score (evidence: `graph/workflow.py`)
- Confidence scoring → Workflow state: scores final state (evidence: `graph/confidence.py`)
- FastAPI → Response serializer: serializes response (evidence: `app/api.py`)
- FastAPI → Research SPA: streams progress and result (evidence: `README.md`)
