Advanced RAG System with Intelligent Agentic Routing
A production-ready document intelligence system that combines Retrieval Augmented Generation (RAG) with intelligent query routing. Built with FastAPI and Streamlit, featuring automatic decision-making between local document search and real-time web search.
- π€ Intelligent Query Routing - Automatically routes between document RAG and web search using LangGraph
- π Multi-Format Support - PDF, DOCX, TXT, CSV document processing
- π Smart Web Scraping - Structured content extraction (headings, paragraphs, lists) with recursive crawling
- π Semantic Search - FAISS vector database with K=3 retrieval optimization
- β‘ Fast Inference - Groq API (Llama 3.3 70B) for <2s response times
- π¬ Interactive Chat - Real-time Streamlit interface with source attribution
- π³ Docker Ready - Containerized deployment with Docker Compose
ββββββββββββββββ βββββββββββββββββββ ββββββββββββββββ
β Streamlit β ββββΊ β FastAPI + RAG β ββββΊ β Groq LLM β
β Frontend β β + LangGraph β β (Llama 3.3) β
ββββββββββββββββ βββββββββββββββββββ ββββββββββββββββ
β
βββββββββββ΄ββββββββββ
βΌ βΌ
ββββββββββββ ββββββββββββ
β FAISS β β Tavily β
β Vector β β Web β
β Search β β Search β
ββββββββββββ ββββββββββββ
Backend:
- FastAPI - High-performance async API
- LangChain & LangGraph - AI orchestration & agentic routing
- FAISS - Vector similarity search
- Groq API - Fast LLM inference
- Tavily API - Real-time web search
Frontend:
- Streamlit - Interactive web UI
AI/ML:
- HuggingFace Transformers (all-MiniLM-L6-v2)
- PyPDF, python-docx - Document processing
- BeautifulSoup4 - Web scraping
# 1. Clone repository
git clone https://github.com/prasanna-nagarale/QueryFoxAi.git
cd QueryFox
# 2. Create environment file
cp .env.example .env
# Add your API keys to .env
# 3. Backend setup
cd backend
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
# 4. Start backend (Terminal 1)
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
# 5. Frontend setup (Terminal 2)
cd ../frontend
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
# 6. Start frontend
streamlit run app.pyAccess: http://localhost:8501
# 1. Clone and configure
git clone https://github.com/prasanna-nagarale/QueryFoxAi.git
cd QueryFox
cp .env.example .env
# Add your API keys to .env
# 2. Start with Docker
docker-compose up --build
# Access:
# Frontend: http://localhost:8501
# Backend API: http://localhost:8000/docsCreate a .env file in the root directory:
GROQ_API_KEY=your_groq_api_key_here
TAVILY_API_KEY=your_tavily_api_key_here- Click "Upload Document"
- Select PDF, DOCX, TXT, or CSV file
- System processes and creates embeddings
- Enter URL in "Scrape Website"
- Set max pages (1-5)
- System extracts structured content
- Type your question in chat
- System automatically routes to RAG or web search
- Receive answer with source attribution
- Response Time: <2 seconds (RAG mode)
- Document Processing: 3-7 seconds (average)
- Retrieval Accuracy: K=3 optimized chunks
- Supported File Size: Up to 10MB
- Web Scraping: 1-5 pages with structured extraction
- Query Analysis - LangGraph analyzes if query needs current info or can use documents
- Intelligent Routing:
- RAG Path: Semantic search in FAISS β Retrieve K=3 chunks β Generate answer
- Web Path: Tavily search β Fetch articles β Synthesize answer
- Response Generation - Groq LLM creates contextual answer with sources
QueryFox/
βββ backend/
β βββ app/
β β βββ main.py # FastAPI application
β β βββ config.py # Configuration
β β βββ core/
β β β βββ rag_engine.py # RAG logic
β β β βββ langgraph_agent.py # Agentic routing
β β β βββ document_processor.py
β β β βββ web_scraper.py
β β β βββ embeddings.py
β β βββ models/
β β βββ schemas.py # Pydantic models
β βββ requirements.txt
β βββ Dockerfile
βββ frontend/
β βββ app.py # Streamlit UI
β βββ requirements.txt
β βββ Dockerfile
βββ docker-compose.yml
βββ .env.example
βββ README.md
| Endpoint | Method | Description |
|---|---|---|
/ |
GET | Health check |
/upload |
POST | Upload and process document |
/scrape |
POST | Scrape and process website |
/query |
POST | Query with intelligent routing |
/docs |
GET | Interactive API documentation |
Full API Docs: http://localhost:8000/docs (when running)
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- LangChain - AI orchestration framework
- Groq - Fast LLM inference
- Tavily - Web search API
- FAISS - Vector search
- Streamlit - UI framework
Prasanna Nagarale
- Email: nagaraleprasanna@gmail.com
- LinkedIn: linkedin.com/in/prasanna-ai
- GitHub: github.com/prasanna-nagarale
- Portfolio: prasanna-nagarale.github.io/prasanna-portfolio
If you find this project useful, please consider giving it a star β
Built with β€οΈ using FastAPI, LangGraph, and Groq