# rnktyagi/pdf_rag_chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/rnktyagi/pdf_rag_chatbot
- Repository: https://github.com/rnktyagi/pdf_rag_chatbot

## Overview

This PDF question-answering product lets users upload PDFs and ask document-grounded questions through a chat UI. Uploads are converted to contextualized chunks and indexed; chat requests enter a stateful agent, which can retrieve user-scoped passages and answer using an LLM. The README provides little architectural detail, so the map relies on the sampled source; unsampled capabilities and integrations are not inferred.

Main entry points: [`src/main.py`](https://github.com/rnktyagi/pdf_rag_chatbot/blob/main/src/main.py) (FastAPI endpoints), [`src/graph.py`](https://github.com/rnktyagi/pdf_rag_chatbot/blob/main/src/graph.py) (RAG agent), [`src/embedding.py`](https://github.com/rnktyagi/pdf_rag_chatbot/blob/main/src/embedding.py) (Embedding and indexing), [`src/retrieval.py`](https://github.com/rnktyagi/pdf_rag_chatbot/blob/main/src/retrieval.py) (Hybrid retriever)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_ui["Chat UI<br/>[app.py]"]
end

subgraph group_api["API and agent"]
  node_api["FastAPI endpoints<br/>[main.py]"]
  node_agent["RAG agent<br/>[graph.py]"]
  node_tool["Retrieval tool<br/>[graph.py]"]
end

subgraph group_documents["Document processing"]
  node_ingestion["PDF chunking<br/>[ingestion.py]"]
  node_indexing["Embedding and indexing<br/>[embedding.py]"]
end

subgraph group_search["Retrieval"]
  node_retriever["Hybrid retriever<br/>[retrieval.py]"]
end

subgraph group_services["External services"]
  node_qdrant[("Qdrant vector store")]
  node_reranker["Cross-encoder reranker"]
  node_postgres[("Postgres checkpoints")]
  node_llm["Groq-hosted LLM"]
end

node_user(("User"))

node_user -->|"asks or uploads"| node_ui
node_ui -->|"posts requests"| node_api
node_api -->|"processes upload"| node_indexing
node_indexing -->|"chunks PDF"| node_ingestion
node_indexing -->|"indexes chunks"| node_qdrant
node_api -->|"invokes chat"| node_agent
node_api -->|"sets up checkpoints"| node_postgres
node_agent -->|"dispatches retrieval"| node_tool
node_agent -->|"generates answers"| node_llm
node_tool -->|"searches for user"| node_retriever
node_retriever -->|"searches chunks"| node_qdrant
node_retriever -->|"reranks matches"| node_reranker
node_tool -->|"returns passages"| node_agent

click node_ui "https://github.com/rnktyagi/pdf_rag_chatbot/blob/main/app.py"
click node_api "https://github.com/rnktyagi/pdf_rag_chatbot/blob/main/src/main.py"
click node_agent "https://github.com/rnktyagi/pdf_rag_chatbot/blob/main/src/graph.py"
click node_tool "https://github.com/rnktyagi/pdf_rag_chatbot/blob/main/src/graph.py"
click node_ingestion "https://github.com/rnktyagi/pdf_rag_chatbot/blob/main/src/ingestion.py"
click node_indexing "https://github.com/rnktyagi/pdf_rag_chatbot/blob/main/src/embedding.py"
click node_retriever "https://github.com/rnktyagi/pdf_rag_chatbot/blob/main/src/retrieval.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_ui,node_user toneBlue
class node_api,node_agent,node_tool toneAmber
class node_ingestion,node_indexing toneMint
class node_retriever toneRose
class node_qdrant,node_reranker,node_postgres,node_llm toneIndigo
```

## Components

### User interface

- [Chat UI](https://github.com/rnktyagi/pdf_rag_chatbot/blob/main/app.py): `app.py`

### API and agent

- [FastAPI endpoints](https://github.com/rnktyagi/pdf_rag_chatbot/blob/main/src/main.py): `src/main.py`
- [RAG agent](https://github.com/rnktyagi/pdf_rag_chatbot/blob/main/src/graph.py): `src/graph.py`
- [Retrieval tool](https://github.com/rnktyagi/pdf_rag_chatbot/blob/main/src/graph.py): `src/graph.py`

### Document processing

- [PDF chunking](https://github.com/rnktyagi/pdf_rag_chatbot/blob/main/src/ingestion.py): `src/ingestion.py`
- [Embedding and indexing](https://github.com/rnktyagi/pdf_rag_chatbot/blob/main/src/embedding.py): `src/embedding.py`

### Retrieval

- [Hybrid retriever](https://github.com/rnktyagi/pdf_rag_chatbot/blob/main/src/retrieval.py): `src/retrieval.py`

### External services

- **Qdrant vector store**
- **Cross-encoder reranker**
- **Postgres checkpoints**
- **Groq-hosted LLM**

### Other components

- **User**

## Connections

- User → Chat UI: asks or uploads (evidence: `app.py`)
- Chat UI → FastAPI endpoints: posts requests (evidence: `app.py`)
- FastAPI endpoints → Embedding and indexing: processes upload (evidence: `src/main.py`)
- Embedding and indexing → PDF chunking: chunks PDF (evidence: `src/embedding.py`)
- Embedding and indexing → Qdrant vector store: indexes chunks (evidence: `src/embedding.py`)
- FastAPI endpoints → RAG agent: invokes chat (evidence: `src/main.py`)
- FastAPI endpoints → Postgres checkpoints: sets up checkpoints (evidence: `src/main.py`)
- RAG agent → Retrieval tool: dispatches retrieval (evidence: `src/graph.py`)
- RAG agent → Groq-hosted LLM: generates answers (evidence: `src/graph.py`)
- Retrieval tool → Hybrid retriever: searches for user (evidence: `src/graph.py`)
- Hybrid retriever → Qdrant vector store: searches chunks (evidence: `src/retrieval.py`)
- Hybrid retriever → Cross-encoder reranker: reranks matches (evidence: `src/retrieval.py`)
- Retrieval tool → RAG agent: returns passages (evidence: `src/graph.py`)
