# princevegetaiv/document-rag-chatbot architecture

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

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

## Overview

Local single-user document RAG chatbot: a user adds supported files through the knowledge-base panel, the backend extracts and chunks them into persistent Chroma storage, then chat requests retrieve relevant passages and generate grounded answers through Groq. The browser retains follow-up history. The README documents the health/status and ingestion capabilities. The graph follows shown calls and documented HTTP behavior; unsampled frontend page wiring and some runtime details are not inferred.

Main entry points: [`backend/app/rag/vector_store.py`](https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/rag/vector_store.py) (Persistent vector store), [`backend/app/api/chat.py`](https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/api/chat.py) (Chat endpoint), [`backend/app/rag/chain.py`](https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/rag/chain.py) (Conversational RAG chain), [`backend/app/api/ingestion.py`](https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/api/ingestion.py) (Ingestion endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Browser UI"]
  node_kb_ui["Knowledge base panel<br/>[KnowledgeBase.tsx]"]
  node_chat_ui["Chat interface<br/>[Chat.tsx]"]
  node_frontend_api["Backend API client<br/>[api.ts]"]
  node_browser_history["Conversation history<br/>[Chat.tsx]"]
end

subgraph group_api["HTTP Backend"]
  node_app["FastAPI application<br/>[main.py]"]
  node_settings["Application settings<br/>[config.py]"]
  node_dependencies["Shared dependencies<br/>[deps.py]"]
  node_request_schemas["Request schemas<br/>[requests.py]"]
  node_ingest_endpoint["Ingestion endpoint<br/>[ingestion.py]"]
  node_chat_endpoint["Chat endpoint<br/>[chat.py]"]
end

subgraph group_ingestion["Document Indexing"]
  node_file_loader["File discovery and loading<br/>[document_loader.py]"]
  node_chunker["Document chunker<br/>[chunker.py]"]
  node_embeddings["Local embeddings<br/>[embeddings.py]"]
  node_vector_store[("Persistent vector store<br/>[vector_store.py]")]
  node_documents["User document files"]
  node_manifest[("Ingestion manifest<br/>[vector_store.py]")]
end

subgraph group_chat["Grounded Chat"]
  node_rag_chain["Conversational RAG chain<br/>[chain.py]"]
  node_retriever["Thresholded retrieval<br/>[retriever.py]"]
  node_groq{{"Groq language model"}}
end

node_user(("Local user"))

node_user -->|"uploads via"| node_kb_ui
node_user -->|"asks"| node_chat_ui
node_kb_ui -->|"requests ingestion"| node_frontend_api
node_chat_ui -->|"sends chat"| node_frontend_api
node_chat_ui -->|"stores history"| node_browser_history
node_frontend_api -->|"POST /api/ingest"| node_ingest_endpoint
node_frontend_api -->|"POST /api/chat"| node_chat_endpoint
node_app -->|"registers route"| node_ingest_endpoint
node_app -->|"registers route"| node_chat_endpoint
node_app -->|"resolves settings/store"| node_dependencies
node_dependencies -->|"loads configuration"| node_settings
node_dependencies -->|"opens store"| node_vector_store
node_ingest_endpoint -->|"uses dependencies"| node_dependencies
node_chat_endpoint -->|"uses dependencies"| node_dependencies
node_ingest_endpoint -->|"returns schema"| node_request_schemas
node_chat_endpoint -->|"validates and responds"| node_request_schemas
node_ingest_endpoint -->|"ingests files"| node_vector_store
node_chat_endpoint -->|"counts chunks"| node_vector_store
node_chat_endpoint -->|"answers question"| node_rag_chain
node_documents -->|"provides files"| node_file_loader
node_vector_store -->|"discovers and loads"| node_file_loader
node_vector_store -->|"chunks documents"| node_chunker
node_vector_store -->|"configures embeddings"| node_embeddings
node_vector_store -->|"reads and writes"| node_manifest
node_vector_store -->|"reads source files"| node_documents
node_vector_store -.->|"stores searchable chunks"| node_retriever
node_rag_chain -->|"uses model settings"| node_settings
node_rag_chain -->|"retrieves passages"| node_retriever
node_retriever -->|"searches chunks"| node_vector_store
node_rag_chain -->|"invokes generation"| node_groq
node_rag_chain -->|"uses follow-up context"| node_browser_history

click node_kb_ui "https://github.com/princevegetaiv/document-rag-chatbot/blob/main/frontend/components/KnowledgeBase.tsx"
click node_chat_ui "https://github.com/princevegetaiv/document-rag-chatbot/blob/main/frontend/components/Chat.tsx"
click node_frontend_api "https://github.com/princevegetaiv/document-rag-chatbot/blob/main/frontend/lib/api.ts"
click node_app "https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/main.py"
click node_settings "https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/config.py"
click node_dependencies "https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/deps.py"
click node_request_schemas "https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/schemas/requests.py"
click node_ingest_endpoint "https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/api/ingestion.py"
click node_chat_endpoint "https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/api/chat.py"
click node_file_loader "https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/rag/document_loader.py"
click node_chunker "https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/rag/chunker.py"
click node_embeddings "https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/rag/embeddings.py"
click node_vector_store "https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/rag/vector_store.py"
click node_documents "https://github.com/princevegetaiv/document-rag-chatbot/tree/main/backend/data/documents"
click node_manifest "https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/rag/vector_store.py"
click node_rag_chain "https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/rag/chain.py"
click node_retriever "https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/rag/retriever.py"
click node_browser_history "https://github.com/princevegetaiv/document-rag-chatbot/blob/main/frontend/components/Chat.tsx"

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_kb_ui,node_chat_ui,node_frontend_api,node_browser_history,node_user toneBlue
class node_app,node_settings,node_dependencies,node_request_schemas,node_ingest_endpoint,node_chat_endpoint toneAmber
class node_file_loader,node_chunker,node_embeddings,node_vector_store,node_documents,node_manifest toneMint
class node_rag_chain,node_retriever,node_groq toneRose
```

## Components

### Browser UI

- [Knowledge base panel](https://github.com/princevegetaiv/document-rag-chatbot/blob/main/frontend/components/KnowledgeBase.tsx): `frontend/components/KnowledgeBase.tsx`
- [Chat interface](https://github.com/princevegetaiv/document-rag-chatbot/blob/main/frontend/components/Chat.tsx): `frontend/components/Chat.tsx`
- [Backend API client](https://github.com/princevegetaiv/document-rag-chatbot/blob/main/frontend/lib/api.ts): `frontend/lib/api.ts`
- [Conversation history](https://github.com/princevegetaiv/document-rag-chatbot/blob/main/frontend/components/Chat.tsx): `frontend/components/Chat.tsx`

### HTTP Backend

- [FastAPI application](https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/main.py): `backend/app/main.py`
- [Application settings](https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/config.py): `backend/app/config.py`
- [Shared dependencies](https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/deps.py): `backend/app/deps.py`
- [Request schemas](https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/schemas/requests.py): `backend/app/schemas/requests.py`
- [Ingestion endpoint](https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/api/ingestion.py): `backend/app/api/ingestion.py`
- [Chat endpoint](https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/api/chat.py): `backend/app/api/chat.py`

### Document Indexing

- [File discovery and loading](https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/rag/document_loader.py): `backend/app/rag/document_loader.py`
- [Document chunker](https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/rag/chunker.py): `backend/app/rag/chunker.py`
- [Local embeddings](https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/rag/embeddings.py): `backend/app/rag/embeddings.py`
- [Persistent vector store](https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/rag/vector_store.py): `backend/app/rag/vector_store.py`
- [User document files](https://github.com/princevegetaiv/document-rag-chatbot/tree/main/backend/data/documents): `backend/data/documents`
- [Ingestion manifest](https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/rag/vector_store.py): `backend/app/rag/vector_store.py`

### Grounded Chat

- [Conversational RAG chain](https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/rag/chain.py): `backend/app/rag/chain.py`
- [Thresholded retrieval](https://github.com/princevegetaiv/document-rag-chatbot/blob/main/backend/app/rag/retriever.py): `backend/app/rag/retriever.py`
- **Groq language model**

### Other components

- **Local user**

## Connections

- Local user → Knowledge base panel: uploads via (evidence: `README.md`)
- Local user → Chat interface: asks (evidence: `README.md`)
- Knowledge base panel → Backend API client: requests ingestion (evidence: `README.md`)
- Chat interface → Backend API client: sends chat (evidence: `README.md`)
- Chat interface → Conversation history: stores history (evidence: `README.md`)
- Backend API client → Ingestion endpoint: POST /api/ingest (evidence: `README.md`)
- Backend API client → Chat endpoint: POST /api/chat (evidence: `README.md`)
- FastAPI application → Ingestion endpoint: registers route (evidence: `backend/app/main.py`)
- FastAPI application → Chat endpoint: registers route (evidence: `backend/app/main.py`)
- FastAPI application → Shared dependencies: resolves settings/store (evidence: `backend/app/main.py`)
- Shared dependencies → Application settings: loads configuration (evidence: `backend/app/deps.py`)
- Shared dependencies → Persistent vector store: opens store (evidence: `backend/app/deps.py`)
- Ingestion endpoint → Shared dependencies: uses dependencies (evidence: `backend/app/api/ingestion.py`)
- Chat endpoint → Shared dependencies: uses dependencies (evidence: `backend/app/api/chat.py`)
- Ingestion endpoint → Request schemas: returns schema (evidence: `backend/app/api/ingestion.py`)
- Chat endpoint → Request schemas: validates and responds (evidence: `backend/app/api/chat.py`)
- Ingestion endpoint → Persistent vector store: ingests files (evidence: `backend/app/api/ingestion.py`)
- Chat endpoint → Persistent vector store: counts chunks (evidence: `backend/app/api/chat.py`)
- Chat endpoint → Conversational RAG chain: answers question (evidence: `backend/app/api/chat.py`)
- User document files → File discovery and loading: provides files (evidence: `README.md`)
- Persistent vector store → File discovery and loading: discovers and loads (evidence: `backend/app/rag/vector_store.py`)
- Persistent vector store → Document chunker: chunks documents (evidence: `backend/app/rag/vector_store.py`)
- Persistent vector store → Local embeddings: configures embeddings (evidence: `backend/app/rag/vector_store.py`)
- Persistent vector store → Ingestion manifest: reads and writes (evidence: `backend/app/rag/vector_store.py`)
- Persistent vector store → User document files: reads source files (evidence: `README.md`)
- Persistent vector store → Thresholded retrieval: stores searchable chunks
- Conversational RAG chain → Application settings: uses model settings (evidence: `backend/app/rag/chain.py`)
- Conversational RAG chain → Thresholded retrieval: retrieves passages (evidence: `backend/app/rag/chain.py`)
- Thresholded retrieval → Persistent vector store: searches chunks (evidence: `backend/app/rag/retriever.py`)
- Conversational RAG chain → Groq language model: invokes generation (evidence: `backend/app/rag/chain.py`)
- Conversational RAG chain → Conversation history: uses follow-up context (evidence: `README.md`)
