A sophisticated full-stack application that enables users to upload PDF documents and engage in intelligent conversations using AI. Built with Next.js 15, Bun runtime, and powered by Mistral AI with advanced vector search capabilities through Qdrant.
- PDF Upload & Processing: Upload and parse PDF documents using pdf-parse
- AI-Powered Chat: Ask questions about your PDF content using Mistral AI
- Conversation Memory: Maintains chat history and context across sessions with Langgraph
- Multi-File Context Selection: Choose and combine context from multiple uploaded PDFs
- Document Analysis: Extract and analyze text content from PDFs with advanced chunking
- Interactive UI: Modern React interface with Radix UI components and Tailwind CSS
- Real-time Responses: Get instant answers based on document content with streaming support
- Vector Search: Semantic search across document content using Qdrant embeddings
- User Authentication: Secure user management with Clerk authentication
- Background Processing: Async document processing with BullMQ job queues
- Framework: Next.js 15 with React 19
- Runtime: Turbopack for development
- Styling: Tailwind CSS 4 with custom animations
- UI Components: Radix UI primitives
- State Management: TanStack React Query v5
- Authentication: Clerk Next.js integration
- HTTP Client: Axios
- Notifications: Sonner toast library
- Icons: Lucide React
- Markdown: Streamdown for rendering
- Runtime: Bun (high-performance JavaScript runtime)
- Framework: Express.js 5
- Language: TypeScript 5
- Authentication: Clerk Express middleware
- Database ORM: Drizzle ORM with PostgreSQL driver
- File Upload: Multer for multipart form handling
- PDF Processing: pdf-parse library
- Job Queue: BullMQ with Redis (Valkey)
- CORS: Express CORS middleware
- LLM: Gemini AI
- AI Framework: LangChain with LangGraph for workflow orchestration
- Vector Database: Qdrant for semantic search and embeddings
- Vector Integration: LangChain Qdrant connector
- Database: PostgreSQL 17.5 (Alpine)
- Vector Store: Qdrant latest
- Cache/Queue: Valkey (Redis-compatible)
- Database Admin: Adminer web interface
- Containerization: Docker & Docker Compose
- Networking: Custom bridge network
- Bun (latest version for server)
- Node.js 18+ (for client)
- Docker and Docker Compose
- Mistral AI API Key
- Clerk Authentication Keys
- Clone the repository:
git clone https://github.com/yourusername/chat-with-pdf.git
cd chat-with-pdf- Install client dependencies:
cd client
npm install- Install server dependencies:
cd ../server
bun install- Set up environment variables:
# Root directory
cp .env.example .env
# Configure the following variables:
POSTGRES_DB=chat_with_pdf
POSTGRES_USER=your_username
POSTGRES_PASSWORD=your_secure_password
# Server environment
MISTRAL_API_KEY=your_mistral_api_key
CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
CLERK_SECRET_KEY=your_clerk_secret_key
DATABASE_URL=postgresql://username:password@localhost:5432/chat_with_pdf
QDRANT_URL=http://localhost:6333
REDIS_URL=redis://localhost:6379- Start infrastructure services:
docker-compose up -d- Initialize database schema:
cd server
bun run db:push- Start the development servers:
Terminal 1 - Backend:
cd server
bun run devTerminal 2 - Background Worker:
cd server
bun run dev:workerTerminal 3 - Frontend:
cd client
npm run dev- Sign Up/Login: Authenticate using Clerk authentication
- Upload PDFs: Select and upload one or more PDF documents
- Document Processing: Wait for background processing to complete (chunking and vectorization)
- Select Context: Choose which documents to include in your conversation context
- Start Chatting: Ask questions about the document content
- Memory Retention: Continue conversations with full context memory across sessions
- Multi-Document Queries: Ask questions that span across multiple documents
- Get AI Responses: Receive Mistral AI-generated responses based on selected PDF content
chat-with-pdf/
βββ client/ # Next.js frontend application
β βββ src/
β β βββ app/ # App Router pages and layouts
β β βββ components/ # Reusable React components
β β βββ lib/ # Utility functions and configurations
β β βββ hooks/ # Custom React hooks
β βββ public/ # Static assets
β βββ package.json # Frontend dependencies
βββ server/ # Bun backend application
β βββ src/
β β βββ routes/ # Express route handlers
β β βββ services/ # Business logic services
β β βββ models/ # Drizzle ORM models
β β βββ middleware/ # Express middleware
β β βββ utils/ # Server utilities
β βββ drizzle/ # Database migrations
β βββ index.ts # Main server entry point
β βββ worker.ts # Background job worker
β βββ package.json # Backend dependencies
βββ docker-compose.yml # Infrastructure services
βββ drizzle.config.ts # Database configuration
βββ README.md # Project documentation
Root .env:
POSTGRES_DB=chat_with_pdf
POSTGRES_USER=postgres
POSTGRES_PASSWORD=your_secure_passwordServer .env:
# Database
DATABASE_URL=postgresql://postgres:password@localhost:5432/chat_with_pdf
# External Services
MISTRAL_API_KEY=your_mistral_api_key
QDRANT_URL=http://localhost:6333
REDIS_URL=redis://localhost:6379
# Authentication (Clerk)
CLERK_PUBLISHABLE_KEY=pk_test_...
CLERK_SECRET_KEY=sk_test_...
# Server Configuration
PORT=3001
NODE_ENV=developmentClient .env.local:
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_...
CLERK_SECRET_KEY=sk_test_...
NEXT_PUBLIC_SERVER_URL=http://localhost:3001- Frontend (Next.js): http://localhost:3000
- Backend (Bun/Express): http://localhost:3001
- PostgreSQL: localhost:5432
- Qdrant: http://localhost:6333
- Valkey/Redis: localhost:6379
- Adminer: http://localhost:8080
# Frontend tests
cd client
npm test
# Backend tests
cd server
bun test- Frontend: Next.js with React Server Components and client-side hydration
- Backend: Express.js API with Bun runtime for high performance
- Real-time: Server-sent events for streaming AI responses
- Document Upload: Multer β PDF parsing β Text chunking β Vector embedding β Qdrant storage
- Chat Processing: User input β Context retrieval β Mistral AI β Response streaming
- Memory Management: Chat history in PostgreSQL + Session cache in Valkey
- BullMQ Jobs: Document processing, embedding generation, cleanup tasks
- Worker Process: Separate Bun process for handling background jobs
- Authentication: Clerk-based user management with JWT tokens
- File Upload: Validated PDF uploads with size and type restrictions
- Database: Parameterized queries with Drizzle ORM
- CORS: Configured for development and production environments
- Rate Limiting: API rate limiting (implementation required)
Client:
cd client
npm run build
npm startServer:
cd server
bun run start# Build production images
docker-compose -f docker-compose.prod.yml build
# Deploy with production configuration
docker-compose -f docker-compose.prod.yml up -d- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow TypeScript strict mode
- Use Prettier for code formatting
- Write tests for new features
- Update documentation for API changes
This project is licensed under the MIT License - see the LICENSE file for details.
- Mistral AI for powerful language model capabilities
- Qdrant for high-performance vector database
- LangChain for AI application framework
- Clerk for seamless authentication
- Bun for ultra-fast JavaScript runtime
- Next.js for React framework excellence
- Vercel for deployment platform
- Radix UI for accessible component primitives
- Tailwind CSS for utility-first styling
- Issues: GitHub Issues for bug reports and feature requests
- Discussions: GitHub Discussions for community support
- Email: [celersneha@example.com]
After running docker-compose up -d, access:
-
Adminer: http://localhost:8080 (Database management)
- Server:
postgres - Username:
${POSTGRES_USER} - Password:
${POSTGRES_PASSWORD} - Database:
${POSTGRES_DB}
- Server:
-
Qdrant Dashboard: http://localhost:6333/dashboard (Vector database UI)
- Start Infrastructure:
docker-compose up -d - Database Migration:
cd server && bun run db:push - Start Backend:
cd server && bun run dev - Start Worker:
cd server && bun run dev:worker - Start Frontend:
cd client && bun run dev - Access Application: http://localhost:3000
- Bun Runtime: Up to 4x faster than Node.js for server operations
- Turbopack: Faster development builds with Next.js 15
- Qdrant: Sub-millisecond vector search performance
- Valkey: High-throughput Redis-compatible caching