# builtbyprashant/genai-doc-assistant architecture

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

- Interactive diagram: https://gitdiagram.com/builtbyprashant/genai-doc-assistant
- Repository: https://github.com/builtbyprashant/genai-doc-assistant

## Overview

This is an agentic document Q&A product: users upload files, the backend parses and indexes them, then returns grounded answers with citations and pipeline traces. The principal query path supports a deterministic custom pipeline, a ReAct-style search loop, and side-by-side comparison. The README documents the major capabilities; several implementation details were not sampled, so uncertain internal links are omitted or marked unverified.

Main entry points: [`app/agents/pipeline.py`](https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/agents/pipeline.py) (Pipeline orchestrator), [`app/agents/llm.py`](https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/agents/llm.py) (LLM client), [`app/api/main.py`](https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/api/main.py) (FastAPI API), [`app/agents/llama_agent.py`](https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/agents/llama_agent.py) (ReAct agent)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_ui["Streamlit UI<br/>[app.py]"]
  node_api["FastAPI API<br/>[main.py]"]
end

subgraph group_ingestion["Document ingestion"]
  node_loader["Document loader<br/>[document_loader.py]"]
  node_chunker["Chunk service<br/>[chunk_service.py]"]
end

subgraph group_query["Query orchestration"]
  node_pipeline["Pipeline orchestrator<br/>[pipeline.py]"]
  node_threshold["Similarity threshold<br/>[pipeline.py]"]
  node_compare["Compare results<br/>[pipeline.py]"]
end

subgraph group_agents["Agents and models"]
  node_safety["Safety guard<br/>[safety.py]"]
  node_planner["Planner agent<br/>[planner.py]"]
  node_reasoner["Reasoner agent<br/>[reasoner.py]"]
  node_validator["Validator agent<br/>[validator.py]"]
  node_react["ReAct agent<br/>[llama_agent.py]"]
  node_llm["LLM client<br/>[llm.py]"]
end

subgraph group_retrieval["Retrieval and state"]
  node_vector[("Vector store<br/>[vector_store.py]")]
  node_ranker["Cross-encoder reranker<br/>[ranker.py]"]
end

node_browser(("Browser user"))
node_anthropic["Anthropic API"]

node_browser -->|"asks and uploads"| node_ui
node_ui -->|"sends HTTP"| node_api
node_api -->|"parses uploads"| node_loader
node_api -->|"indexes and manages"| node_vector
node_api -->|"runs queries"| node_pipeline
node_pipeline -->|"checks input"| node_safety
node_pipeline -->|"plans query"| node_planner
node_pipeline -->|"retrieves chunks"| node_vector
node_pipeline -->|"checks similarity"| node_threshold
node_pipeline -->|"reranks chunks"| node_ranker
node_pipeline -->|"generates answer"| node_reasoner
node_pipeline -->|"validates answer"| node_validator
node_pipeline -->|"runs alternate mode"| node_react
node_pipeline -->|"combines modes"| node_compare
node_planner -->|"requests completion"| node_llm
node_reasoner -->|"requests completion"| node_llm
node_validator -->|"requests completion"| node_llm
node_react -->|"searches iteratively"| node_vector
node_react -->|"reasons each turn"| node_llm
node_llm -->|"calls model"| node_anthropic
node_loader -.->|"chunks parsed text"| node_chunker

