RAG Chatbot
Retrieval-Augmented Generation with pgvector + OpenAI
Documents (0)
Welcome to RAG Chatbot!
Upload documents and ask questions about them.
Knowledge Base
Upload documents to build your custom knowledge base
Smart Search
Vector similarity search finds relevant context
AI Responses
GPT-4 generates answers based on your data
Tech Stack & Architecture
Backend
- •Next.js 16 - Serverless API routes
- •Neon PostgreSQL + pgvector - Vector database with HNSW indexing
- •OpenAI Embeddings - text-embedding-3-small (1536 dimensions)
- •Vercel Blob - Document storage (bypasses 4.5MB upload limit)
Frontend
- •React 19 - Modern UI with hooks
- •Tailwind CSS - Responsive styling + dark mode
- •CSRF Protection - Secure state-changing operations
- •PDF/TXT Support - Upload files up to 25MB
Data Flow
Document Upload Flow:
PDF/TXT Upload
→Vercel Blob
→Extract Text
→Chunk (500 tokens)
→Generate Embeddings
→Store in Neon
Query Flow:
User Question
→Embed Query
→Vector Search (pgvector)
→Retrieve Top 5 Chunks
→GPT-4 + Context
→AI Response
Key Technical Features
✓HNSW Indexing: Fast approximate nearest neighbor search
✓Semantic Chunking: 500 tokens with 50-token overlap
✓Cosine Similarity: <=> operator for vector distance
✓Source Citations: Track which documents answered questions