A full-stack Retrieval-Augmented Generation (RAG) system that allows users to upload documents, ask questions, and receive AI-powered answers grounded in their uploaded content.
βββββββββββββββββββ ββββββββββββββββ βββββββββββββββββββ
β Frontend β β FastAPI β β PostgreSQL β
β (React/TS) βββββΊβ Backend βββββΊβ (Metadata) β
βββββββββββββββββββ ββββββββββββββββ βββββββββββββββββββ
β
ββββββΌβββββ βββββββββββββββββββ
β Redis β β Qdrant β
β(Caching)β β (Vector Store) β
βββββββββββ βββββββββββββββββββ
β β
βββββββββββΌβββββββββββ βββββββββΌβββββββββ
β AI Pipeline β β Embeddings β
β β β (OpenAI) β
β ββββββββββββββββββββ ββββββββββββββββββ
β β Claude 3.5 ββ
β β (Answer Gen) ββ ββββββββββββββββββ
β ββββββββββββββββββββ β Document β
β ββββββββββββββββββββ β Processing β
β β OpenAI ββ β (PyPDF2/Text) β
β β (Embeddings) ββ ββββββββββββββββββ
β ββββββββββββββββββββ
ββββββββββββββββββββββ
-
Frontend (React + TypeScript)
- Modern, responsive interface with dark/light theme support
- Document upload with drag-and-drop functionality
- Real-time chat interface with typing indicators
- Source citations and document references
-
Backend (FastAPI)
- RESTful API with automatic documentation
- JWT-based authentication system
- Document processing and text extraction
- Vector embedding generation and storage
- RAG query processing with source attribution
-
Database Layer
- PostgreSQL: User accounts, document metadata, chat history
- Qdrant: Vector embeddings for semantic search
- Redis: Query caching and session management
-
AI Pipeline
- Document chunking and embedding generation
- Semantic similarity search
- Context-aware answer generation with citations
- Docker and Docker Compose
- Node.js 18+ (for frontend development)
- Python 3.9+ (for backend development)
- Clone the repository:
git clone <repository-url>
cd rag-dashboard- Create environment files:
# Backend environment
cp .env.example .env
# Configure your API keys and settings:
# OPENAI_API_KEY=your_openai_key
# CLAUDE_API_KEY=your_claude_key
# POSTGRES_URL=postgresql://user:pass@localhost:5432/ragdb
# REDIS_URL=redis://localhost:6379
# QDRANT_URL=http://localhost:6333
# JWT_SECRET_KEY=your_secret_key- Start all services:
docker-compose up -d- Access the application:
- Frontend: http://localhost:3000
- API Documentation: http://localhost:8000/docs
- Qdrant Dashboard: http://localhost:6333/dashboard
Backend:
cd backend
pip install -r requirements.txt
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000Frontend:
cd frontend
npm install
npm run devPOST /auth/register- Create new accountPOST /auth/login- User login
POST /documents/upload- Upload PDF document
POST /qa/query- Ask question about documents
GET /health- Service health checkGET /status- System status and metrics
| Variable | Description | Default |
|---|---|---|
OPENAI_API_KEY |
OpenAI API key for LLM | Required |
CLAUDE_API_KEY |
CLAUDE API key for LLM | Required |
POSTGRES_URL |
PostgreSQL connection string | postgresql://postgres:postgres@localhost:5432/ragdb |
REDIS_URL |
Redis connection string | redis://localhost:6379 |
QDRANT_URL |
Qdrant vector database URL | http://localhost:6333 |
JWT_SECRET_KEY |
JWT signing secret | Random generated |
JWT_EXPIRE_HOURS |
JWT token expiration | 24 |
MAX_FILE_SIZE_MB |
Maximum upload file size | 10 |
LLM_MODEL |
OpenAI chat model | gpt-3.5-turbo |
services:
frontend: # React application (port 3000)
backend: # FastAPI server (port 8000)
postgres: # PostgreSQL database (port 5432)
redis: # Redis cache (port 6379)
qdrant: # Vector database (port 6333)Run the test suite:
# Backend tests
cd backend
pytest tests/ -v --cov=app
# Frontend tests
cd frontend
npm test
# Integration tests
docker-compose -f docker-compose.test.yml up --abort-on-container-exitconst formData = new FormData();
formData.append('file', pdfFile);
const response = await fetch('/documents/upload', {
method: 'POST',
headers: { 'Authorization': `Bearer ${token}` },
body: formData
});const response = await fetch('/query/ask', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
question: "What are the key findings in the document?"
})
});
const data = await response.json();
console.log(data.answer, data.sources);- JWT-based authentication with refresh tokens
- Multi-tenant data isolation (users only see their documents)
- Input validation and sanitization
- Rate limiting on API endpoints
- File type and size restrictions
- SQL injection prevention with SQLAlchemy ORM
- Modern UI: Clean, responsive design with Tailwind CSS
- Dark Mode: Full dark/light theme support
- Real-time Chat: Instant responses with typing indicators
- File Upload: Drag-and-drop with progress tracking
- Source Citations: Clickable references to source documents
- Mobile Responsive: Works seamlessly on all device sizes
# Production build
docker-compose -f docker-compose.prod.yml up -d
# With SSL termination
docker-compose -f docker-compose.prod.yml -f docker-compose.ssl.yml up -d- Development: Auto-reload, debug logging, CORS enabled
- Production: Optimized builds, security headers, log aggregation
- Testing: Isolated databases, mock services, coverage reporting
- Health check endpoints for all services
- Structured logging with correlation IDs
- Performance metrics collection
- Error tracking and alerting
- Database query optimization
- Implement horizontal scaling with load balancers
- Add message queues (Celery + RabbitMQ) for async document processing
- Implement database read replicas and connection pooling
- Add CDN for frontend static assets and file storage
- Multi-language document support with language detection
- Document summarization and automatic tagging
- Advanced retrieval strategies (hybrid search, re-ranking)
- Custom fine-tuned models for domain-specific use cases
- Conversation memory and context persistence
- OAuth2/SSO integration (Google, Microsoft, SAML)
- Role-based access control (RBAC) with granular permissions
- Data encryption at rest and in transit
- Audit logging and compliance reporting (GDPR, HIPAA)
- API rate limiting and DDoS protection
- Implement GraphQL for efficient data fetching
- Add full-text search capabilities with Elasticsearch
- Implement smart caching strategies with cache invalidation
- Database sharding for large-scale deployments
- Optimize embedding models for faster inference
- Kubernetes deployment with auto-scaling
- Comprehensive monitoring with Prometheus + Grafana
- Automated backup and disaster recovery procedures
- Blue-green deployments with automated rollbacks
- Infrastructure as Code (Terraform/Pulumi)
- Fork the repository
- Create a 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
This project is licensed under the MIT License - see the LICENSE file for details.
Built with β€οΈ using FastAPI, React, and modern AI technologies# RAG-Application