# partomia/alm-irrbb-casa-behavioural-forecasting architecture

> Architecture diagram of the GitHub repository partomia/alm-irrbb-casa-behavioural-forecasting, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/partomia/alm-irrbb-casa-behavioural-forecasting
- Repository: https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting

## Overview

This project refreshes CASA deposit behavioural assumptions for ALM/IRRBB: balance history is prepared as weekly segment data, forecast and backtest results produce core/non-core splits and liquidity buckets, and ALCO users inspect results or run stress what-ifs. The graph follows the documented CDE-to-CAI workflow and includes reporting, lineage, and optional endpoint scoring. Some app, validation, and silver-stage wiring is documented but not shown in sampled source; the graph uses those documented stages without inferring their internals.

Main entry points: [`casa/pipeline.py`](https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/casa/pipeline.py) (Monthly pipeline), [`cde/dags/casa_alm_dag.py`](https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/cde/dags/casa_alm_dag.py) (Airflow DAG), [`casa/storage.py`](https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/casa/storage.py) (Storage adapter), [`cde/jobs/build_silver_daily.py`](https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/cde/jobs/build_silver_daily.py) (Daily silver build)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Data preparation"]
  node_generator["Bronze generator"]
  node_bronze[("Bronze tables")]
  node_validator["Bronze validation<br/>[validate_bronze.py]"]
  node_silver["Daily silver build"]
  node_silverdata[("Silver daily table")]
  node_goldbuild["Weekly gold build"]
end

subgraph group_orchestration["Run orchestration"]
  node_dag["Airflow DAG<br/>[casa_alm_dag.py]"]
  node_job["Monthly forecast job"]
end

subgraph group_analytics["Forecast analytics"]
  node_weekly[("Weekly balance table")]
  node_pipeline["Monthly pipeline<br/>[pipeline.py]"]
  node_model["TimesFM forecasting<br/>[model.py]"]
  node_backtest["Rolling backtest<br/>[backtest.py]"]
  node_behaviour["Core and SLS rules<br/>[behavioural.py]"]
  node_storage["Storage adapter<br/>[storage.py]"]
  node_outputs[("ALCO output tables")]
  node_scoring["Stress scoring<br/>[scoring.py]"]
end

subgraph group_consumption["ALCO consumption"]
  node_app["ALCO Streamlit app<br/>[streamlit_app.py]"]
  node_appdata["App data access<br/>[data.py]"]
  node_client["What-if client<br/>[client.py]"]
  node_endpoint["Model endpoint<br/>[predict.py]"]
  node_reports["Impala reports<br/>[reports.sql]"]
end

node_cbs["CBS extract"]
node_actor(("ALCO user"))

node_cbs -.->|"provides balances"| node_generator
node_generator -->|"writes"| node_bronze
node_dag -->|"dispatches"| node_generator
node_dag -->|"dispatches"| node_validator
node_dag -->|"dispatches"| node_silver
node_dag -->|"dispatches"| node_goldbuild
node_validator -->|"validates"| node_bronze
node_validator -->|"gates"| node_silver
node_silver -->|"reads"| node_bronze
node_silver -->|"writes"| node_silverdata
node_goldbuild -->|"reads"| node_silverdata
node_goldbuild -->|"merges"| node_weekly
node_dag -->|"triggers via API"| node_job
node_job -->|"runs"| node_pipeline
node_pipeline -->|"reads weekly data"| node_storage
node_storage -->|"reads"| node_weekly
node_pipeline -->|"runs"| node_backtest
node_pipeline -->|"forecasts with"| node_model
node_pipeline -->|"applies rules"| node_behaviour
node_pipeline -->|"writes outputs"| node_storage
node_storage -->|"reads and writes"| node_outputs
node_actor -->|"views ALCO results"| node_app
node_app -->|"loads data through"| node_appdata
node_appdata -->|"reads tables"| node_storage
node_app -->|"requests stress what-if"| node_client
node_client -.->|"calls when configured"| node_endpoint
node_endpoint -->|"scores request"| node_scoring
node_scoring -->|"forecasts with"| node_model
node_client -.->|"scores locally"| node_scoring
node_reports -->|"queries"| node_outputs

