View on GitHub

RAG Banking Assistant

Production-ready Retrieval-Augmented Generation system for banking question answering.

🏦 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:


▢️ 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:

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:

Run

docker compose up -d redis

Verify

docker ps

πŸ“ˆ Monitoring

Monitoring stack includes

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


🀝 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


πŸ™ Acknowledgements

Special thanks to: