# vignesh-a04/rag-chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/vignesh-a04/rag-chatbot
- Repository: https://github.com/vignesh-a04/rag-chatbot

## Overview

This is a full-stack, multi-PDF RAG chatbot. Users upload PDFs, which the API saves and indexes; questions go through retrieval, context construction, and Gemini generation, with answers and source metadata returned to the chat UI. The API also supports document listing and deletion, while the frontend provides chat and document management. Relationships among backend modules are supported by the sampled source; other capabilities and frontend-to-API wiring are documented in the README or visible in the page excerpt.

Main entry points: [`app/main.py`](https://github.com/vignesh-a04/rag-chatbot/blob/main/app/main.py) (FastAPI endpoints), [`app/rag/pipeline.py`](https://github.com/vignesh-a04/rag-chatbot/blob/main/app/rag/pipeline.py) (Ingestion orchestration), [`frontend/app/page.tsx`](https://github.com/vignesh-a04/rag-chatbot/blob/main/frontend/app/page.tsx) (Chat and documents UI), [`app/ingestion/loader.py`](https://github.com/vignesh-a04/rag-chatbot/blob/main/app/ingestion/loader.py) (PDF page extraction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_web["Chat and documents UI<br/>[page.tsx]"]
end

subgraph group_api["REST API"]
  node_api_routes["FastAPI endpoints<br/>[main.py]"]
  node_uploaded_pdfs["Uploaded PDF files<br/>[main.py]"]
end

subgraph group_ingest["Document ingestion"]
  node_ingest_flow["Ingestion orchestration<br/>[pipeline.py]"]
  node_pdf_loader["PDF page extraction<br/>[loader.py]"]
  node_chunker["Text chunking<br/>[chunker.py]"]
  node_pdf_loader_lib["PyPDFLoader"]
  node_text_splitter["Recursive splitter"]
end

subgraph group_rag["RAG and storage"]
  node_rag_flow["RAG orchestration<br/>[pipeline.py]"]
  node_retrieval_context["Search and context<br/>[pipeline.py]"]
  node_document_admin["Document lifecycle<br/>[pipeline.py]"]
  node_vector_store[("Chroma vector store")]
end

subgraph group_models["AI services"]
  node_embedding_factory["Embedding setup<br/>[embeddings.py]"]
  node_gemini_embeddings["Gemini embeddings"]
  node_gemini_llm["Gemini answer model"]
end

node_user(("User"))

node_user -->|"uses"| node_web
node_web -->|"calls API"| node_api_routes
node_api_routes -->|"saves and removes"| node_uploaded_pdfs
node_api_routes -->|"indexes upload"| node_ingest_flow
node_api_routes -->|"lists and deletes"| node_document_admin
node_api_routes -->|"submits question"| node_rag_flow
node_ingest_flow -->|"loads pages"| node_pdf_loader
node_ingest_flow -->|"splits pages"| node_chunker
node_pdf_loader -->|"extracts pages"| node_pdf_loader_lib
node_chunker -->|"splits text"| node_text_splitter
node_ingest_flow -->|"stores chunks"| node_vector_store
node_ingest_flow -->|"configures embeddings"| node_embedding_factory
node_embedding_factory -->|"creates embeddings"| node_gemini_embeddings
node_rag_flow -->|"retrieves and builds context"| node_retrieval_context
node_retrieval_context -->|"searches top three"| node_vector_store
node_rag_flow -->|"generates answer"| node_gemini_llm
node_document_admin -->|"reads and deletes chunks"| node_vector_store
node_api_routes -.->|"returns API results"| node_web

click node_web "https://github.com/vignesh-a04/rag-chatbot/blob/main/frontend/app/page.tsx"
click node_api_routes "https://github.com/vignesh-a04/rag-chatbot/blob/main/app/main.py"
click node_uploaded_pdfs "https://github.com/vignesh-a04/rag-chatbot/blob/main/app/main.py"
click node_ingest_flow "https://github.com/vignesh-a04/rag-chatbot/blob/main/app/rag/pipeline.py"
click node_pdf_loader "https://github.com/vignesh-a04/rag-chatbot/blob/main/app/ingestion/loader.py"
click node_chunker "https://github.com/vignesh-a04/rag-chatbot/blob/main/app/ingestion/chunker.py"
click node_embedding_factory "https://github.com/vignesh-a04/rag-chatbot/blob/main/app/retrieval/embeddings.py"
click node_rag_flow "https://github.com/vignesh-a04/rag-chatbot/blob/main/app/rag/pipeline.py"
click node_retrieval_context "https://github.com/vignesh-a04/rag-chatbot/blob/main/app/rag/pipeline.py"
click node_document_admin "https://github.com/vignesh-a04/rag-chatbot/blob/main/app/rag/pipeline.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_web,node_user toneBlue
class node_api_routes,node_uploaded_pdfs toneAmber
class node_ingest_flow,node_pdf_loader,node_chunker,node_pdf_loader_lib,node_text_splitter toneMint
class node_rag_flow,node_retrieval_context,node_document_admin,node_vector_store toneRose
class node_embedding_factory,node_gemini_embeddings,node_gemini_llm toneIndigo
```

## Components

### Web client

- [Chat and documents UI](https://github.com/vignesh-a04/rag-chatbot/blob/main/frontend/app/page.tsx): `frontend/app/page.tsx`

### REST API

- [FastAPI endpoints](https://github.com/vignesh-a04/rag-chatbot/blob/main/app/main.py): `app/main.py`
- [Uploaded PDF files](https://github.com/vignesh-a04/rag-chatbot/blob/main/app/main.py): `app/main.py`

### Document ingestion

- [Ingestion orchestration](https://github.com/vignesh-a04/rag-chatbot/blob/main/app/rag/pipeline.py): `app/rag/pipeline.py`
- [PDF page extraction](https://github.com/vignesh-a04/rag-chatbot/blob/main/app/ingestion/loader.py): `app/ingestion/loader.py`
- [Text chunking](https://github.com/vignesh-a04/rag-chatbot/blob/main/app/ingestion/chunker.py): `app/ingestion/chunker.py`
- **PyPDFLoader**
- **Recursive splitter**

### RAG and storage

- [RAG orchestration](https://github.com/vignesh-a04/rag-chatbot/blob/main/app/rag/pipeline.py): `app/rag/pipeline.py`
- [Search and context](https://github.com/vignesh-a04/rag-chatbot/blob/main/app/rag/pipeline.py): `app/rag/pipeline.py`
- [Document lifecycle](https://github.com/vignesh-a04/rag-chatbot/blob/main/app/rag/pipeline.py): `app/rag/pipeline.py`
- **Chroma vector store**

### AI services

- [Embedding setup](https://github.com/vignesh-a04/rag-chatbot/blob/main/app/retrieval/embeddings.py): `app/retrieval/embeddings.py`
- **Gemini embeddings**
- **Gemini answer model**

### Other components

- **User**

## Connections

- User → Chat and documents UI: uses (evidence: `README.md`)
- Chat and documents UI → FastAPI endpoints: calls API (evidence: `README.md`)
- FastAPI endpoints → Uploaded PDF files: saves and removes (evidence: `app/main.py`)
- FastAPI endpoints → Ingestion orchestration: indexes upload (evidence: `app/main.py`)
- FastAPI endpoints → Document lifecycle: lists and deletes (evidence: `app/main.py`)
- FastAPI endpoints → RAG orchestration: submits question (evidence: `app/main.py`)
- Ingestion orchestration → PDF page extraction: loads pages (evidence: `app/rag/pipeline.py`)
- Ingestion orchestration → Text chunking: splits pages (evidence: `app/rag/pipeline.py`)
- PDF page extraction → PyPDFLoader: extracts pages (evidence: `app/ingestion/loader.py`)
- Text chunking → Recursive splitter: splits text (evidence: `app/ingestion/chunker.py`)
- Ingestion orchestration → Chroma vector store: stores chunks (evidence: `app/rag/pipeline.py`)
- Ingestion orchestration → Embedding setup: configures embeddings (evidence: `app/rag/pipeline.py`)
- Embedding setup → Gemini embeddings: creates embeddings (evidence: `app/retrieval/embeddings.py`)
- RAG orchestration → Search and context: retrieves and builds context (evidence: `app/rag/pipeline.py`)
- Search and context → Chroma vector store: searches top three (evidence: `app/rag/pipeline.py`)
- RAG orchestration → Gemini answer model: generates answer (evidence: `app/rag/pipeline.py`)
- Document lifecycle → Chroma vector store: reads and deletes chunks (evidence: `app/rag/pipeline.py`)
- FastAPI endpoints → Chat and documents UI: returns API results (evidence: `README.md`)
