# abhinav-ram/bank-statement-agents architecture

> Architecture diagram of the GitHub repository abhinav-ram/bank-statement-agents, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abhinav-ram/bank-statement-agents
- Repository: https://github.com/abhinav-ram/bank-statement-agents

## Overview

Bank Statement Agents turns uploaded digital or scanned statements into validated, categorized financial data, then answers questions using SQL and hybrid search with transaction citations. The main workflow is upload → parse/OCR → validate and, when needed, human review → store and enrich → index → ask and receive a grounded answer. The README documents capabilities whose detailed implementations were not sampled; those links are cited to the README or left unverified. Graph wiring is supported by the excerpts and SOURCE INDEX, not by inspection of unsampled source.

Main entry points: [`backend/app/graphs/ingestion.py`](https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/graphs/ingestion.py) (Ingestion workflow), [`backend/app/graphs/query.py`](https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/graphs/query.py) (Question workflow), [`frontend/src/api/client.ts`](https://github.com/abhinav-ram/bank-statement-agents/blob/main/frontend/src/api/client.ts) (API client), [`frontend/src/App.tsx`](https://github.com/abhinav-ram/bank-statement-agents/blob/main/frontend/src/App.tsx) (Web interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Statement ingestion"]
  node_backend_api["FastAPI application<br/>[main.py]"]
  node_statement_api["Statement endpoints<br/>[statements.py]"]
  node_job_api["Ingestion jobs<br/>[jobs.py]"]
  node_ingest_graph["Ingestion workflow<br/>[ingestion.py]"]
  node_parser["Statement parser<br/>[digital.py]"]
  node_ocr["OCR engines<br/>[engines.py]"]
  node_extract["Metadata extraction<br/>[extract.py]"]
  node_validation["Balance validation<br/>[validate.py]"]
  node_review["Review contract<br/>[review.py]"]
end

subgraph group_query["Question answering"]
  node_query_graph["Question workflow<br/>[query.py]"]
  node_query_agent["Question planner and answerer<br/>[query.py]"]
  node_sql_tools["SQL query tools<br/>[sql_tools.py]"]
  node_hybrid_search["Hybrid retrieval<br/>[hybrid.py]"]
end

subgraph group_data["Data and intelligence"]
  node_repository[("Statement repository<br/>[repo.py]")]
  node_categorize["Transaction categories<br/>[categorize.py]"]
  node_anomaly["Anomaly detection<br/>[anomaly.py]"]
  node_summarize["Statement summaries<br/>[summarize.py]"]
  node_indexer["Search indexing<br/>[chunks.py]"]
  node_llm["LLM client<br/>[client.py]"]
end

subgraph group_ui["Web application"]
  node_web["Web interface<br/>[App.tsx]"]
  node_api_client["API client<br/>[client.ts]"]
  node_upload_ui["Upload and progress<br/>[Upload.tsx]"]
  node_review_ui["Review screen<br/>[Review.tsx]"]
  node_statement_ui["Statement views<br/>[Overview.tsx]"]
  node_chat_ui["Ask page<br/>[Chat.tsx]"]
end

node_person(("Statement user"))
node_llm_service["LLM provider"]

node_person -->|"uses"| node_web
node_web -->|"routes to"| node_upload_ui
node_web -->|"routes to"| node_statement_ui
node_web -->|"routes to"| node_chat_ui
node_upload_ui -.->|"requests"| node_api_client
node_review_ui -->|"requests"| node_api_client
node_chat_ui -->|"requests"| node_api_client
node_api_client -.->|"calls API"| node_backend_api
node_backend_api -->|"mounts"| node_statement_api
node_backend_api -->|"mounts"| node_job_api
node_statement_api -->|"starts ingestion"| node_ingest_graph
node_job_api -.->|"runs jobs"| node_ingest_graph
node_ingest_graph -->|"parses PDF"| node_parser
node_parser -->|"uses for scans"| node_ocr
node_ingest_graph -->|"extracts details"| node_extract
node_ingest_graph -->|"checks balances"| node_validation
node_ingest_graph -->|"builds review"| node_review
node_review_ui -.->|"submits corrections"| node_statement_api
node_ingest_graph -->|"persists statement"| node_repository
node_ingest_graph -->|"categorizes"| node_categorize
node_ingest_graph -->|"flags anomalies"| node_anomaly
node_ingest_graph -->|"summarizes"| node_summarize
node_ingest_graph -->|"indexes transactions"| node_indexer
node_person -->|"asks question"| node_query_graph
node_query_graph -->|"plans and answers"| node_query_agent
node_query_graph -->|"runs tools"| node_sql_tools
node_query_graph -->|"searches evidence"| node_hybrid_search
node_query_graph -->|"reads statements"| node_repository
node_query_graph -->|"requests completion"| node_llm
node_ingest_graph -.->|"requests completion"| node_llm
node_llm -->|"sends prompts"| node_llm_service
node_query_graph -.->|"serves answer"| node_backend_api
node_statement_ui -.->|"requests statement data"| node_api_client
node_chat_ui -.->|"shows cited answer"| node_person

click node_web "https://github.com/abhinav-ram/bank-statement-agents/blob/main/frontend/src/App.tsx"
click node_api_client "https://github.com/abhinav-ram/bank-statement-agents/blob/main/frontend/src/api/client.ts"
click node_upload_ui "https://github.com/abhinav-ram/bank-statement-agents/blob/main/frontend/src/pages/Upload.tsx"
click node_review_ui "https://github.com/abhinav-ram/bank-statement-agents/blob/main/frontend/src/pages/Review.tsx"
click node_statement_ui "https://github.com/abhinav-ram/bank-statement-agents/blob/main/frontend/src/pages/Overview.tsx"
click node_chat_ui "https://github.com/abhinav-ram/bank-statement-agents/blob/main/frontend/src/pages/Chat.tsx"
click node_backend_api "https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/main.py"
click node_statement_api "https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/api/statements.py"
click node_job_api "https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/api/jobs.py"
click node_ingest_graph "https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/graphs/ingestion.py"
click node_parser "https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/parsing/digital.py"
click node_ocr "https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/ocr/engines.py"
click node_extract "https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/agents/extract.py"
click node_validation "https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/services/validate.py"
click node_review "https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/services/review.py"
click node_repository "https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/db/repo.py"
click node_categorize "https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/agents/categorize.py"
click node_anomaly "https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/services/anomaly.py"
click node_summarize "https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/agents/summarize.py"
click node_indexer "https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/retrieval/chunks.py"
click node_query_graph "https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/graphs/query.py"
click node_query_agent "https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/agents/query.py"
click node_sql_tools "https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/tools/sql_tools.py"
click node_hybrid_search "https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/retrieval/hybrid.py"
click node_llm "https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/llm/client.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_backend_api,node_statement_api,node_job_api,node_ingest_graph,node_parser,node_ocr,node_extract,node_validation,node_review,node_person toneBlue
class node_query_graph,node_query_agent,node_sql_tools,node_hybrid_search toneAmber
class node_repository,node_categorize,node_anomaly,node_summarize,node_indexer,node_llm toneMint
class node_web,node_api_client,node_upload_ui,node_review_ui,node_statement_ui,node_chat_ui toneRose
class node_llm_service toneIndigo
```

## Components

### Statement ingestion

- [FastAPI application](https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/main.py): `backend/app/main.py`
- [Statement endpoints](https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/api/statements.py): `backend/app/api/statements.py`
- [Ingestion jobs](https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/api/jobs.py): `backend/app/api/jobs.py`
- [Ingestion workflow](https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/graphs/ingestion.py): `backend/app/graphs/ingestion.py`
- [Statement parser](https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/parsing/digital.py): `backend/app/parsing/digital.py`
- [OCR engines](https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/ocr/engines.py): `backend/app/ocr/engines.py`
- [Metadata extraction](https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/agents/extract.py): `backend/app/agents/extract.py`
- [Balance validation](https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/services/validate.py): `backend/app/services/validate.py`
- [Review contract](https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/services/review.py): `backend/app/services/review.py`

### Question answering

- [Question workflow](https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/graphs/query.py): `backend/app/graphs/query.py`
- [Question planner and answerer](https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/agents/query.py): `backend/app/agents/query.py`
- [SQL query tools](https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/tools/sql_tools.py): `backend/app/tools/sql_tools.py`
- [Hybrid retrieval](https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/retrieval/hybrid.py): `backend/app/retrieval/hybrid.py`

### Data and intelligence

- [Statement repository](https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/db/repo.py): `backend/app/db/repo.py`
- [Transaction categories](https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/agents/categorize.py): `backend/app/agents/categorize.py`
- [Anomaly detection](https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/services/anomaly.py): `backend/app/services/anomaly.py`
- [Statement summaries](https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/agents/summarize.py): `backend/app/agents/summarize.py`
- [Search indexing](https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/retrieval/chunks.py): `backend/app/retrieval/chunks.py`
- [LLM client](https://github.com/abhinav-ram/bank-statement-agents/blob/main/backend/app/llm/client.py): `backend/app/llm/client.py`

### Web application

- [Web interface](https://github.com/abhinav-ram/bank-statement-agents/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [API client](https://github.com/abhinav-ram/bank-statement-agents/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [Upload and progress](https://github.com/abhinav-ram/bank-statement-agents/blob/main/frontend/src/pages/Upload.tsx): `frontend/src/pages/Upload.tsx`
- [Review screen](https://github.com/abhinav-ram/bank-statement-agents/blob/main/frontend/src/pages/Review.tsx): `frontend/src/pages/Review.tsx`
- [Statement views](https://github.com/abhinav-ram/bank-statement-agents/blob/main/frontend/src/pages/Overview.tsx): `frontend/src/pages/Overview.tsx`
- [Ask page](https://github.com/abhinav-ram/bank-statement-agents/blob/main/frontend/src/pages/Chat.tsx): `frontend/src/pages/Chat.tsx`

### Other components

- **Statement user**
- **LLM provider**

## Connections

- Statement user → Web interface: uses (evidence: `README.md`)
- Web interface → Upload and progress: routes to (evidence: `frontend/src/App.tsx`)
- Web interface → Statement views: routes to (evidence: `frontend/src/App.tsx`)
- Web interface → Ask page: routes to (evidence: `frontend/src/App.tsx`)
- Upload and progress → API client: requests
- Review screen → API client: requests (evidence: `frontend/src/pages/Review.tsx`)
- Ask page → API client: requests (evidence: `frontend/src/pages/Chat.tsx`)
- API client → FastAPI application: calls API
- FastAPI application → Statement endpoints: mounts (evidence: `backend/app/main.py`)
- FastAPI application → Ingestion jobs: mounts (evidence: `backend/app/main.py`)
- Statement endpoints → Ingestion workflow: starts ingestion (evidence: `backend/app/api/statements.py`)
- Ingestion jobs → Ingestion workflow: runs jobs
- Ingestion workflow → Statement parser: parses PDF (evidence: `backend/app/graphs/ingestion.py`)
- Statement parser → OCR engines: uses for scans (evidence: `backend/app/parsing/digital.py`)
- Ingestion workflow → Metadata extraction: extracts details (evidence: `backend/app/graphs/ingestion.py`)
- Ingestion workflow → Balance validation: checks balances (evidence: `backend/app/graphs/ingestion.py`)
- Ingestion workflow → Review contract: builds review (evidence: `backend/app/graphs/ingestion.py`)
- Review screen → Statement endpoints: submits corrections
- Ingestion workflow → Statement repository: persists statement (evidence: `backend/app/graphs/ingestion.py`)
- Ingestion workflow → Transaction categories: categorizes (evidence: `backend/app/graphs/ingestion.py`)
- Ingestion workflow → Anomaly detection: flags anomalies (evidence: `backend/app/graphs/ingestion.py`)
- Ingestion workflow → Statement summaries: summarizes (evidence: `backend/app/graphs/ingestion.py`)
- Ingestion workflow → Search indexing: indexes transactions (evidence: `backend/app/graphs/ingestion.py`)
- Statement user → Question workflow: asks question (evidence: `README.md`)
- Question workflow → Question planner and answerer: plans and answers (evidence: `backend/app/graphs/query.py`)
- Question workflow → SQL query tools: runs tools (evidence: `backend/app/graphs/query.py`)
- Question workflow → Hybrid retrieval: searches evidence (evidence: `backend/app/graphs/query.py`)
- Question workflow → Statement repository: reads statements (evidence: `backend/app/graphs/query.py`)
- Question workflow → LLM client: requests completion (evidence: `backend/app/graphs/query.py`)
- Ingestion workflow → LLM client: requests completion (evidence: `backend/app/graphs/ingestion.py`)
- LLM client → LLM provider: sends prompts (evidence: `backend/app/llm/client.py`)
- Question workflow → FastAPI application: serves answer
- Statement views → API client: requests statement data
- Ask page → Statement user: shows cited answer
