A Node.js API that enables intelligent conversations with PDF documents using Retrieval-Augmented Generation (RAG) powered by Google's Gemini AI and LangChain. Built with LangChain's powerful RAG framework for efficient document processing and contextual retrieval.
- 📤 PDF Upload: Secure file upload with size and type validation
- 💾 Vector Storage: Document embeddings stored in Qdrant vector database
- 🤖 Smart Retrieval: Contextual search using similarity matching
- 💬 AI Chat: Natural conversations with PDF content using Gemini AI
- Node.js
- Docker (for Qdrant)
- Google Gemini API Key
Create a .env
file with:
GEMINI_API_KEY=your_api_key_here
QDRANT_URL=http://localhost:6333
PORT=3000
- Clone the repository
- Install dependencies:
npm install
- Start Qdrant:
docker-compose -f docker-compose.db.yml up -d
- Run the server:
npm run dev
POST /upload-pdf
Content-Type: multipart/form-data
form-data:
- pdf: <file>
POST /chat
Content-Type: application/json
{
"pdfName": "example.pdf",
"query": "What is this document about?"
}
- Express.js - Web framework
- LangChain - RAG implementation
- Google Gemini AI - Embeddings and chat completion
- Qdrant - Vector database
- Multer - File upload handling
- File size limit: 5MB
- PDF-only file validation
- Error handling and validation