This is the production-ready refactor of rag-bot-chroma, introducing a real separation between frontend (UI) and backend (logic) using Streamlit and FastAPI respectively. This modular architecture helps in scaling, extending, and deploying the bot in real-world environments.
🔗 Helpful Links
| Feature | Version 2 | Version 3 |
|---|---|---|
| Codebase | One Streamlit app | Split into client/ + server/ |
| PDF Upload | In Streamlit | Async FastAPI API |
| Chat | In Streamlit | Calls /chat API |
| Vectorstore | In UI | Controlled by backend |
| Model Options | Static | Dynamically fetched |
| Inspector | In sidebar | Main panel toggle |
| Splitting | RecursiveTextSplitter |
TokenTextSplitter |
| UX | Crude | Responsive, clear, downloadable |
| Extendability | Hard | Easy to plug new LLMs, tools |
- 📁 Upload multiple PDFs and chat with them
- 🔌 Choose from Groq or Gemini as LLM providers
- 🔎 Query inspector for vectorstore transparency
- 🧠 RAG with LangChain + ChromaDB
- 📦 Streamlit frontend, FastAPI backend
- 🧪 Token-based chunking for LLM precision
- 💬 Downloadable chat history
- 🧰 Tools for reset, undo, clear
- 🌐 Fully API-driven interaction
🛠️ Tech Stack
- Frontend: Streamlit
- Backend: FastAPI
- LLMs: Groq & Gemini via LangChain
- Vector DB: ChromaDB
- Embeddings: HuggingFace & Google GenAI
- Chunking: TokenTextSplitter (was RecursiveCharacterTextSplitter)
- Parsing: PyPDF
- Orchestration: LangChain Retrieval Chain
git clone https://github.com/Zlash65/rag-bot-fastapi.git
cd rag-bot-fastapiSetup Virtual Environment:
python3 -m venv venv
source venv/bin/activateInstall frontend:
cd client
pip3 install -r requirements.txtInstall backend:
cd ../server
pip3 install -r requirements.txt- Groq API key from console.groq.com
- Google Gemini API key from ai.google.dev
Create a .env file:
GROQ_API_KEY=your-groq-key
GOOGLE_API_KEY=your-google-keyStart FastAPI backend:
# Terminal 1
cd server
uvicorn main:app --reloadStart Streamlit frontend:
# Terminal 2
cd client
streamlit run app.py📁 Project Structure
rag-bot-v3/
├── client/ # Streamlit Frontend
│ ├── app.py # Main Streamlit entrypoint
│ ├── components/ # UI modules
│ │ ├── chat.py
│ │ ├── inspector.py
│ │ └── sidebar.py
│ ├── state/
│ │ └── session.py # Session state manager
│ ├── utils/
│ │ ├── api.py # Talks to backend
│ │ ├── config.py # API_URL and config values
│ │ └── helpers.py # API wrappers for frontend
│ ├── requirements.txt
│ └── README.md
├── server/ # FastAPI Backend
│ ├── api/
│ │ ├── routes.py # API endpoints
│ │ └── schemas.py # Pydantic schemas for I/O
│ ├── core/
│ │ ├── document_processor.py # Handles PDF validation and chunking
│ │ ├── llm_chain_factory.py # Builds LLM chains and prompts
│ │ └── vector_database.py # Embeddings + ChromaDB ops
│ ├── config/
│ │ └── settings.py # App config, model provider setup
│ ├── utils/
│ │ └── logger.py # Logging setup
│ ├── main.py # FastAPI app entrypoint
│ ├── requirements.txt
│ └── README.md
├── README.md # Root README (overview + instructions)
├── .gitignore👓 Different Views
| View | Description |
|---|---|
| 💬 Chat | Renders chat bubbles, input box, and chat history download |
| 🔬 Inspector | Renders inspector to test vectorstore responses |
🧼 Tools Panel
| Button | Function |
|---|---|
| 🔄 Reset | Clears session state and reruns app |
| 🧹 Clear Chat | Clears chat + PDF submission |
| ↩️ Undo | Removes last question/response |
📦 Download Chat History
Chat history is saved in the session state and can be exported as a CSV with the following columns:
| Question | Answer | Model Provider | Model Name | PDF File | Timestamp |
|---|---|---|---|---|---|
| What is this PDF about? | This PDF explains... | Groq | llama3-70b-8192 | file1.pdf, file2.pdf | 2025-07-03 21:00:00 |
🙏 Acknowledgements
Start from the basics: 👉 Version 1 - rag-bot-basic
Understand modular design: 👉 Version 2 - rag-bot-chroma
Then return here for real-world patterns.
Happy building! 🛠️