click node_ui "https://github.com/builtbyprashant/genai-doc-assistant/blob/main/frontend/app.py"
click node_api "https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/api/main.py"
click node_loader "https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/services/document_loader.py"
click node_chunker "https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/services/chunk_service.py"
click node_vector "https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/services/vector_store.py"
click node_pipeline "https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/agents/pipeline.py"
click node_safety "https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/agents/safety.py"
click node_planner "https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/agents/planner.py"
click node_threshold "https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/agents/pipeline.py"
click node_ranker "https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/agents/ranker.py"
click node_reasoner "https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/agents/reasoner.py"
click node_validator "https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/agents/validator.py"
click node_react "https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/agents/llama_agent.py"
click node_compare "https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/agents/pipeline.py"
click node_llm "https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/agents/llm.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_ui,node_api,node_browser toneBlue
class node_loader,node_chunker toneAmber
class node_pipeline,node_threshold,node_compare,node_anthropic toneMint
class node_safety,node_planner,node_reasoner,node_validator,node_react,node_llm toneRose
class node_vector,node_ranker toneIndigo
```

## Components

### User experience

- [Streamlit UI](https://github.com/builtbyprashant/genai-doc-assistant/blob/main/frontend/app.py): `frontend/app.py`
- [FastAPI API](https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/api/main.py): `app/api/main.py`

### Document ingestion

- [Document loader](https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/services/document_loader.py): `app/services/document_loader.py`
- [Chunk service](https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/services/chunk_service.py): `app/services/chunk_service.py`

### Query orchestration

- [Pipeline orchestrator](https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/agents/pipeline.py): `app/agents/pipeline.py`
- [Similarity threshold](https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/agents/pipeline.py): `app/agents/pipeline.py`
- [Compare results](https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/agents/pipeline.py): `app/agents/pipeline.py`

### Agents and models

- [Safety guard](https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/agents/safety.py): `app/agents/safety.py`
- [Planner agent](https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/agents/planner.py): `app/agents/planner.py`
- [Reasoner agent](https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/agents/reasoner.py): `app/agents/reasoner.py`
- [Validator agent](https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/agents/validator.py): `app/agents/validator.py`
- [ReAct agent](https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/agents/llama_agent.py): `app/agents/llama_agent.py`
- [LLM client](https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/agents/llm.py): `app/agents/llm.py`

### Retrieval and state

- [Vector store](https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/services/vector_store.py): `app/services/vector_store.py`
- [Cross-encoder reranker](https://github.com/builtbyprashant/genai-doc-assistant/blob/main/app/agents/ranker.py): `app/agents/ranker.py`

### Other components

- **Browser user**
- **Anthropic API**

## Connections

- Browser user → Streamlit UI: asks and uploads (evidence: `README.md`)
- Streamlit UI → FastAPI API: sends HTTP (evidence: `README.md`)
- FastAPI API → Document loader: parses uploads (evidence: `app/api/main.py`)
- FastAPI API → Vector store: indexes and manages (evidence: `app/api/main.py`)
- FastAPI API → Pipeline orchestrator: runs queries (evidence: `app/api/main.py`)
- Pipeline orchestrator → Safety guard: checks input (evidence: `README.md`)
- Pipeline orchestrator → Planner agent: plans query (evidence: `README.md`)
- Pipeline orchestrator → Vector store: retrieves chunks (evidence: `app/agents/pipeline.py`)
- Pipeline orchestrator → Similarity threshold: checks similarity (evidence: `README.md`)
- Pipeline orchestrator → Cross-encoder reranker: reranks chunks (evidence: `README.md`)
- Pipeline orchestrator → Reasoner agent: generates answer (evidence: `README.md`)
- Pipeline orchestrator → Validator agent: validates answer (evidence: `README.md`)
- Pipeline orchestrator → ReAct agent: runs alternate mode (evidence: `app/agents/pipeline.py`)
- Pipeline orchestrator → Compare results: combines modes (evidence: `app/agents/pipeline.py`)
- Planner agent → LLM client: requests completion (evidence: `app/agents/planner.py`)
- Reasoner agent → LLM client: requests completion (evidence: `app/agents/reasoner.py`)
- Validator agent → LLM client: requests completion (evidence: `app/agents/validator.py`)
- ReAct agent → Vector store: searches iteratively (evidence: `app/agents/llama_agent.py`)
- ReAct agent → LLM client: reasons each turn (evidence: `app/agents/llama_agent.py`)
- LLM client → Anthropic API: calls model (evidence: `README.md`)
- Document loader → Chunk service: chunks parsed text
