AI Bank Statement Document Automation By LLM model and Personal Finanical Analysis
Jupyter Notebook
627
82 commits
updated Aug 2, 2026
Intelligent document automation for bank statements — Extract, structure, analyze, and query financial data from PDFs using YOLO + OCR + LLM, with parallel agent harnesses (CrewAI, Deep Agents, Hermes) and local LLMs (LM Studio / Ollama).
acompletion)reasoning_contentWhen using local models via LM Studio or Ollama:
instructor if needed.| Component | Technology |
|---|---|
| API | FastAPI, SQLAlchemy 2.0 (async), Alembic, Pydantic v2 |
| LLM Orchestration | LiteLLM (LM Studio, Ollama, OpenAI, DeepSeek, etc.) |
| Agent Frameworks | CrewAI + Skills · Deep Agents (LangGraph) · Hermes (Docker sandbox) |
| Document Processing | PyMuPDF, YOLO, OCR |
| Vector Database | Qdrant, Chroma |
| RAG | LangChain + PII redaction |
| Async Tasks | Celery + Redis |
| Database | PostgreSQL 16 |
| GPU (optional) | NVIDIA Container Toolkit, PyTorch 2.11+cu128 |
| Frontend | React 18, TypeScript 5, Vite 5, TailwindCSS 3 (SPA on :80) |
| Tracing | MLflow (CrewAI path) |
AI-Bank-Statement-Document-Automation/
├── agents/ # Multi-harness agents (experimental)
│ ├── README.md
│ ├── crewai/ # Skills snapshot + pointer to baseline
│ ├── deep-agents/ # deepagents SDK, tools, tests, E2E
│ │ ├── run_e2e.py
│ │ ├── agent.py
│ │ ├── tools/
│ │ ├── skills/
│ │ └── tests/
│ └── hermes/ # Docker-sandboxed Hermes profile
│ ├── config.yaml
│ ├── scripts/
│ └── skills/
├── api/ # FastAPI backend (full-stack v1)
│ ├── app/
│ │ ├── agents/ # Agent adapters (CrewAI, DeepAgents)
│ │ │ ├── crewai/
│ │ │ └── registry.py
│ │ ├── api/ # REST endpoints (auth, llm, documents, agent_runs)
│ │ ├── core/ # Security (JWT + bcrypt), deps
│ │ ├── db/ # SQLAlchemy session + models
│ │ ├── models/ # SQLAlchemy ORM models
│ │ ├── schemas/ # Pydantic v2 request/response schemas
│ │ ├── tests/ # pytest + pytest-asyncio
│ │ ├── worker/ # Celery tasks + runner
│ │ ├── config.py # pydantic-settings env loader
│ │ └── main.py # FastAPI application entrypoint
│ ├── alembic/ # Database migrations
│ ├── config/ # LLM provider catalog (YAML)
│ └── requirements.txt # Pinned API dependencies
├── backend/
│ └── app/
│ ├── core/
│ │ └── ai_agent_skills_dev.ipynb # CrewAI main notebook
│ └── skills/ # Live CrewAI skills (shared via namespace pkg)
│ ├── bank-statement-parsing/
│ ├── financial-analysis/
│ ├── pii-handling/
│ ├── rag-query-handling/
│ └── output-format/
├── infra/ # Docker compose + Kubernetes manifests
│ ├── api.Dockerfile # API & Worker image
│ ├── docker-compose.yml # PostgreSQL, Redis, Qdrant, API, Worker, Web
│ ├── docker-compose.override.yml # Dev bind-mounts
│ ├── .env.example # Environment template
│ └── k8s/
├── web/ # React 18 + Vite 5 SPA
├── data/
│ ├── bank-statement-document/ # Sample PDFs (e.g. Dummy-Bank-Statement.pdf)
│ ├── uploads/
│ └── ...
├── docs/
│ ├── guides/
│ │ ├── multi-harness-agents-guide.md
│ │ └── full-stack-app-guide.md
│ └── superpowers/
│ ├── specs/ # Design docs
│ └── plans/ # Implementation plans
├── requirements.txt # Root / CrewAI stack
└── README.md
Parallel frameworks for the same bank-statement workflow. Shared inputs live in data/. Each harness has its own skill copies (no auto-sync).
| Harness | Path | Skills | How to run |
|---|---|---|---|
| CrewAI (baseline) | backend/app/core/ + agents/crewai/ | CrewAI Skills | Jupyter notebook |
| Deep Agents | agents/deep-agents/ | agentskills.io | Local .venv + run_e2e.py |
| Hermes | agents/hermes/ | agentskills.io | Hermes CLI + Docker only |
Deep Agents deterministic pipeline — extract PDF, redact PII, store vectors, RAG answer:
cd agents/deep-agents
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
PYTHONPATH=. pytest tests/ -v
PYTHONPATH=. python run_e2e.py \
--pdf ../../data/bank-statement-document/Dummy-Bank-Statement.pdf \
--question "What amounts appear in the statement?" \
--mode pipeline
docs/guides/multi-harness-agents-guide.md — setup, use, and test for all three harnesses, verification checklist, and troubleshooting.
Also see:
git clone https://github.com/johnsonhk88/AI-Bank-Statement-Document-Automation-By-LLM-And-Personal-Finanical-Analysis-Prediction.git
cd AI-Bank-Statement-Document-Automation-By-LLM-And-Personal-Finanical-Analysis-Prediction
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
http://localhost:1234jupyter notebook backend/app/core/ai_agent_skills_dev.ipynb
| Goal | Start here |
|---|---|
| Offline tools + tests | Guide § Deep Agents |
| CrewAI notebook | Steps 1–3 above |
| Docker-sandboxed agent | Guide § Hermes |
llm = LLM(
model="openai/qwen2.5-14b-instruct", # Use 9B+ model
base_url="http://localhost:1234/v1",
api_key="lm-studio",
temperature=0.6,
max_tokens=2048,
)
from litellm import acompletion
response = await acompletion(
model="openai/your-model",
base_url="http://localhost:1234/v1",
api_key="lm-studio",
messages=[{"role": "user", "content": prompt}],
)
MLflow can trace LLM calls, tools, and CrewAI task execution:
import mlflow
mlflow.crewai.autolog()
mlflow.litellm.autolog()
View traces in the MLflow UI after running the notebook.
The full-stack app wraps the three agent harnesses (CrewAI, Deep Agents, Hermes) behind a typed FastAPI + React frontend, with PostgreSQL, Qdrant, and Celery for async background processing.
DOCKER_BUILDKIT=1)# 1. Configure environment
cp infra/.env.example infra/.env
# 2. Generate JWT secret and admin password hash
python -c "import secrets; print(secrets.token_urlsafe(32))" # → JWT_SECRET
python -c "import bcrypt; print(bcrypt.hashpw(b'your-password', bcrypt.gensalt()).decode())" # → ADMIN_PASSWORD_HASH
# 3. Edit infra/.env — fill in JWT_SECRET and ADMIN_PASSWORD_HASH.
# IMPORTANT: bcrypt hashes contain $ — escape them as $$ in .env:
# ADMIN_PASSWORD_HASH=$$2b$$12$$...
# (Docker Compose interprets $ as a variable reference.)
# 4. Start everything (prod profile: PostgreSQL + Redis + Qdrant + API + Worker + Nginx on :80)
cd infra && DOCKER_BUILDKIT=1 docker compose --profile prod up -d --build
# Open http://localhost
# 5. For development (API with reload + Vite HMR on :5173):
cd infra && docker compose up -d # backend services
cd web && npm install && npm run dev # frontend dev server
To use an NVIDIA GPU inside containers:
# 1. Install NVIDIA Container Toolkit (Ubuntu/Debian)
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \
sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update && sudo apt-get install -y nvidia-docker2
sudo systemctl restart docker
# 2. Verify GPU access
docker run --rm --gpus all nvidia/cuda:12.2.1-base-ubuntu22.04 nvidia-smi
# 3. Build and run — the Dockerfile installs the correct GPU PyTorch wheel
# (torch --index-url https://download.pytorch.org/whl/cu128 — matches Blackwell).
# GPU devices are requested via deploy.resources.reservations.devices in docker-compose.yml.
cd infra && DOCKER_BUILDKIT=1 docker compose --profile prod up -d --build
# 4. Verify PyTorch sees the GPU inside the container
docker compose exec api python -c "import torch; print(torch.cuda.is_available(), torch.cuda.get_device_name(0))"
Note: Experiment code in
backend/,agents/,frontend/streamlit_app/,notebooks/,yolo-base-layout-analysis/is untouched by v1.
api/app/__init__.py is deliberately absent — app/ is a PEP 420 implicit namespace package. Python automatically merges api/app/ and backend/app/ so app.skills resolves from backend/app/skills/ without symlinks.bcrypt<4.1 because passlib 1.7.4 is incompatible with bcrypt ≥ 4.1 (bcrypt.__about__ removed). If upgrading passlib, retest login flow./proc/net/tcp instead of curl because the qdrant/qdrant minimal image ships without curl or wget.cd /app/api before starting Celery (PYTHONPATH alone doesn't add the api directory to Python's import search path for absolute app.* imports).This project is licensed under the Apache License 2.0.
Made with care for smarter personal finance automation in Hong Kong.
If you find this project useful, please consider giving it a star.
221 followers · starred Dec 2024
AI Bank Statement Document Automation By LLM model and Personal Finanical Analysis
Jupyter Notebook
627
82 commits
updated Aug 2, 2026
Intelligent document automation for bank statements — Extract, structure, analyze, and query financial data from PDFs using YOLO + OCR + LLM, with parallel agent harnesses (CrewAI, Deep Agents, Hermes) and local LLMs (LM Studio / Ollama).
acompletion)reasoning_contentWhen using local models via LM Studio or Ollama:
instructor if needed.| Component | Technology |
|---|---|
| API | FastAPI, SQLAlchemy 2.0 (async), Alembic, Pydantic v2 |
| LLM Orchestration | LiteLLM (LM Studio, Ollama, OpenAI, DeepSeek, etc.) |
| Agent Frameworks | CrewAI + Skills · Deep Agents (LangGraph) · Hermes (Docker sandbox) |
| Document Processing | PyMuPDF, YOLO, OCR |
| Vector Database | Qdrant, Chroma |
| RAG | LangChain + PII redaction |
| Async Tasks | Celery + Redis |
| Database | PostgreSQL 16 |
| GPU (optional) | NVIDIA Container Toolkit, PyTorch 2.11+cu128 |
| Frontend | React 18, TypeScript 5, Vite 5, TailwindCSS 3 (SPA on :80) |
| Tracing | MLflow (CrewAI path) |
AI-Bank-Statement-Document-Automation/
├── agents/ # Multi-harness agents (experimental)
│ ├── README.md
│ ├── crewai/ # Skills snapshot + pointer to baseline
│ ├── deep-agents/ # deepagents SDK, tools, tests, E2E
│ │ ├── run_e2e.py
│ │ ├── agent.py
│ │ ├── tools/
│ │ ├── skills/
│ │ └── tests/
│ └── hermes/ # Docker-sandboxed Hermes profile
│ ├── config.yaml
│ ├── scripts/
│ └── skills/
├── api/ # FastAPI backend (full-stack v1)
│ ├── app/
│ │ ├── agents/ # Agent adapters (CrewAI, DeepAgents)
│ │ │ ├── crewai/
│ │ │ └── registry.py
│ │ ├── api/ # REST endpoints (auth, llm, documents, agent_runs)
│ │ ├── core/ # Security (JWT + bcrypt), deps
│ │ ├── db/ # SQLAlchemy session + models
│ │ ├── models/ # SQLAlchemy ORM models
│ │ ├── schemas/ # Pydantic v2 request/response schemas
│ │ ├── tests/ # pytest + pytest-asyncio
│ │ ├── worker/ # Celery tasks + runner
│ │ ├── config.py # pydantic-settings env loader
│ │ └── main.py # FastAPI application entrypoint
│ ├── alembic/ # Database migrations
│ ├── config/ # LLM provider catalog (YAML)
│ └── requirements.txt # Pinned API dependencies
├── backend/
│ └── app/
│ ├── core/
│ │ └── ai_agent_skills_dev.ipynb # CrewAI main notebook
│ └── skills/ # Live CrewAI skills (shared via namespace pkg)
│ ├── bank-statement-parsing/
│ ├── financial-analysis/
│ ├── pii-handling/
│ ├── rag-query-handling/
│ └── output-format/
├── infra/ # Docker compose + Kubernetes manifests
│ ├── api.Dockerfile # API & Worker image
│ ├── docker-compose.yml # PostgreSQL, Redis, Qdrant, API, Worker, Web
│ ├── docker-compose.override.yml # Dev bind-mounts
│ ├── .env.example # Environment template
│ └── k8s/
├── web/ # React 18 + Vite 5 SPA
├── data/
│ ├── bank-statement-document/ # Sample PDFs (e.g. Dummy-Bank-Statement.pdf)
│ ├── uploads/
│ └── ...
├── docs/
│ ├── guides/
│ │ ├── multi-harness-agents-guide.md
│ │ └── full-stack-app-guide.md
│ └── superpowers/
│ ├── specs/ # Design docs
│ └── plans/ # Implementation plans
├── requirements.txt # Root / CrewAI stack
└── README.md
Parallel frameworks for the same bank-statement workflow. Shared inputs live in data/. Each harness has its own skill copies (no auto-sync).
| Harness | Path | Skills | How to run |
|---|---|---|---|
| CrewAI (baseline) | backend/app/core/ + agents/crewai/ | CrewAI Skills | Jupyter notebook |
| Deep Agents | agents/deep-agents/ | agentskills.io | Local .venv + run_e2e.py |
| Hermes | agents/hermes/ | agentskills.io | Hermes CLI + Docker only |
Deep Agents deterministic pipeline — extract PDF, redact PII, store vectors, RAG answer:
cd agents/deep-agents
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
PYTHONPATH=. pytest tests/ -v
PYTHONPATH=. python run_e2e.py \
--pdf ../../data/bank-statement-document/Dummy-Bank-Statement.pdf \
--question "What amounts appear in the statement?" \
--mode pipeline
docs/guides/multi-harness-agents-guide.md — setup, use, and test for all three harnesses, verification checklist, and troubleshooting.
Also see:
git clone https://github.com/johnsonhk88/AI-Bank-Statement-Document-Automation-By-LLM-And-Personal-Finanical-Analysis-Prediction.git
cd AI-Bank-Statement-Document-Automation-By-LLM-And-Personal-Finanical-Analysis-Prediction
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
http://localhost:1234jupyter notebook backend/app/core/ai_agent_skills_dev.ipynb
| Goal | Start here |
|---|---|
| Offline tools + tests | Guide § Deep Agents |
| CrewAI notebook | Steps 1–3 above |
| Docker-sandboxed agent | Guide § Hermes |
llm = LLM(
model="openai/qwen2.5-14b-instruct", # Use 9B+ model
base_url="http://localhost:1234/v1",
api_key="lm-studio",
temperature=0.6,
max_tokens=2048,
)
from litellm import acompletion
response = await acompletion(
model="openai/your-model",
base_url="http://localhost:1234/v1",
api_key="lm-studio",
messages=[{"role": "user", "content": prompt}],
)
MLflow can trace LLM calls, tools, and CrewAI task execution:
import mlflow
mlflow.crewai.autolog()
mlflow.litellm.autolog()
View traces in the MLflow UI after running the notebook.
The full-stack app wraps the three agent harnesses (CrewAI, Deep Agents, Hermes) behind a typed FastAPI + React frontend, with PostgreSQL, Qdrant, and Celery for async background processing.
DOCKER_BUILDKIT=1)# 1. Configure environment
cp infra/.env.example infra/.env
# 2. Generate JWT secret and admin password hash
python -c "import secrets; print(secrets.token_urlsafe(32))" # → JWT_SECRET
python -c "import bcrypt; print(bcrypt.hashpw(b'your-password', bcrypt.gensalt()).decode())" # → ADMIN_PASSWORD_HASH
# 3. Edit infra/.env — fill in JWT_SECRET and ADMIN_PASSWORD_HASH.
# IMPORTANT: bcrypt hashes contain $ — escape them as $$ in .env:
# ADMIN_PASSWORD_HASH=$$2b$$12$$...
# (Docker Compose interprets $ as a variable reference.)
# 4. Start everything (prod profile: PostgreSQL + Redis + Qdrant + API + Worker + Nginx on :80)
cd infra && DOCKER_BUILDKIT=1 docker compose --profile prod up -d --build
# Open http://localhost
# 5. For development (API with reload + Vite HMR on :5173):
cd infra && docker compose up -d # backend services
cd web && npm install && npm run dev # frontend dev server
To use an NVIDIA GPU inside containers:
# 1. Install NVIDIA Container Toolkit (Ubuntu/Debian)
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \
sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update && sudo apt-get install -y nvidia-docker2
sudo systemctl restart docker
# 2. Verify GPU access
docker run --rm --gpus all nvidia/cuda:12.2.1-base-ubuntu22.04 nvidia-smi
# 3. Build and run — the Dockerfile installs the correct GPU PyTorch wheel
# (torch --index-url https://download.pytorch.org/whl/cu128 — matches Blackwell).
# GPU devices are requested via deploy.resources.reservations.devices in docker-compose.yml.
cd infra && DOCKER_BUILDKIT=1 docker compose --profile prod up -d --build
# 4. Verify PyTorch sees the GPU inside the container
docker compose exec api python -c "import torch; print(torch.cuda.is_available(), torch.cuda.get_device_name(0))"
Note: Experiment code in
backend/,agents/,frontend/streamlit_app/,notebooks/,yolo-base-layout-analysis/is untouched by v1.
api/app/__init__.py is deliberately absent — app/ is a PEP 420 implicit namespace package. Python automatically merges api/app/ and backend/app/ so app.skills resolves from backend/app/skills/ without symlinks.bcrypt<4.1 because passlib 1.7.4 is incompatible with bcrypt ≥ 4.1 (bcrypt.__about__ removed). If upgrading passlib, retest login flow./proc/net/tcp instead of curl because the qdrant/qdrant minimal image ships without curl or wget.cd /app/api before starting Celery (PYTHONPATH alone doesn't add the api directory to Python's import search path for absolute app.* imports).This project is licensed under the Apache License 2.0.
Made with care for smarter personal finance automation in Hong Kong.
If you find this project useful, please consider giving it a star.
221 followers · starred Dec 2024