# haiderimam07/pdf-chat-rag architecture

> Architecture diagram of the GitHub repository haiderimam07/pdf-chat-rag, 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/haiderimam07/pdf-chat-rag
- Repository: https://github.com/haiderimam07/pdf-chat-rag

## Overview

PDF-Chat-RAG lets a user upload PDFs and ask natural-language questions answered from their contents. The upload endpoint saves each PDF and queues a job; a background worker extracts text, chunks it, embeds it, and indexes it in Qdrant. For questions, the chat UI calls the API, which retrieves matching chunks and supplies them as context to the language model before returning an answer and the retrieved documents. The graph follows the sampled client and server code; unsampled deployment details and the README’s scalability claims are not represented.

Main entry points: [`server/worker.js`](https://github.com/haiderimam07/pdf-chat-rag/blob/main/server/worker.js) (Ingestion worker), [`server/index.js`](https://github.com/haiderimam07/pdf-chat-rag/blob/main/server/index.js) (Chat endpoint), [`client/app/page.tsx`](https://github.com/haiderimam07/pdf-chat-rag/blob/main/client/app/page.tsx) (Chat workspace), [`client/app/components/chat.tsx`](https://github.com/haiderimam07/pdf-chat-rag/blob/main/client/app/components/chat.tsx) (Chat interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_workspace["Chat workspace<br/>[page.tsx]"]
  node_upload_ui["PDF upload<br/>[file-upload.tsx]"]
  node_chat_ui["Chat interface<br/>[chat.tsx]"]
end

subgraph group_ingestion["PDF ingestion"]
  node_upload_api["Upload endpoint<br/>[index.js]"]
  node_pdf_files[("Uploaded PDFs")]
  node_worker["Ingestion worker<br/>[worker.js]"]
  node_pdf_parse["PDF extraction<br/>[worker.js]"]
  node_chunking["Text chunking<br/>[worker.js]"]
  node_indexing["Vector indexing<br/>[worker.js]"]
end

subgraph group_retrieval["Question answering"]
  node_chat_api["Chat endpoint<br/>[index.js]"]
  node_retrieval_logic["Context retrieval<br/>[index.js]"]
  node_generation["Answer generation<br/>[index.js]"]
end

subgraph group_services["External services"]
  node_job_queue["Upload queue"]
  node_vector_store[("Qdrant collection")]
  node_ollama["Ollama models"]
end

node_user(("User"))

node_user -->|"uses"| node_workspace
node_workspace -->|"presents"| node_upload_ui
node_workspace -->|"presents"| node_chat_ui
node_upload_ui -->|"uploads PDF"| node_upload_api
node_upload_api -->|"saves file"| node_pdf_files
node_upload_api -->|"enqueues job"| node_job_queue
node_job_queue -->|"dispatches job"| node_worker
node_worker -->|"reads PDF"| node_pdf_files
node_worker -->|"loads document"| node_pdf_parse
node_pdf_parse -->|"provides text"| node_chunking
node_worker -->|"indexes chunks"| node_indexing
node_indexing -->|"writes vectors"| node_vector_store
node_indexing -->|"requests embeddings"| node_ollama
node_chat_ui -->|"sends query"| node_chat_api
node_chat_api -->|"retrieves context"| node_retrieval_logic
node_retrieval_logic -->|"embeds query"| node_ollama
node_retrieval_logic -->|"searches vectors"| node_vector_store
node_chat_api -->|"generates answer"| node_generation
node_generation -->|"invokes model"| node_ollama
node_chat_api -->|"returns answer"| node_chat_ui

click node_workspace "https://github.com/haiderimam07/pdf-chat-rag/blob/main/client/app/page.tsx"
click node_upload_ui "https://github.com/haiderimam07/pdf-chat-rag/blob/main/client/app/components/file-upload.tsx"
click node_chat_ui "https://github.com/haiderimam07/pdf-chat-rag/blob/main/client/app/components/chat.tsx"
click node_upload_api "https://github.com/haiderimam07/pdf-chat-rag/blob/main/server/index.js"
click node_pdf_files "https://github.com/haiderimam07/pdf-chat-rag/tree/main/server/uploads"
click node_worker "https://github.com/haiderimam07/pdf-chat-rag/blob/main/server/worker.js"
click node_pdf_parse "https://github.com/haiderimam07/pdf-chat-rag/blob/main/server/worker.js"
click node_chunking "https://github.com/haiderimam07/pdf-chat-rag/blob/main/server/worker.js"
click node_indexing "https://github.com/haiderimam07/pdf-chat-rag/blob/main/server/worker.js"
click node_chat_api "https://github.com/haiderimam07/pdf-chat-rag/blob/main/server/index.js"
click node_retrieval_logic "https://github.com/haiderimam07/pdf-chat-rag/blob/main/server/index.js"
click node_generation "https://github.com/haiderimam07/pdf-chat-rag/blob/main/server/index.js"

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_workspace,node_upload_ui,node_chat_ui,node_user toneBlue
class node_upload_api,node_pdf_files,node_worker,node_pdf_parse,node_chunking,node_indexing toneAmber
class node_chat_api,node_retrieval_logic,node_generation toneMint
class node_job_queue,node_vector_store,node_ollama toneRose
```

## Components

### Client experience

- [Chat workspace](https://github.com/haiderimam07/pdf-chat-rag/blob/main/client/app/page.tsx): `client/app/page.tsx`
- [PDF upload](https://github.com/haiderimam07/pdf-chat-rag/blob/main/client/app/components/file-upload.tsx): `client/app/components/file-upload.tsx`
- [Chat interface](https://github.com/haiderimam07/pdf-chat-rag/blob/main/client/app/components/chat.tsx): `client/app/components/chat.tsx`

### PDF ingestion

- [Upload endpoint](https://github.com/haiderimam07/pdf-chat-rag/blob/main/server/index.js): `server/index.js`
- [Uploaded PDFs](https://github.com/haiderimam07/pdf-chat-rag/tree/main/server/uploads): `server/uploads`
- [Ingestion worker](https://github.com/haiderimam07/pdf-chat-rag/blob/main/server/worker.js): `server/worker.js`
- [PDF extraction](https://github.com/haiderimam07/pdf-chat-rag/blob/main/server/worker.js): `server/worker.js`
- [Text chunking](https://github.com/haiderimam07/pdf-chat-rag/blob/main/server/worker.js): `server/worker.js`
- [Vector indexing](https://github.com/haiderimam07/pdf-chat-rag/blob/main/server/worker.js): `server/worker.js`

### Question answering

- [Chat endpoint](https://github.com/haiderimam07/pdf-chat-rag/blob/main/server/index.js): `server/index.js`
- [Context retrieval](https://github.com/haiderimam07/pdf-chat-rag/blob/main/server/index.js): `server/index.js`
- [Answer generation](https://github.com/haiderimam07/pdf-chat-rag/blob/main/server/index.js): `server/index.js`

### External services

- **Upload queue**
- **Qdrant collection**
- **Ollama models**

### Other components

- **User**

## Connections

- User → Chat workspace: uses
- Chat workspace → PDF upload: presents
- Chat workspace → Chat interface: presents
- PDF upload → Upload endpoint: uploads PDF
- Upload endpoint → Uploaded PDFs: saves file
- Upload endpoint → Upload queue: enqueues job
- Upload queue → Ingestion worker: dispatches job
- Ingestion worker → Uploaded PDFs: reads PDF
- Ingestion worker → PDF extraction: loads document
- PDF extraction → Text chunking: provides text
- Ingestion worker → Vector indexing: indexes chunks
- Vector indexing → Qdrant collection: writes vectors
- Vector indexing → Ollama models: requests embeddings
- Chat interface → Chat endpoint: sends query
- Chat endpoint → Context retrieval: retrieves context
- Context retrieval → Ollama models: embeds query
- Context retrieval → Qdrant collection: searches vectors
- Chat endpoint → Answer generation: generates answer
- Answer generation → Ollama models: invokes model
- Chat endpoint → Chat interface: returns answer
