A production-style Retrieval-Augmented Generation (RAG) application built with FastAPI, LangChain, Groq, HuggingFace Embeddings, and ChromaDB.
The application allows users to upload PDF documents, generate vector embeddings, store them in a persistent Chroma Vector Database, and chat with the uploaded documents using semantic search.
- 📄 Upload PDF documents
- 📖 Extract text from PDFs
- ✂️ Intelligent document chunking
- 🤗 HuggingFace Embeddings
- 🗄️ Persistent Chroma Vector Database
- 🔍 Semantic Similarity Search
- ⚡ Groq LLM Integration
- 💬 Context-Aware Chat
- 🧠 Conversation Memory
- 📚 Swagger API Documentation
- 📝 Structured Logging
- ⚙️ Environment-based Configuration
- 🚀 FastAPI Backend
- 📦 uv Package Management
Upload PDF
│
▼
PDF Upload API
│
▼
Save PDF File
│
▼
PDF Loader
│
▼
Recursive Text Splitter
│
▼
HuggingFace Embeddings
│
▼
Chroma Vector Database
│
▼
Similarity Search
│
▼
Retrieved Chunks
│
▼
Prompt Template
│
▼
Groq LLM
│
▼
Generated Answer
│
▼
Conversation Memory
DOCU-RAG/
│
├── app/
│ ├── config/
│ │ settings.py
│ │
│ ├── memory/
│ │ chat_memory.py
│ │
│ ├── models/
│ │ request_models.py
│ │ response_models.py
│ │
│ ├── prompts/
│ │ prompt.py
│ │
│ ├── routers/
│ │ chat.py
│ │ health.py
│ │ upload.py
│ │
│ ├── services/
│ │ embedding_service.py
│ │ groq_service.py
│ │ pdf_loader.py
│ │ pdf_service.py
│ │ rag_chain.py
│ │ retriever.py
│ │ text_splitter.py
│ │ vector_store.py
│ │
│ ├── utils/
│ │ logger.py
│ │
│ └── main.py
│
├── chroma_db/
├── uploads/
├── logs/
│
├── tests/
│
├── .env
├── .gitignore
├── pyproject.toml
├── uv.lock
└── README.md
| Category | Technology |
|---|---|
| Backend | FastAPI |
| LLM | Groq |
| Framework | LangChain |
| Embedding Model | HuggingFace Embeddings |
| Vector Database | ChromaDB |
| Document Loader | PyPDFLoader |
| Text Splitter | RecursiveCharacterTextSplitter |
| Package Manager | uv |
| API Documentation | Swagger UI |
| Configuration | Pydantic Settings |
| Logging | Python Logging |
Upload PDF
│
▼
Save PDF
│
▼
Read PDF
│
▼
Split into Chunks
│
▼
Generate Embeddings
│
▼
Store in ChromaDB
│
▼
User Question
│
▼
Generate Query Embedding
│
▼
Similarity Search
│
▼
Retrieve Relevant Chunks
│
▼
Prompt + Context
│
▼
Groq LLM
│
▼
Response
Clone the repository
git clone <repository-url>
cd DOCU-RAGCreate virtual environment
uv venvActivate virtual environment
.venv\Scripts\activatesource .venv/bin/activateInstall dependencies
uv syncCreate a .env file in the project root.
GROQ_API_KEY=your_groq_api_key
EMBEDDING_MODEL=sentence-transformers/all-MiniLM-L6-v2
CHROMA_DB_PATH=./chroma_db
UPLOAD_FOLDER=./uploads
CHUNK_SIZE=1000
CHUNK_OVERLAP=200
TOP_K_RESULTS=5
LLM_MODEL=llama-3.1-8b-instantuv run uvicorn app.main:app --reloadServer
http://127.0.0.1:8000
Swagger UI
http://127.0.0.1:8000/docs
GET /health
POST /upload
Uploads a PDF document for processing.
POST /chat
Example Request
{
"question": "What is Artificial Intelligence?"
}Example Response
{
"answer": "Artificial Intelligence is..."
}PDF
│
▼
Upload
│
▼
PyPDFLoader
│
▼
RecursiveCharacterTextSplitter
│
▼
HuggingFace Embeddings
│
▼
ChromaDB
│
▼
Retriever
│
▼
Prompt Template
│
▼
Groq LLM
│
▼
Generated Answer
- FastAPI
- LangChain
- LangChain Community
- LangChain Groq
- LangChain HuggingFace
- LangChain Chroma
- ChromaDB
- Sentence Transformers
- PyPDF
- Pydantic Settings
- Python Dotenv
- Uvicorn
- Multiple PDF Support
- Source Citation with Page Numbers
- Streaming Responses
- Hybrid Search (BM25 + Vector Search)
- User Authentication
- Conversation Persistence
- Document Deletion API
- Docker Support
- AWS Deployment
- Frontend Integration (React/Next.js)
Kallappa Kabbur