# subhamparajuli/hybrid-rag architecture

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

- Interactive diagram: https://gitdiagram.com/subhamparajuli/hybrid-rag
- Repository: https://github.com/subhamparajuli/hybrid-rag

## Overview

Hybrid RAG Assistant accepts document uploads and questions through a Streamlit UI or FastAPI, indexes supported files locally, and answers from hybrid retrieval context using Ollama. The graph follows documented upload and answer flows, plus the optional evaluation capability. Source excerpts show the main calls; LangSmith and Ollama are external services, and some README-described subsystem details rely on documentation rather than sampled implementation.

Main entry points: [`api.py`](https://github.com/subhamparajuli/hybrid-rag/blob/main/api.py) (FastAPI Routes), [`src/evaluate.py`](https://github.com/subhamparajuli/hybrid-rag/blob/main/src/evaluate.py) (Retrieval Evaluation), [`src/chain.py`](https://github.com/subhamparajuli/hybrid-rag/blob/main/src/chain.py) (Context and RAG Chain), [`src/vectorstore.py`](https://github.com/subhamparajuli/hybrid-rag/blob/main/src/vectorstore.py) (Embeddings and Chroma)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User Interfaces"]
  node_streamlit["Chat and Upload UI<br/>[app.py]"]
end

subgraph group_service["API Service"]
  node_api["FastAPI Routes<br/>[api.py]"]
  node_config["Runtime Settings<br/>[config.py]"]
end

subgraph group_indexing["Document Indexing"]
  node_ingester["Load and Split<br/>[ingestion.py]"]
  node_vectors[("Embeddings and Chroma<br/>[vectorstore.py]")]
  node_chroma[("Local Vector Store")]
end

subgraph group_answering["Retrieval and Generation"]
  node_hybrid["Hybrid Retrieval and RRF<br/>[retriever.py]"]
  node_rag["Context and RAG Chain<br/>[chain.py]"]
  node_ollama["Local Ollama Model"]
end

subgraph group_evaluation["Evaluation"]
  node_evaluator["Retrieval Evaluation<br/>[evaluate.py]"]
  node_examples["Evaluation Examples<br/>[examples.py]"]
end

node_user(("User"))
node_langsmith["LangSmith"]

node_user -->|"uses"| node_streamlit
node_user -->|"queries directly"| node_api
node_streamlit -->|"posts uploads and questions"| node_api
node_api -->|"runs ingestion"| node_ingester
node_ingester -->|"persists chunks"| node_vectors
node_vectors -->|"stores embeddings"| node_chroma
node_api -->|"initializes and asks"| node_rag
node_rag -->|"retrieves context"| node_hybrid
node_hybrid -->|"opens vector store"| node_vectors
node_hybrid -->|"searches and reads chunks"| node_chroma
node_rag -->|"generates answer"| node_ollama
node_api -->|"returns answer"| node_streamlit
node_evaluator -->|"loads examples"| node_examples
node_evaluator -->|"uses RAG chain"| node_rag
node_evaluator -->|"opens store"| node_vectors
node_evaluator -->|"uploads and evaluates"| node_langsmith

click node_streamlit "https://github.com/subhamparajuli/hybrid-rag/blob/main/app.py"
click node_api "https://github.com/subhamparajuli/hybrid-rag/blob/main/api.py"
click node_ingester "https://github.com/subhamparajuli/hybrid-rag/blob/main/src/ingestion.py"
click node_vectors "https://github.com/subhamparajuli/hybrid-rag/blob/main/src/vectorstore.py"
click node_config "https://github.com/subhamparajuli/hybrid-rag/blob/main/src/config.py"
click node_hybrid "https://github.com/subhamparajuli/hybrid-rag/blob/main/src/retriever.py"
click node_rag "https://github.com/subhamparajuli/hybrid-rag/blob/main/src/chain.py"
click node_evaluator "https://github.com/subhamparajuli/hybrid-rag/blob/main/src/evaluate.py"
click node_examples "https://github.com/subhamparajuli/hybrid-rag/blob/main/src/examples.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_streamlit,node_user toneBlue
class node_api,node_config toneAmber
class node_ingester,node_vectors,node_chroma toneMint
class node_hybrid,node_rag,node_ollama toneRose
class node_evaluator,node_examples,node_langsmith toneIndigo
```

## Components

### User Interfaces

- [Chat and Upload UI](https://github.com/subhamparajuli/hybrid-rag/blob/main/app.py): `app.py`

### API Service

- [FastAPI Routes](https://github.com/subhamparajuli/hybrid-rag/blob/main/api.py): `api.py`
- [Runtime Settings](https://github.com/subhamparajuli/hybrid-rag/blob/main/src/config.py): `src/config.py`

### Document Indexing

- [Load and Split](https://github.com/subhamparajuli/hybrid-rag/blob/main/src/ingestion.py): `src/ingestion.py`
- [Embeddings and Chroma](https://github.com/subhamparajuli/hybrid-rag/blob/main/src/vectorstore.py): `src/vectorstore.py`
- **Local Vector Store**

### Retrieval and Generation

- [Hybrid Retrieval and RRF](https://github.com/subhamparajuli/hybrid-rag/blob/main/src/retriever.py): `src/retriever.py`
- [Context and RAG Chain](https://github.com/subhamparajuli/hybrid-rag/blob/main/src/chain.py): `src/chain.py`
- **Local Ollama Model**

### Evaluation

- [Retrieval Evaluation](https://github.com/subhamparajuli/hybrid-rag/blob/main/src/evaluate.py): `src/evaluate.py`
- [Evaluation Examples](https://github.com/subhamparajuli/hybrid-rag/blob/main/src/examples.py): `src/examples.py`

### Other components

- **User**
- **LangSmith**

## Connections

- User → Chat and Upload UI: uses (evidence: `README.md`)
- User → FastAPI Routes: queries directly (evidence: `README.md`)
- Chat and Upload UI → FastAPI Routes: posts uploads and questions (evidence: `app.py`)
- FastAPI Routes → Load and Split: runs ingestion (evidence: `api.py`)
- Load and Split → Embeddings and Chroma: persists chunks (evidence: `src/ingestion.py`)
- Embeddings and Chroma → Local Vector Store: stores embeddings (evidence: `README.md`)
- FastAPI Routes → Context and RAG Chain: initializes and asks (evidence: `api.py`)
- Context and RAG Chain → Hybrid Retrieval and RRF: retrieves context (evidence: `src/chain.py`)
- Hybrid Retrieval and RRF → Embeddings and Chroma: opens vector store (evidence: `src/retriever.py`)
- Hybrid Retrieval and RRF → Local Vector Store: searches and reads chunks (evidence: `README.md`)
- Context and RAG Chain → Local Ollama Model: generates answer (evidence: `README.md`)
- FastAPI Routes → Chat and Upload UI: returns answer (evidence: `app.py`)
- Retrieval Evaluation → Evaluation Examples: loads examples (evidence: `src/evaluate.py`)
- Retrieval Evaluation → Context and RAG Chain: uses RAG chain (evidence: `src/evaluate.py`)
- Retrieval Evaluation → Embeddings and Chroma: opens store (evidence: `src/evaluate.py`)
- Retrieval Evaluation → LangSmith: uploads and evaluates (evidence: `README.md`)