click node_generator "https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/cde/jobs/generate_cbs_bronze.py"
click node_validator "https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/cde/jobs/validate_bronze.py"
click node_silver "https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/cde/jobs/build_silver_daily.py"
click node_goldbuild "https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/cde/jobs/build_gold_weekly.py"
click node_dag "https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/cde/dags/casa_alm_dag.py"
click node_job "https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/cai/jobs/monthly_forecast.py"
click node_pipeline "https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/casa/pipeline.py"
click node_model "https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/casa/model.py"
click node_backtest "https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/casa/backtest.py"
click node_behaviour "https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/casa/behavioural.py"
click node_storage "https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/casa/storage.py"
click node_app "https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/app/streamlit_app.py"
click node_appdata "https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/app/data.py"
click node_client "https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/casa/client.py"
click node_endpoint "https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/cai/model/predict.py"
click node_scoring "https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/casa/scoring.py"
click node_reports "https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/sql/reports.sql"

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_generator,node_bronze,node_validator,node_silver,node_silverdata,node_goldbuild,node_actor toneBlue
class node_dag,node_job toneAmber
class node_weekly,node_pipeline,node_model,node_backtest,node_behaviour,node_storage,node_outputs,node_scoring toneMint
class node_app,node_appdata,node_client,node_endpoint,node_reports toneRose
class node_cbs toneIndigo
```

## Components

### Data preparation

- [Bronze generator](https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/cde/jobs/generate_cbs_bronze.py): `cde/jobs/generate_cbs_bronze.py`
- **Bronze tables**
- [Bronze validation](https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/cde/jobs/validate_bronze.py): `cde/jobs/validate_bronze.py`
- [Daily silver build](https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/cde/jobs/build_silver_daily.py): `cde/jobs/build_silver_daily.py`
- **Silver daily table**
- [Weekly gold build](https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/cde/jobs/build_gold_weekly.py): `cde/jobs/build_gold_weekly.py`

### Run orchestration

- [Airflow DAG](https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/cde/dags/casa_alm_dag.py): `cde/dags/casa_alm_dag.py`
- [Monthly forecast job](https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/cai/jobs/monthly_forecast.py): `cai/jobs/monthly_forecast.py`

### Forecast analytics

- **Weekly balance table**
- [Monthly pipeline](https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/casa/pipeline.py): `casa/pipeline.py`
- [TimesFM forecasting](https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/casa/model.py): `casa/model.py`
- [Rolling backtest](https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/casa/backtest.py): `casa/backtest.py`
- [Core and SLS rules](https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/casa/behavioural.py): `casa/behavioural.py`
- [Storage adapter](https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/casa/storage.py): `casa/storage.py`
- **ALCO output tables**
- [Stress scoring](https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/casa/scoring.py): `casa/scoring.py`

### ALCO consumption

- [ALCO Streamlit app](https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/app/streamlit_app.py): `app/streamlit_app.py`
- [App data access](https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/app/data.py): `app/data.py`
- [What-if client](https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/casa/client.py): `casa/client.py`
- [Model endpoint](https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/cai/model/predict.py): `cai/model/predict.py`
- [Impala reports](https://github.com/partomia/alm-irrbb-casa-behavioural-forecasting/blob/main/sql/reports.sql): `sql/reports.sql`

### Other components

- **CBS extract**
- **ALCO user**

## Connections

- CBS extract → Bronze generator: provides balances
- Bronze generator → Bronze tables: writes
- Airflow DAG → Bronze generator: dispatches
- Airflow DAG → Bronze validation: dispatches
- Airflow DAG → Daily silver build: dispatches
- Airflow DAG → Weekly gold build: dispatches
- Bronze validation → Bronze tables: validates
- Bronze validation → Daily silver build: gates
- Daily silver build → Bronze tables: reads
- Daily silver build → Silver daily table: writes
- Weekly gold build → Silver daily table: reads
- Weekly gold build → Weekly balance table: merges
- Airflow DAG → Monthly forecast job: triggers via API
- Monthly forecast job → Monthly pipeline: runs
- Monthly pipeline → Storage adapter: reads weekly data
- Storage adapter → Weekly balance table: reads
- Monthly pipeline → Rolling backtest: runs
- Monthly pipeline → TimesFM forecasting: forecasts with
- Monthly pipeline → Core and SLS rules: applies rules
- Monthly pipeline → Storage adapter: writes outputs
- Storage adapter → ALCO output tables: reads and writes
- ALCO user → ALCO Streamlit app: views ALCO results
- ALCO Streamlit app → App data access: loads data through
- App data access → Storage adapter: reads tables
- ALCO Streamlit app → What-if client: requests stress what-if
- What-if client → Model endpoint: calls when configured
- Model endpoint → Stress scoring: scores request
- Stress scoring → TimesFM forecasting: forecasts with
- What-if client → Stress scoring: scores locally
- Impala reports → ALCO output tables: queries
