# ahsaanjameel595/document-rag-chatbot architecture

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

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

## Overview

This is a PDF question-answering chatbot: users ask questions in a browser, the API retrieves relevant document context, generates an answer with sources, and stores the exchange by session. The frontend also fetches document metadata and supports starting a fresh chat. The tree identifies document-loading, splitting, embedding, vector-store, and answer-generation modules, but their implementations and wiring were not sampled; those components are shown without speculative links. The README is empty.

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Chat frontend"]
  node_app["App state"]
  node_chat_ui["Chat window"]
end

subgraph group_api["Backend API"]
  node_api_entry["FastAPI app"]
  node_chat_api["Chat endpoint"]
  node_documents_api["Document endpoint"]
  node_conversations_api["Conversation endpoint"]
end

subgraph group_rag["RAG pipeline"]
  node_loader["PDF loader"]
  node_splitter["Text splitter"]
  node_embeddings["Embeddings"]
  node_vectorstore["Vector store"]
  node_retriever["Retriever"]
  node_generator["Answer generator"]
end

subgraph group_state["Conversation state"]
  node_database[("Chat history")]
end

node_user(("User"))

node_user -->|"asks questions"| node_chat_ui
node_app -->|"provides session"| node_chat_ui
node_app -->|"fetches metadata"| node_documents_api
node_chat_ui -->|"posts question"| node_chat_api
node_api_entry -->|"mounts route"| node_chat_api
node_api_entry -->|"mounts route"| node_documents_api
node_api_entry -->|"mounts route"| node_conversations_api
node_chat_api -->|"saves messages"| node_database
node_chat_api -->|"retrieves context"| node_retriever
node_retriever -->|"creates retriever"| node_vectorstore
node_chat_api -->|"generates answer"| node_generator
node_conversations_api -->|"reads history"| node_database
node_chat_api -->|"reads history"| node_database

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_chat_ui,node_user toneBlue
class node_api_entry,node_chat_api,node_documents_api,node_conversations_api toneAmber
class node_loader,node_splitter,node_embeddings,node_vectorstore,node_retriever,node_generator toneMint
class node_database toneRose
```

## Components

### Chat frontend

- **App state**
- **Chat window**

### Backend API

- **FastAPI app**
- **Chat endpoint**
- **Document endpoint**
- **Conversation endpoint**

### RAG pipeline

- **PDF loader**
- **Text splitter**
- **Embeddings**
- **Vector store**
- **Retriever**
- **Answer generator**

### Conversation state

- **Chat history**

### Other components

- **User**

## Connections

- User → Chat window: asks questions
- App state → Chat window: provides session
- App state → Document endpoint: fetches metadata
- Chat window → Chat endpoint: posts question
- FastAPI app → Chat endpoint: mounts route
- FastAPI app → Document endpoint: mounts route
- FastAPI app → Conversation endpoint: mounts route
- Chat endpoint → Chat history: saves messages
- Chat endpoint → Retriever: retrieves context
- Retriever → Vector store: creates retriever
- Chat endpoint → Answer generator: generates answer
- Conversation endpoint → Chat history: reads history
- Chat endpoint → Chat history: reads history
