π¦ RAG Banking Assistant
Production-ready Retrieval-Augmented Generation (RAG) system for banking documents powered by FastAPI, ChromaDB, MLflow and Docker.
π Overview
RAG Banking Assistant is a production-ready Retrieval-Augmented Generation system designed for banking knowledge bases.
Instead of relying solely on an LLM, the assistant retrieves relevant banking documents from a vector database before generating answers, ensuring higher accuracy, transparency, and grounded responses.
β¨ Features
| Feature | Description |
|---|---|
| π JWT Authentication | Secure API endpoints |
| π PDF Ingestion | Automatic chunking & preprocessing |
| π Semantic Search | Vector similarity search with ChromaDB |
| π€ RAG Pipeline | Context-aware response generation |
| π MLflow | Experiment tracking |
| π₯ Streamlit | Interactive chat UI |
| π³ Docker | One-command deployment |
| π Monitoring | Prometheus & Grafana |
| β‘ Redis Cache | Faster retrieval |
| π Logging | Structured logs |
π Project Structure
rag-banking-assistant/
β
βββ app/
β βββ api/
β β βββ auth.py
β β βββ routes.py
β β
β βββ core/
β β βββ config.py
β β βββ logger.py
β β βββ security.py
β β
β βββ rag/
β β βββ ingest.py
β β βββ embeddings.py
β β βββ retriever.py
β β βββ pipeline.py
β β βββ generator.py
β β
β βββ models/
β β
β βββ main.py
β
βββ chromadb/
βββ streamlit/
βββ scripts/
βββ monitoring/
βββ tests/
βββ docker-compose.yml
βββ Dockerfile
βββ requirements.txt
βββ .env.example
βββ README.md
π Quick Start
Clone Repository
git clone https://github.com/SobhanAlizadeh/rag-banking-assistant.git
cd rag-banking-assistant
Create Virtual Environment
python -m venv .venv
Linux / macOS
source .venv/bin/activate
Windows
.venv\Scripts\activate
Install Dependencies
pip install -r requirements.txt
Configure Environment
cp .env.example .env
Edit the environment variables before running the application.
π₯ Document Ingestion
Before using the assistant, your banking documents must be indexed into ChromaDB.
python scripts/ingest.py
The ingestion pipeline performs:
- π PDF loading
- βοΈ Smart text chunking
- π§ Embedding generation
- π Vector indexing into ChromaDB
- πΎ Persistent storage
βΆοΈ Running the Application
Start FastAPI
uvicorn app.main:app --reload
Application:
http://localhost:8000
Swagger UI:
http://localhost:8000/docs
ReDoc:
http://localhost:8000/redoc
Start Streamlit
streamlit run streamlit/chat_app.py
Default URL
http://localhost:8501
π³ Docker Deployment
Build all services
docker compose up --build
Run in background
docker compose up -d
Stop containers
docker compose down
Rebuild
docker compose up --build --force-recreate
π§ MLflow Tracking
Start only MLflow
docker compose up -d mlflow
Open
http://localhost:5000
Track:
- Parameters
- Metrics
- Artifacts
- Experiments
- Models
Example
import mlflow
with mlflow.start_run():
mlflow.log_param("chunk_size",512)
mlflow.log_metric("accuracy",0.94)
β‘ Redis Cache
Redis is used for:
- Session cache
- Prompt cache
- Response cache
- Query history
- Rate limiting
Run
docker compose up -d redis
Verify
docker ps
π Monitoring
Monitoring stack includes
- Prometheus
- Grafana
Start
docker compose up -d prometheus grafana
Access
Prometheus
http://localhost:9090
Grafana
http://localhost:3000
Default credentials
admin
admin
π Authentication
Every protected endpoint requires a JWT token.
Example
Authorization:
Bearer YOUR_ACCESS_TOKEN
π‘ API Endpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | /login | User authentication |
| POST | /register | Create user |
| POST | /ask | Ask questions |
| POST | /ingest | Upload new documents |
| GET | /health | Health check |
| GET | /metrics | Prometheus metrics |
βοΈ Environment Variables
Example
APP_NAME=RAG Banking Assistant
DEBUG=True
SECRET_KEY=YOUR_SECRET_KEY
JWT_EXPIRE_MINUTES=60
OPENAI_API_KEY=YOUR_KEY
MODEL_NAME=gpt-4o-mini
CHROMA_DB=chromadb
EMBEDDING_MODEL=sentence-transformers/all-MiniLM-L6-v2
REDIS_HOST=redis
REDIS_PORT=6379
MLFLOW_TRACKING_URI=http://mlflow:5000
π§ͺ Running Tests
Execute all tests
pytest
Verbose
pytest -v
Coverage
pytest --cov=app
Generate HTML report
pytest --cov=app --cov-report=html
π Example Request
curl -X POST http://localhost:8000/ask \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"question":"What is the minimum balance for a savings account?"
}'
π¦ Docker Services
| Service | Port |
|---|---|
| FastAPI | 8000 |
| Streamlit | 8501 |
| MLflow | 5000 |
| Redis | 6379 |
| Prometheus | 9090 |
| Grafana | 3000 |
π§° Tech Stack
β οΈ Troubleshooting
ChromaDB is empty
python scripts/ingest.py
Redis connection failed
Check
docker ps
Verify Redis is running.
MLflow unavailable
Run
docker compose up -d mlflow
API returns 401
Your JWT token has expired.
Authenticate again.
Docker build failed
Rebuild
docker compose build --no-cache
π GitHub Stats
πΊοΈ Roadmap
- RAG pipeline with ChromaDB
- FastAPI backend
- Streamlit UI
- JWT Authentication
- Docker support
- MLflow tracking
- Redis caching
- Kubernetes deployment
- Multi-LLM support (OpenAI, Claude, Local LLMs)
- Role-based access control (RBAC)
- Multi-language answers (FA / EN / AR)
- Advanced reranking model
π€ Contributing
We welcome contributions!
Steps
# 1. Fork the repo
# 2. Clone your fork
git clone https://github.com/SobhanAlizadeh/rag-banking-assistant.git
# 3. Create a branch
git checkout -b feature/new-feature
# 4. Commit changes
git commit -m "Add new feature"
# 5. Push
git push origin feature/new-feature
Then open a Pull Request π
π License
This project is licensed under the MIT License.
MIT License Β© 2026 Sobhan Alizadeh
π¨βπ» Author
Sobhan Alizadeh
AI Engineer Β· Builder of Intelligent Systems Β· RAG & LLM Enthusiast
π Future Improvements
- Vector DB migration to Weaviate / Pinecone
- GPU-accelerated embeddings
- Streaming responses (SSE / WebSocket)
- Fine-tuned banking LLM
- Document OCR support
- Audit logging system
- Enterprise RBAC + SSO
π Acknowledgements
Special thanks to:
- OpenAI for LLM APIs
- FastAPI team
- ChromaDB team
- MLflow project
- Open-source community β€οΈ