A production-ready Retrieval-Augmented Generation (RAG) application built with FastAPI, React, and LangChain. ContextAI transforms how you interact with documents through intelligent conversation and streaming responses.
- 📄 PDF Document Upload & Processing: Upload and process PDF documents for Q&A
- 🧠 Conversational Memory: Maintains context across conversations using history-aware retrieval
- ⚡ Streaming Responses: Real-time typewriter effect like ChatGPT
- 🎯 Intelligent Question Reformulation: Automatically reformulates follow-up questions based on chat history
- 🔍 Vector Search: Uses FAISS for efficient semantic search
- 🌐 Modern Tech Stack: FastAPI backend, React frontend with TypeScript
- FastAPI - Modern Python web framework
- LangChain - LLM orchestration and RAG implementation
- Groq - Fast LLM inference
- FAISS - Vector database for document search
- HuggingFace - Embeddings model
- React 19 - Modern React with hooks
- TypeScript - Type-safe development
- Vite - Fast development and build tool
- Tailwind CSS - Utility-first CSS framework
cd backend
python -m venv venv
source venv/bin/activate # Windows: .\venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env # Add your GROQ_API_KEY
python main.pycd frontend
npm install
npm run dev- Implements history-aware retrieval for context preservation
- Automatically reformulates vague questions ("what's the first one about?")
- Maintains conversation flow across multiple exchanges
- Server-Sent Events (SSE) for real-time response streaming
- Dual endpoints:
/chat(instant) and/chat/stream(typewriter effect) - Smooth user experience with progressive content loading
- Environment-based configuration
- CORS security settings
- Error handling and logging
- Scalable deployment setup
Note: Free tier services may take 30 seconds to wake up from sleep. This is normal for portfolio projects.
Current Status: Groq API is experiencing temporary outages (Nov 18, 2025). The application architecture and deployment are fully functional - this demonstrates real-world API reliability considerations.
├── backend/
│ ├── main.py # FastAPI application
│ ├── requirements.txt # Python dependencies
│ └── .env.example # Environment template
└── frontend/
├── src/
│ ├── components/ # React components
│ ├── hooks/ # Custom hooks
│ └── api/ # API client
└── package.json # Node dependencies
Deployed on Render (Free Tier):
- Backend: Web Service with Python runtime
- Frontend: Static Site with automatic builds
- Features: Auto-deployments from GitHub, built-in SSL, environment variables
- Fork this repository
- Connect to Render.com
- Deploy backend as Web Service (
backenddirectory) - Deploy frontend as Static Site (
frontenddirectory) - Add environment variables (GROQ_API_KEY)
MIT License - feel free to use for your projects!
Built by Faraz Mirza - Showcasing modern RAG implementation with conversational AI