How haiderimam07/pdf-chat-rag works
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: worker.js Ingestion worker · index.js Chat endpoint · page.tsx Chat workspace · chat.tsx Chat interface
Components 16
Client experience
- Chat workspace
client/app/page.tsx - PDF upload
client/app/components/file-upload.tsx - Chat interface
client/app/components/chat.tsx
PDF ingestion
- Upload endpoint
server/index.js - Uploaded PDFs
server/uploads - Ingestion worker
server/worker.js - PDF extraction
server/worker.js - Text chunking
server/worker.js - Vector indexing
server/worker.js
Question answering
- Chat endpoint
server/index.js - Context retrieval
server/index.js - Answer generation
server/index.js
External services
- Upload queue
- Qdrant collection
- Ollama models
Other components
- User
Connections 20
- 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