A production-ready Retrieval-Augmented Generation (RAG) system for intelligent document question-answering, powered by Groqβs ultra-fast LLM inference.
π₯ Live Demo: https://rag-document-analyzer.vercel.app
π API Docs (Swagger): https://rag-document-analyzer.onrender.com/docs
π Report Bug: https://github.com/Emart29/rag-document-analyzer/issues
RAG Document Analyzer allows users to upload PDF documents and ask natural-language questions while receiving accurate, source-cited answers.
It combines semantic search + LLM reasoning for fast, reliable document intelligence.
Built with:
- React + Vite (Frontend)
- FastAPI (Backend)
- Groq (Llama 3.1 70B) for lightning-fast inference
- ChromaDB for vector similarity search
- π PDF Document Processing: Upload and process PDFs with intelligent text chunking
- π§ AI-Powered Q&A: Ask natural language questions and get accurate answers
- π Semantic Search: Vector-based similarity search using ChromaDB
- π Source Citations: Every answer includes relevant document excerpts with page numbers
- π¬ Conversation History: Maintains context across multiple questions
- β‘ Lightning Fast: Powered by Groq's ultra-fast LLM inference (500+ tokens/sec)
- Beautiful React Interface: Built with Vite, TailwindCSS, and shadcn/ui
- Responsive Design: Works seamlessly across devices
- Real-time Updates: Live upload progress and query processing
- Dark Mode Support: Eye-friendly interface (if implemented)
- Drag & Drop: Intuitive document upload experience
- Production-Ready: Comprehensive error handling and validation
- Scalable Architecture: Modular, maintainable codebase
- API Documentation: Auto-generated Swagger/OpenAPI docs
- Type Safety: Pydantic models for request/response validation
- Performance Optimized: Efficient chunking, batching, and caching
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β React Frontend (Vite) β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Document β β Chat β β Source β β
β β Upload β β Interface β β Citations β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ
β REST API (Axios)
ββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββ
β FastAPI Backend β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β RAG Engine (Orchestrator) β β
β ββββ¬βββββββββββββ¬βββββββββββββ¬βββββββββββββ¬ββββββββββββ β
β β β β β β
β ββββΌββββ βββββΌββββ βββββΌβββββ βββββΌββββββ β
β β PDF β β Groq β βSentenceβ β Chroma β β
β βProcesβ β API β βTransformβ β DB β β
β βsor β β(LLM) β β (Embed)β β(Vector) β β
β ββββββββ βββββββββ ββββββββββ βββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Python 3.8+
- Node.js 18+
- Groq API Key (Get free key)
- 8GB RAM minimum
- 2GB free disk space
git clone https://github.com/Emart29/rag-document-analyzer.git
cd rag-document-analyzer# Navigate to backend
cd backend
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Configure environment
cp .env.example .env
# Edit .env and add your GROQ_API_KEY
# Start backend server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000Backend will start on: http://localhost:8000
API Documentation: http://localhost:8000/docs
# Open new terminal, navigate to frontend
cd frontend
# Install dependencies
npm install
# Start development server
npm run devFrontend will start on: http://localhost:5173
- Click the Upload tab in the sidebar
- Drag & drop a PDF or click Browse
- Wait for processing (10-30 seconds)
- Document appears in the Documents list
- Select documents (optional - searches all if none selected)
- Type your question in the chat input
- Press Enter or click Send
- Get AI-generated answer with source citations in 2-3 seconds
"What are the main findings of this research?"
"Summarize the key points from page 5"
"Compare the methodologies discussed in the documents"
"What does the author say about machine learning?"
| Technology | Purpose |
|---|---|
| React 18 | UI framework |
| Vite | Build tool & dev server |
| TailwindCSS | Styling |
| shadcn/ui | UI components |
| Tanstack Query | Server state management |
| Axios | HTTP client |
| React Markdown | Answer rendering |
| Lucide React | Icons |
| Technology | Purpose |
|---|---|
| FastAPI | REST API framework |
| Groq API | LLM inference (Llama 3.1 70B) |
| ChromaDB | Vector database |
| Sentence Transformers | Text embeddings |
| PyPDF2 & pdfplumber | PDF text extraction |
| Pydantic | Data validation |
| Uvicorn | ASGI server |
Tested on: Dell Latitude 5400 (i5-8th gen, 8GB RAM)
| Operation | Time | Notes |
|---|---|---|
| Document Upload | 10-30s | 5-page PDF |
| Question Answering | 1-3s | Including retrieval & generation |
| Semantic Search | <100ms | ChromaDB query |
| Memory Usage | ~600MB | Backend runtime |
| LLM Inference | 500+ tokens/sec | Via Groq |
# Install Vercel CLI
npm i -g vercel
# Navigate to frontend folder
cd frontend
# Deploy
vercel
# Follow prompts, set environment variable:
# VITE_API_URL=https://your-backend-url.onrender.com- Create
render.yamlin project root:
services:
- type: web
name: rag-backend
env: python
region: oregon
plan: free
buildCommand: |
cd backend
pip install -r requirements.txt
startCommand: cd backend && uvicorn app.main:app --host 0.0.0.0 --port $PORT
envVars:
- key: GROQ_API_KEY
sync: false
- key: PYTHON_VERSION
value: 3.11.0- Push to GitHub
- Connect repo to Render.com
- Add
GROQ_API_KEYenvironment variable - Deploy!
Your app will be live at:
- Frontend:
https://your-app.vercel.app - Backend API:
https://your-api.onrender.com
rag-document-analyzer/
βββ backend/
β βββ app/
β β βββ main.py # FastAPI application
β β βββ models.py # Pydantic models
β β βββ routers/ # API endpoints
β β β βββ documents.py # Document operations
β β β βββ query.py # Q&A endpoints
β β β βββ system.py # Health & stats
β β βββ services/ # Business logic
β β β βββ rag_engine.py # RAG orchestration
β β β βββ groq_client.py # LLM interface
β β β βββ embeddings.py # Vector generation
β β β βββ pdf_processor.py # Document processing
β β βββ database/
β β βββ chroma_db.py # Vector database
β βββ requirements.txt
β βββ .env
β βββ README.md
βββ frontend/
β βββ src/
β β βββ components/ # React components
β β β βββ Header.jsx
β β β βββ Sidebar.jsx
β β β βββ ChatInterface.jsx
β β β βββ DocumentList.jsx
β β β βββ ui/ # shadcn components
β β βββ services/
β β β βββ api.js # API client
β β βββ App.jsx
β β βββ main.jsx
β βββ package.json
β βββ tailwind.config.js
β βββ README.md
βββ README.md # This file
βββ LICENSE
cd backend
# Test individual components
python app/services/groq_client.py
python app/services/embeddings.py
python app/database/chroma_db.py
python app/services/rag_engine.py
# API documentation
# Visit: http://localhost:8000/docscd frontend
# Run development server
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview- β Environment variables for sensitive data
- β Input validation with Pydantic
- β CORS configuration for frontend
- β File size and type validation
- β Error handling and logging
- β API rate limiting (recommended for production)
β οΈ Add authentication for production useβ οΈ Implement user management for multi-tenant
Issue: "GROQ_API_KEY not found"
# Solution: Check .env file
cat backend/.env # Should show GROQ_API_KEY=gsk_...Issue: ChromaDB errors
# Solution: Clear database and restart
rm -rf backend/chroma_db/
# Restart backendIssue: PDF processing fails
# Solution: Install additional dependencies
pip install python-magic-bin # Windows
pip install python-magic # Mac/LinuxIssue: API connection refused
# Solution: Check VITE_API_URL in .env
# Verify backend is running on correct portIssue: Build errors
# Solution: Clear cache and reinstall
rm -rf node_modules package-lock.json
npm install- Multi-format Support: Add .docx, .txt, .md support
- User Authentication: JWT-based auth system
- Multi-tenancy: Per-user document isolation
- Advanced Filters: Filter by date, size, type
- Export Conversations: Download chat history
- Streaming Responses: Real-time token streaming
- Voice Input: Speech-to-text for questions
- Document Summarization: Auto-generate summaries
- Collaborative Sharing: Share documents between users
- Analytics Dashboard: Usage statistics and insights
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Your Name
- LinkedIn: Emmanuel Nwanguma
- GitHub: Emart29
- Groq - Ultra-fast LLM inference platform
- ChromaDB - Open-source embedding database
- FastAPI - Modern Python web framework
- Sentence Transformers - State-of-the-art text embeddings
- shadcn/ui - Beautiful React components
- Vercel - Frontend hosting platform
- Render - Backend hosting platform
β If this project helped you, please give it a star! β
Made with β€οΈ by Emmanuel Nwanguma