A modern RAG (Retrieval-Augmented Generation) application for interactive PDF document querying
Features • Architecture • Tech Stack • Installation • Usage • Development • License
PdfChat is a full-stack PDF chat application that allows users to upload PDF files, process them into vector embeddings, store them in a Qdrant vector database, and interact with the content through a conversational AI interface. The system leverages local machine learning models for embeddings and integrates with OpenRouter for chat completions.
- 📄 PDF Management: Upload and process multiple PDFs with streamlined interface
- 🔍 Semantic Search: AI-powered search through your documents using natural language questions
- 💬 Conversational AI: Chat with your documents using OpenRouter's GPT-4o integration
- 🧠 Local Embeddings: Generate vector embeddings locally using Xenova Transformers
- 🚀 Real-time Updates: Track PDF processing with visual progress indicators
- 🔐 Authentication: Secure user management through Clerk authentication
- 🎨 Modern UI: Clean, responsive design with glassmorphism and dark mode
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Frontend │ ◄──────► │ Backend │ ◄──────► │ Vector Store│
│ (Next.js) │ │ (Node.js) │ │ (Qdrant) │
└─────────────┘ └─────────────┘ └─────────────┘
▲ │ ▲
│ ▼ │
│ ┌─────────────┐ │
│ │ Job Queue │ │
│ │ (BullMQ) │ │
│ └─────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────┐ │
└───────────────►│ LLM API │◄────────────────┘
│ (OpenRouter) │
└─────────────┘
- User uploads a PDF through the frontend
- Backend queues the PDF for processing using BullMQ
- Worker processes the PDF:
- Extracts text
- Splits into chunks
- Generates embeddings using Xenova Transformers
- Stores vectors in Qdrant
- User asks questions through the chat interface
- Backend retrieves relevant document chunks from Qdrant
- Retrieved context is sent to OpenRouter along with the query
- AI-generated response is displayed to the user
- Framework: Next.js 15 with App Router and React 19
- UI Components: Custom components with Tailwind CSS
- Authentication: Clerk integration
- State Management: React hooks
- Runtime: Node.js with Express 5
- Vector Database: Qdrant (via Docker)
- Queue System: BullMQ with Valkey (Redis alternative)
- Document Processing: LangChain document loaders and text splitters
- Embeddings: Local Xenova Transformers (all-MiniLM-L6-v2)
- LLM Provider: OpenRouter with GPT-4o
- Node.js (v18+)
- Docker and Docker Compose
- OpenRouter API key
- Hugging Face API key (optional)
git clone https://github.com/yourusername/pdfchat.git
cd pdfchat
docker-compose up -d
This starts:
- Qdrant on port 6333 (UI dashboard available at http://localhost:6333/dashboard)
- Valkey (Redis alternative) on port 6379
For the server:
cd server
# Create .env file with necessary API keys and configuration
Required server environment variables:
OPENAI_API_KEY
: Your OpenRouter API keyHUGGINGFACE_API_KEY
: Your Hugging Face API key (optional)
For the client (if using authentication):
cd client
# Create .env.local with Clerk credentials
Backend:
cd server
npm install
npm run dev # Start the main server
npm run dev:worker # In a separate terminal, start the worker
Frontend:
cd client
npm install
npm run dev
- Navigate to http://localhost:3000 in your browser
- Upload a PDF document
- Wait for processing to complete (observe the progress indicator)
- Start asking questions about your document in the chat interface
- View AI-generated responses with source references
pdfchat/
├── client/ # Frontend (Next.js)
│ ├── app/ # App router structure
│ ├── components/ # Reusable UI components
│ └── lib/ # Utility functions
├── server/ # Backend (Node.js)
│ ├── index.js # Express server
│ ├── worker.js # BullMQ worker for PDF processing
│ └── uploads/ # Temporary PDF storage
└── docker-compose.yml # Docker config for infrastructure
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.
- LangChain for document processing
- Qdrant for vector storage
- OpenRouter for AI completions
- Xenova Transformers for local embeddings
- Next.js for the frontend framework
- Clerk for authentication