# kishore-cpu/rag architecture

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

- Interactive diagram: https://gitdiagram.com/kishore-cpu/rag
- Repository: https://github.com/kishore-cpu/rag

## Overview

This local document-question-answering application offers two entry points: a Streamlit interface and a lightweight HTTP web server. Users upload PDF, text, or Markdown files; the interfaces invoke document loading and chunking, then build a persistent vector index. Questions are passed to the RAG chain, which retrieves relevant chunks and is configured with a local Ollama chat model; answers include source citations. The excerpts show both ingestion routes and the retrieval setup, but omit some query-chain internals, so those links are limited to visible calls.

Main entry points: [`RAG/rag_chain.py`](https://github.com/kishore-cpu/rag/blob/main/RAG/rag_chain.py) (RAG Query Chain), [`RAG/app.py`](https://github.com/kishore-cpu/rag/blob/main/RAG/app.py) (Streamlit App), [`RAG/server.py`](https://github.com/kishore-cpu/rag/blob/main/RAG/server.py) (HTTP Server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User Interfaces"]
  node_streamlit_app["Streamlit App<br/>[app.py]"]
  node_http_server["HTTP Server<br/>[server.py]"]
end

subgraph group_ingestion["Document Indexing"]
  node_document_processor["Document Processor<br/>[rag_chain.py]"]
  node_ocr["PDF OCR<br/>[rag_chain.py]"]
  node_chunking["Text Chunking<br/>[rag_chain.py]"]
  node_vector_manager["Vector Store Manager<br/>[rag_chain.py]"]
  node_chroma[("Chroma Index<br/>[rag_chain.py]")]
end

subgraph group_answering["Question Answering"]
  node_rag_chain["RAG Query Chain<br/>[rag_chain.py]"]
  node_retriever["Chunk Retrieval<br/>[rag_chain.py]"]
end

node_user(("User"))
node_ollama["Ollama Model"]

node_user -->|"uploads, asks"| node_streamlit_app
node_user -->|"uploads, asks"| node_http_server
node_streamlit_app -->|"loads documents"| node_document_processor
node_http_server -->|"loads documents"| node_document_processor
node_document_processor -->|"runs when needed"| node_ocr
node_document_processor -->|"splits documents"| node_chunking
node_streamlit_app -->|"builds index"| node_vector_manager
node_http_server -->|"builds index"| node_vector_manager
node_vector_manager -->|"persists chunks"| node_chroma
node_streamlit_app -->|"runs query"| node_rag_chain
node_http_server -->|"runs query"| node_rag_chain
node_rag_chain -->|"gets retriever"| node_vector_manager
node_rag_chain -->|"invokes retrieval"| node_retriever
node_rag_chain -->|"configures model"| node_ollama

click node_streamlit_app "https://github.com/kishore-cpu/rag/blob/main/RAG/app.py"
click node_http_server "https://github.com/kishore-cpu/rag/blob/main/RAG/server.py"
click node_document_processor "https://github.com/kishore-cpu/rag/blob/main/RAG/rag_chain.py"
click node_ocr "https://github.com/kishore-cpu/rag/blob/main/RAG/rag_chain.py"
click node_chunking "https://github.com/kishore-cpu/rag/blob/main/RAG/rag_chain.py"
click node_vector_manager "https://github.com/kishore-cpu/rag/blob/main/RAG/rag_chain.py"
click node_chroma "https://github.com/kishore-cpu/rag/blob/main/RAG/rag_chain.py"
click node_rag_chain "https://github.com/kishore-cpu/rag/blob/main/RAG/rag_chain.py"
click node_retriever "https://github.com/kishore-cpu/rag/blob/main/RAG/rag_chain.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_app,node_http_server,node_user toneBlue
class node_document_processor,node_ocr,node_chunking,node_vector_manager,node_chroma toneAmber
class node_rag_chain,node_retriever toneMint
class node_ollama toneIndigo
```

## Components

### User Interfaces

- [Streamlit App](https://github.com/kishore-cpu/rag/blob/main/RAG/app.py): `RAG/app.py`
- [HTTP Server](https://github.com/kishore-cpu/rag/blob/main/RAG/server.py): `RAG/server.py`

### Document Indexing

- [Document Processor](https://github.com/kishore-cpu/rag/blob/main/RAG/rag_chain.py): `RAG/rag_chain.py`
- [PDF OCR](https://github.com/kishore-cpu/rag/blob/main/RAG/rag_chain.py): `RAG/rag_chain.py`
- [Text Chunking](https://github.com/kishore-cpu/rag/blob/main/RAG/rag_chain.py): `RAG/rag_chain.py`
- [Vector Store Manager](https://github.com/kishore-cpu/rag/blob/main/RAG/rag_chain.py): `RAG/rag_chain.py`
- [Chroma Index](https://github.com/kishore-cpu/rag/blob/main/RAG/rag_chain.py): `RAG/rag_chain.py`

### Question Answering

- [RAG Query Chain](https://github.com/kishore-cpu/rag/blob/main/RAG/rag_chain.py): `RAG/rag_chain.py`
- [Chunk Retrieval](https://github.com/kishore-cpu/rag/blob/main/RAG/rag_chain.py): `RAG/rag_chain.py`

### Other components

- **User**
- **Ollama Model**

## Connections

- User → Streamlit App: uploads, asks (evidence: `RAG/app.py`)
- User → HTTP Server: uploads, asks (evidence: `RAG/server.py`)
- Streamlit App → Document Processor: loads documents (evidence: `RAG/app.py`)
- HTTP Server → Document Processor: loads documents (evidence: `RAG/server.py`)
- Document Processor → PDF OCR: runs when needed (evidence: `RAG/rag_chain.py`)
- Document Processor → Text Chunking: splits documents (evidence: `RAG/rag_chain.py`)
- Streamlit App → Vector Store Manager: builds index (evidence: `RAG/app.py`)
- HTTP Server → Vector Store Manager: builds index (evidence: `RAG/server.py`)
- Vector Store Manager → Chroma Index: persists chunks (evidence: `RAG/rag_chain.py`)
- Streamlit App → RAG Query Chain: runs query (evidence: `RAG/app.py`)
- HTTP Server → RAG Query Chain: runs query (evidence: `RAG/server.py`)
- RAG Query Chain → Vector Store Manager: gets retriever (evidence: `RAG/rag_chain.py`)
- RAG Query Chain → Chunk Retrieval: invokes retrieval (evidence: `RAG/rag_chain.py`)
- RAG Query Chain → Ollama Model: configures model (evidence: `RAG/rag_chain.py`)
