# derek-aman/docchat architecture

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

- Interactive diagram: https://gitdiagram.com/derek-aman/docchat
- Repository: https://github.com/derek-aman/docchat

## Overview

DocChat is a document-question answering application: users upload a PDF, the backend queues it for indexing, and users ask questions through a chat UI that retrieves relevant document context for an AI-generated answer. The sampled runtime implements PDF ingestion; DOCX/TXT parsing is described in the README but not evidenced in the sampled code. The README also names Qdrant and Redis, while source excerpts show their use. Some queue handoff and deployment wiring is not fully evidenced, so uncertain links are omitted or dashed.

Main entry points: [`backend/index.js`](https://github.com/derek-aman/docchat/blob/main/backend/index.js) (Upload and chat API), [`frontend/src/Pages/Home.jsx`](https://github.com/derek-aman/docchat/blob/main/frontend/src/Pages/Home.jsx) (Home page), [`backend/worker.js`](https://github.com/derek-aman/docchat/blob/main/backend/worker.js) (Ingestion worker), [`frontend/src/Pages/ChatPage.jsx`](https://github.com/derek-aman/docchat/blob/main/frontend/src/Pages/ChatPage.jsx) (Chat interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["User interface"]
  node_app["Route app<br/>[App.jsx]"]
  node_home["Home page<br/>[Home.jsx]"]
  node_hero["Product intro<br/>[Hero.jsx]"]
  node_uploadui["PDF upload UI<br/>[FileUploadCard.jsx]"]
  node_chatui["Chat interface<br/>[ChatPage.jsx]"]
  node_header["Navigation header<br/>[Header.jsx]"]
  node_about["Feature overview<br/>[About.jsx]"]
  node_footer["Page footer<br/>[Footer.jsx]"]
end

subgraph group_api["Backend API"]
  node_api["Upload and chat API<br/>[index.js]"]
  node_redisconfig["Redis connection<br/>[redis.js]"]
end

subgraph group_ingest["Document indexing"]
  node_queue["Upload job queue<br/>[index.js]"]
  node_worker["Ingestion worker<br/>[worker.js]"]
  node_pdf["PDF extraction<br/>[worker.js]"]
  node_chunks["Text chunking<br/>[worker.js]"]
  node_embeddings["Embedding generation<br/>[worker.js]"]
end

subgraph group_rag["Answer retrieval"]
  node_vectors[("Vector collection<br/>[worker.js]")]
  node_retrieval["Context retrieval<br/>[index.js]"]
  node_generation["Answer generation<br/>[index.js]"]
end

node_user(("Document user"))
node_redis["Redis service"]
node_qdrant[("Qdrant")]
node_googleai{{"Google AI"}}

node_user -.->|"opens"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_chatui
node_home -->|"renders"| node_hero
node_home -->|"renders"| node_uploadui
node_home -->|"renders"| node_header
node_home -->|"renders"| node_about
node_home -->|"renders"| node_footer
node_chatui -->|"renders"| node_header
node_uploadui -->|"uploads PDF"| node_api
node_chatui -->|"sends question"| node_api
node_api -.->|"returns answer"| node_chatui
node_api -->|"uses connection"| node_redisconfig
node_worker -->|"uses connection"| node_redisconfig
node_api -->|"enqueues upload"| node_queue
node_queue -.->|"dispatches job"| node_worker
node_redisconfig -.->|"connects to"| node_redis
node_worker -->|"loads file"| node_pdf
node_worker -->|"splits documents"| node_chunks
node_worker -->|"embeds chunks"| node_embeddings
node_worker -->|"stores documents"| node_vectors
node_embeddings -.->|"calls"| node_googleai
node_vectors -.->|"writes collection"| node_qdrant
node_api -->|"searches context"| node_retrieval
node_retrieval -.->|"embeds query"| node_embeddings
node_retrieval -.->|"reads vectors"| node_qdrant
node_api -->|"generates answer"| node_generation
node_generation -.->|"calls model"| node_googleai

click node_app "https://github.com/derek-aman/docchat/blob/main/frontend/src/App.jsx"
click node_home "https://github.com/derek-aman/docchat/blob/main/frontend/src/Pages/Home.jsx"
click node_hero "https://github.com/derek-aman/docchat/blob/main/frontend/src/components/Hero.jsx"
click node_uploadui "https://github.com/derek-aman/docchat/blob/main/frontend/src/components/FileUploadCard.jsx"
click node_chatui "https://github.com/derek-aman/docchat/blob/main/frontend/src/Pages/ChatPage.jsx"
click node_header "https://github.com/derek-aman/docchat/blob/main/frontend/src/components/Header.jsx"
click node_about "https://github.com/derek-aman/docchat/blob/main/frontend/src/components/About.jsx"
click node_footer "https://github.com/derek-aman/docchat/blob/main/frontend/src/components/Footer.jsx"
click node_api "https://github.com/derek-aman/docchat/blob/main/backend/index.js"
click node_redisconfig "https://github.com/derek-aman/docchat/blob/main/backend/redis.js"
click node_queue "https://github.com/derek-aman/docchat/blob/main/backend/index.js"
click node_worker "https://github.com/derek-aman/docchat/blob/main/backend/worker.js"
click node_pdf "https://github.com/derek-aman/docchat/blob/main/backend/worker.js"
click node_chunks "https://github.com/derek-aman/docchat/blob/main/backend/worker.js"
click node_embeddings "https://github.com/derek-aman/docchat/blob/main/backend/worker.js"
click node_vectors "https://github.com/derek-aman/docchat/blob/main/backend/worker.js"
click node_retrieval "https://github.com/derek-aman/docchat/blob/main/backend/index.js"
click node_generation "https://github.com/derek-aman/docchat/blob/main/backend/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_app,node_home,node_hero,node_uploadui,node_chatui,node_header,node_about,node_footer,node_user toneBlue
class node_api,node_redisconfig,node_redis,node_qdrant toneAmber
class node_queue,node_worker,node_pdf,node_chunks,node_embeddings toneMint
class node_vectors,node_retrieval,node_generation toneRose
class node_googleai toneIndigo
```

## Components

### User interface

- [Route app](https://github.com/derek-aman/docchat/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Home page](https://github.com/derek-aman/docchat/blob/main/frontend/src/Pages/Home.jsx): `frontend/src/Pages/Home.jsx`
- [Product intro](https://github.com/derek-aman/docchat/blob/main/frontend/src/components/Hero.jsx): `frontend/src/components/Hero.jsx`
- [PDF upload UI](https://github.com/derek-aman/docchat/blob/main/frontend/src/components/FileUploadCard.jsx): `frontend/src/components/FileUploadCard.jsx`
- [Chat interface](https://github.com/derek-aman/docchat/blob/main/frontend/src/Pages/ChatPage.jsx): `frontend/src/Pages/ChatPage.jsx`
- [Navigation header](https://github.com/derek-aman/docchat/blob/main/frontend/src/components/Header.jsx): `frontend/src/components/Header.jsx`
- [Feature overview](https://github.com/derek-aman/docchat/blob/main/frontend/src/components/About.jsx): `frontend/src/components/About.jsx`
- [Page footer](https://github.com/derek-aman/docchat/blob/main/frontend/src/components/Footer.jsx): `frontend/src/components/Footer.jsx`

### Backend API

- [Upload and chat API](https://github.com/derek-aman/docchat/blob/main/backend/index.js): `backend/index.js`
- [Redis connection](https://github.com/derek-aman/docchat/blob/main/backend/redis.js): `backend/redis.js`

### Document indexing

- [Upload job queue](https://github.com/derek-aman/docchat/blob/main/backend/index.js): `backend/index.js`
- [Ingestion worker](https://github.com/derek-aman/docchat/blob/main/backend/worker.js): `backend/worker.js`
- [PDF extraction](https://github.com/derek-aman/docchat/blob/main/backend/worker.js): `backend/worker.js`
- [Text chunking](https://github.com/derek-aman/docchat/blob/main/backend/worker.js): `backend/worker.js`
- [Embedding generation](https://github.com/derek-aman/docchat/blob/main/backend/worker.js): `backend/worker.js`

### Answer retrieval

- [Vector collection](https://github.com/derek-aman/docchat/blob/main/backend/worker.js): `backend/worker.js`
- [Context retrieval](https://github.com/derek-aman/docchat/blob/main/backend/index.js): `backend/index.js`
- [Answer generation](https://github.com/derek-aman/docchat/blob/main/backend/index.js): `backend/index.js`

### Other components

- **Document user**
- **Redis service**
- **Qdrant**
- **Google AI**

## Connections

- Document user → Route app: opens
- Route app → Home page: routes to (evidence: `frontend/src/App.jsx`)
- Route app → Chat interface: routes to (evidence: `frontend/src/App.jsx`)
- Home page → Product intro: renders (evidence: `frontend/src/Pages/Home.jsx`)
- Home page → PDF upload UI: renders (evidence: `frontend/src/Pages/Home.jsx`)
- Home page → Navigation header: renders (evidence: `frontend/src/Pages/Home.jsx`)
- Home page → Feature overview: renders (evidence: `frontend/src/Pages/Home.jsx`)
- Home page → Page footer: renders (evidence: `frontend/src/Pages/Home.jsx`)
- Chat interface → Navigation header: renders (evidence: `frontend/src/Pages/ChatPage.jsx`)
- PDF upload UI → Upload and chat API: uploads PDF (evidence: `frontend/src/components/FileUploadCard.jsx`)
- Chat interface → Upload and chat API: sends question (evidence: `frontend/src/Pages/ChatPage.jsx`)
- Upload and chat API → Chat interface: returns answer
- Upload and chat API → Redis connection: uses connection (evidence: `backend/index.js`)
- Ingestion worker → Redis connection: uses connection (evidence: `backend/worker.js`)
- Upload and chat API → Upload job queue: enqueues upload (evidence: `backend/index.js`)
- Upload job queue → Ingestion worker: dispatches job
- Redis connection → Redis service: connects to
- Ingestion worker → PDF extraction: loads file (evidence: `backend/worker.js`)
- Ingestion worker → Text chunking: splits documents (evidence: `backend/worker.js`)
- Ingestion worker → Embedding generation: embeds chunks (evidence: `backend/worker.js`)
- Ingestion worker → Vector collection: stores documents (evidence: `backend/worker.js`)
- Embedding generation → Google AI: calls
- Vector collection → Qdrant: writes collection
- Upload and chat API → Context retrieval: searches context (evidence: `backend/index.js`)
- Context retrieval → Embedding generation: embeds query
- Context retrieval → Qdrant: reads vectors
- Upload and chat API → Answer generation: generates answer (evidence: `backend/index.js`)
- Answer generation → Google AI: calls model
