# 0xeroot/bank-health-monitor architecture

> Architecture diagram of the GitHub repository 0xeroot/bank-health-monitor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/0xeroot/bank-health-monitor
- Repository: https://github.com/0xeroot/bank-health-monitor

## Overview

Bank Health Monitor downloads quarterly FFIEC Call Reports, stages and validates them, builds a DuckDB core star schema and CAMELS ratio mart, then serves bank-health views through a Streamlit dashboard. The README also documents a synthetic-data route, peer benchmarks, trend analysis, sensitivity measures, and threshold alerts. Relationships are based on the README and shown excerpts; SQL transforms and some dashboard capabilities are documented but their implementation details were not sampled.

Main entry points: [`python/generate_sample_data.py`](https://github.com/0xeroot/bank-health-monitor/blob/master/python/generate_sample_data.py) (Sample data builder), [`python/download.py`](https://github.com/0xeroot/bank-health-monitor/blob/master/python/download.py) (Quarter downloader), [`python/load_staging.py`](https://github.com/0xeroot/bank-health-monitor/blob/master/python/load_staging.py) (CSV staging loader), [`sql/02_core/02_staging_to_core.sql`](https://github.com/0xeroot/bank-health-monitor/blob/master/sql/02_core/02_staging_to_core.sql) (Staging-to-core ETL)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Report ingestion"]
  node_downloader["Quarter downloader<br/>[download.py]"]
  node_rawfiles["Extracted reports"]
  node_samplegen["Sample data builder"]
  node_loader["CSV staging loader<br/>[load_staging.py]"]
end

subgraph group_warehouse["Data warehouse"]
  node_stagingddl["Staging schema"]
  node_stagingdb[("Staging database")]
  node_validator["Data quality checks<br/>[validate.py]"]
  node_coreddl["Core schema"]
  node_coreetl["Staging-to-core ETL"]
end

subgraph group_analytics["CAMELS analytics"]
  node_camels["CAMELS ratios<br/>[camels_ratios.sql]"]
end

subgraph group_presentation["Dashboard"]
  node_dashboard["Health dashboard<br/>[app.py]"]
  node_bi["Power BI / Tableau"]
end

node_analyst(("Risk analyst"))
node_cdr{{"FFIEC CDR"}}
node_coredb[("Core database")]

node_analyst -->|"views health"| node_dashboard
node_cdr -->|"supplies reports"| node_downloader
node_downloader -->|"downloads and extracts"| node_rawfiles
node_rawfiles -->|"provides CSVs"| node_loader
node_loader -->|"loads CSV data"| node_stagingdb
node_stagingddl -->|"defines tables"| node_stagingdb
node_validator -->|"checks quality"| node_stagingdb
node_coreddl -->|"defines schema"| node_coredb
node_stagingdb -->|"provides staging data"| node_coreetl
node_coreetl -->|"loads core tables"| node_coredb
node_coredb -->|"provides bank data"| node_camels
node_camels -->|"writes ratios"| node_coredb
node_coredb -->|"serves dashboard queries"| node_dashboard
node_samplegen -->|"builds sample staging"| node_stagingdb
node_samplegen -->|"builds sample core"| node_coredb
node_coredb -.->|"connects for BI"| node_bi

click node_downloader "https://github.com/0xeroot/bank-health-monitor/blob/master/python/download.py"
click node_samplegen "https://github.com/0xeroot/bank-health-monitor/blob/master/python/generate_sample_data.py"
click node_loader "https://github.com/0xeroot/bank-health-monitor/blob/master/python/load_staging.py"
click node_stagingddl "https://github.com/0xeroot/bank-health-monitor/blob/master/sql/01_staging/01_create_staging_tables.sql"
click node_validator "https://github.com/0xeroot/bank-health-monitor/blob/master/python/validate.py"
click node_coreddl "https://github.com/0xeroot/bank-health-monitor/blob/master/sql/02_core/01_create_core_schema.sql"
click node_coreetl "https://github.com/0xeroot/bank-health-monitor/blob/master/sql/02_core/02_staging_to_core.sql"
click node_camels "https://github.com/0xeroot/bank-health-monitor/blob/master/sql/03_marts/camels_ratios.sql"
click node_dashboard "https://github.com/0xeroot/bank-health-monitor/blob/master/dashboard/app.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_downloader,node_rawfiles,node_samplegen,node_loader toneBlue
class node_stagingddl,node_stagingdb,node_validator,node_coreddl,node_coreetl,node_coredb toneAmber
class node_camels toneMint
class node_dashboard,node_bi toneRose
class node_analyst,node_cdr toneIndigo
```

## Components

### Report ingestion

- [Quarter downloader](https://github.com/0xeroot/bank-health-monitor/blob/master/python/download.py): `python/download.py`
- **Extracted reports**
- [Sample data builder](https://github.com/0xeroot/bank-health-monitor/blob/master/python/generate_sample_data.py): `python/generate_sample_data.py`
- [CSV staging loader](https://github.com/0xeroot/bank-health-monitor/blob/master/python/load_staging.py): `python/load_staging.py`

### Data warehouse

- [Staging schema](https://github.com/0xeroot/bank-health-monitor/blob/master/sql/01_staging/01_create_staging_tables.sql): `sql/01_staging/01_create_staging_tables.sql`
- **Staging database**
- [Data quality checks](https://github.com/0xeroot/bank-health-monitor/blob/master/python/validate.py): `python/validate.py`
- [Core schema](https://github.com/0xeroot/bank-health-monitor/blob/master/sql/02_core/01_create_core_schema.sql): `sql/02_core/01_create_core_schema.sql`
- [Staging-to-core ETL](https://github.com/0xeroot/bank-health-monitor/blob/master/sql/02_core/02_staging_to_core.sql): `sql/02_core/02_staging_to_core.sql`

### CAMELS analytics

- [CAMELS ratios](https://github.com/0xeroot/bank-health-monitor/blob/master/sql/03_marts/camels_ratios.sql): `sql/03_marts/camels_ratios.sql`

### Dashboard

- [Health dashboard](https://github.com/0xeroot/bank-health-monitor/blob/master/dashboard/app.py): `dashboard/app.py`
- **Power BI / Tableau**

### Other components

- **Risk analyst**
- **FFIEC CDR**
- **Core database**

## Connections

- Risk analyst → Health dashboard: views health (evidence: `README.md`)
- FFIEC CDR → Quarter downloader: supplies reports (evidence: `README.md`)
- Quarter downloader → Extracted reports: downloads and extracts (evidence: `python/download.py`)
- Extracted reports → CSV staging loader: provides CSVs (evidence: `README.md`)
- CSV staging loader → Staging database: loads CSV data (evidence: `README.md`)
- Staging schema → Staging database: defines tables (evidence: `README.md`)
- Data quality checks → Staging database: checks quality (evidence: `python/validate.py`)
- Core schema → Core database: defines schema (evidence: `README.md`)
- Staging database → Staging-to-core ETL: provides staging data (evidence: `README.md`)
- Staging-to-core ETL → Core database: loads core tables (evidence: `README.md`)
- Core database → CAMELS ratios: provides bank data (evidence: `README.md`)
- CAMELS ratios → Core database: writes ratios
- Core database → Health dashboard: serves dashboard queries (evidence: `dashboard/app.py`)
- Sample data builder → Staging database: builds sample staging (evidence: `python/generate_sample_data.py`)
- Sample data builder → Core database: builds sample core (evidence: `python/generate_sample_data.py`)
- Core database → Power BI / Tableau: connects for BI (evidence: `README.md`)
