# jakkenasrikar/rag-document-qa-chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/jakkenasrikar/rag-document-qa-chatbot
- Repository: https://github.com/jakkenasrikar/rag-document-qa-chatbot

## Overview

This is a Streamlit PDF question-answering application. Users upload PDFs for extraction, traceable chunking, embedding, and persistent indexing; questions are retrieved against those chunks and answered by a configurable, grounded LLM, with page-level citations shown in the UI. The app also supports document deletion, database reset, provider selection, and session chat history. The graph follows sampled calls and README-documented capabilities; some app wiring and feature details are documented but not present in the excerpts.

Main entry points: [`app.py`](https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/app.py) (Streamlit App), [`rag/chain.py`](https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/rag/chain.py) (RAG Chain), [`ui/components.py`](https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/ui/components.py) (UI Components), [`vectorstore/chroma_store.py`](https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/vectorstore/chroma_store.py) (Vector Store Manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User Interface"]
  node_app["Streamlit App<br/>[app.py]"]
  node_ui["UI Components<br/>[components.py]"]
  node_session[("Chat Session<br/>[app.py]")]
end

subgraph group_ingest["Document Ingestion"]
  node_pdf["PDF Extraction<br/>[pdf_loader.py]"]
  node_splitter["Text Chunking<br/>[text_splitter.py]"]
end

subgraph group_search["Retrieval and Storage"]
  node_embedding_factory["Embedding Factory<br/>[embedding_model.py]"]
  node_vector_manager["Vector Store Manager<br/>[chroma_store.py]"]
  node_chroma[("Persistent ChromaDB")]
  node_retriever["Document Retriever<br/>[retriever.py]"]
end

subgraph group_answer["Answer Generation"]
  node_rag["RAG Chain<br/>[chain.py]"]
  node_llm_factory["LLM Factory<br/>[llm.py]"]
  node_citations["Grounded Answer and Citations<br/>[chain.py]"]
end

node_user(("User"))
node_settings["Settings<br/>[settings.py]"]
node_embedding_service["Embedding Service"]
node_llm_service["LLM Service"]

node_user -->|"uploads or asks"| node_app
node_app -->|"renders controls"| node_ui
node_app -->|"reads configuration"| node_settings
node_app -->|"maintains history"| node_session
node_app -->|"extracts uploads"| node_pdf
node_pdf -->|"page documents"| node_splitter
node_app -->|"chunks pages"| node_splitter
node_app -->|"selects embeddings"| node_embedding_factory
node_embedding_factory -.->|"creates provider"| node_embedding_service
node_app -->|"checks, indexes, manages"| node_vector_manager
node_vector_manager -->|"reads and writes"| node_chroma
node_app -->|"creates retriever"| node_retriever
node_retriever -->|"searches chunks"| node_vector_manager
node_app -->|"selects model"| node_llm_factory
node_llm_factory -.->|"creates provider"| node_llm_service
node_app -->|"requests answer"| node_rag
node_rag -->|"retrieves scored chunks"| node_retriever
node_rag -->|"generates grounded answer"| node_llm_service
node_rag -->|"returns answer and sources"| node_citations
node_app -->|"displays citations"| node_ui
node_ui -->|"shows response"| node_user

click node_app "https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/app.py"
click node_ui "https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/ui/components.py"
click node_session "https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/app.py"
click node_settings "https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/config/settings.py"
click node_pdf "https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/ingestion/pdf_loader.py"
click node_splitter "https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/ingestion/text_splitter.py"
click node_embedding_factory "https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/embeddings/embedding_model.py"
click node_vector_manager "https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/vectorstore/chroma_store.py"
click node_chroma "https://github.com/jakkenasrikar/rag-document-qa-chatbot/tree/main/data/chroma"
click node_retriever "https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/retrieval/retriever.py"
click node_rag "https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/rag/chain.py"
click node_llm_factory "https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/generation/llm.py"
click node_citations "https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/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_app,node_ui,node_session,node_user toneBlue
class node_pdf,node_splitter toneAmber
class node_embedding_factory,node_vector_manager,node_chroma,node_retriever toneMint
class node_rag,node_llm_factory,node_citations toneRose
class node_settings toneTeal
class node_embedding_service,node_llm_service toneIndigo
```

## Components

### User Interface

- [Streamlit App](https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/app.py): `app.py`
- [UI Components](https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/ui/components.py): `ui/components.py`
- [Chat Session](https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/app.py): `app.py`

### Document Ingestion

- [PDF Extraction](https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/ingestion/pdf_loader.py): `ingestion/pdf_loader.py`
- [Text Chunking](https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/ingestion/text_splitter.py): `ingestion/text_splitter.py`

### Retrieval and Storage

- [Embedding Factory](https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/embeddings/embedding_model.py): `embeddings/embedding_model.py`
- [Vector Store Manager](https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/vectorstore/chroma_store.py): `vectorstore/chroma_store.py`
- [Persistent ChromaDB](https://github.com/jakkenasrikar/rag-document-qa-chatbot/tree/main/data/chroma): `data/chroma`
- [Document Retriever](https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/retrieval/retriever.py): `retrieval/retriever.py`

### Answer Generation

- [RAG Chain](https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/rag/chain.py): `rag/chain.py`
- [LLM Factory](https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/generation/llm.py): `generation/llm.py`
- [Grounded Answer and Citations](https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/rag/chain.py): `rag/chain.py`

### Other components

- **User**
- [Settings](https://github.com/jakkenasrikar/rag-document-qa-chatbot/blob/main/config/settings.py): `config/settings.py`
- **Embedding Service**
- **LLM Service**

## Connections

- User → Streamlit App: uploads or asks
- Streamlit App → UI Components: renders controls
- Streamlit App → Settings: reads configuration
- Streamlit App → Chat Session: maintains history
- Streamlit App → PDF Extraction: extracts uploads
- PDF Extraction → Text Chunking: page documents
- Streamlit App → Text Chunking: chunks pages
- Streamlit App → Embedding Factory: selects embeddings
- Embedding Factory → Embedding Service: creates provider
- Streamlit App → Vector Store Manager: checks, indexes, manages
- Vector Store Manager → Persistent ChromaDB: reads and writes
- Streamlit App → Document Retriever: creates retriever
- Document Retriever → Vector Store Manager: searches chunks
- Streamlit App → LLM Factory: selects model
- LLM Factory → LLM Service: creates provider
- Streamlit App → RAG Chain: requests answer
- RAG Chain → Document Retriever: retrieves scored chunks
- RAG Chain → LLM Service: generates grounded answer
- RAG Chain → Grounded Answer and Citations: returns answer and sources
- Streamlit App → UI Components: displays citations
- UI Components → User: shows response
