# bhupesh-debug/ml-project-client-cashflow-early-warning architecture

> Architecture diagram of the GitHub repository bhupesh-debug/ml-project-client-cashflow-early-warning, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bhupesh-debug/ml-project-client-cashflow-early-warning
- Repository: https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning

## Overview

CP-PCG is an SMB finance advisory engine: it turns historical cash-flow, working-capital, and WIP data into leakage-safe features, forecasts 13-week cash flow, flags 45-day Daily Cash Target breach risk, and presents risk tiers with TAPW interventions. The Streamlit app is the interactive user entry point; inference produces the displayed diagnostics. The README documents the broader domain stages, while sampled source confirms key implementation links. Some unsampled subsystem details are represented only at the documented level.

Main entry points: [`src/models/train.py`](https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/blob/main/src/models/train.py) (Chronological Model Training), [`src/inference/pipeline.py`](https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/blob/main/src/inference/pipeline.py) (Prediction Engine), [`app/app.py`](https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/blob/main/app/app.py) (Interactive Diagnostics), [`src/features/build_features.py`](https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/blob/main/src/features/build_features.py) (Leakage-Safe Features)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Financial Data"]
  node_synthetic_data["SMB Data Generator"]
  node_dataset_loader["Schema and Time Split<br/>[loader.py]"]
  node_financial_records["Historical Transactions"]
end

subgraph group_features["Feature Engineering"]
  node_feature_engineering["Leakage-Safe Features<br/>[build_features.py]"]
end

subgraph group_models["Modeling and Evaluation"]
  node_training["Chronological Model Training<br/>[train.py]"]
  node_baselines["Financial Baselines<br/>[baseline.py]"]
  node_evaluation_metrics["Forecast and Risk Metrics<br/>[metrics.py]"]
  node_model_artifacts["Trained Model Artifacts"]
end

subgraph group_advisory["Inference and Advisory"]
  node_streamlit_app["Interactive Diagnostics<br/>[app.py]"]
  node_inference["Prediction Engine<br/>[pipeline.py]"]
  node_risk_tiering["Liquidity Risk Tiering<br/>[pipeline.py]"]
  node_tapw_advisory["TAPW Interventions<br/>[pipeline.py]"]
  node_triad_review(("Platform Triad Review"))
end

node_finance_user(("Finance Manager"))

node_finance_user -->|"enters inputs"| node_streamlit_app
node_streamlit_app -->|"requests predictions"| node_inference
node_synthetic_data -.->|"generates records"| node_financial_records
node_financial_records -->|"loads and validates"| node_dataset_loader
node_dataset_loader -.->|"provides records"| node_feature_engineering
node_feature_engineering -.->|"builds training inputs"| node_training
node_training -->|"benchmarks against"| node_baselines
node_training -->|"evaluates predictions"| node_evaluation_metrics
node_training -->|"serializes models"| node_model_artifacts
node_training -->|"uses feature matrices"| node_feature_engineering
node_inference -->|"loads trained models"| node_model_artifacts
node_inference -->|"transforms inputs"| node_feature_engineering
node_inference -->|"assigns risk tier"| node_risk_tiering
node_inference -->|"prescribes actions"| node_tapw_advisory
node_streamlit_app -->|"displays diagnostics"| node_risk_tiering
node_streamlit_app -->|"presents interventions"| node_tapw_advisory
node_tapw_advisory -.->|"guides review"| node_triad_review

click node_streamlit_app "https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/blob/main/app/app.py"
click node_synthetic_data "https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/blob/main/src/data/generate_synthetic_data.py"
click node_dataset_loader "https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/blob/main/src/data/loader.py"
click node_financial_records "https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/blob/main/data/sample/raw_platform_cashflow_sample.csv"
click node_feature_engineering "https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/blob/main/src/features/build_features.py"
click node_training "https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/blob/main/src/models/train.py"
click node_baselines "https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/blob/main/src/models/baseline.py"
click node_evaluation_metrics "https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/blob/main/src/evaluation/metrics.py"
click node_model_artifacts "https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/tree/main/reports/models"
click node_inference "https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/blob/main/src/inference/pipeline.py"
click node_risk_tiering "https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/blob/main/src/inference/pipeline.py"
click node_tapw_advisory "https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/blob/main/src/inference/pipeline.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_synthetic_data,node_dataset_loader,node_financial_records toneBlue
class node_feature_engineering toneAmber
class node_training,node_baselines,node_evaluation_metrics,node_model_artifacts toneMint
class node_streamlit_app,node_inference,node_risk_tiering,node_tapw_advisory,node_triad_review toneRose
class node_finance_user toneIndigo
```

## Components

### Financial Data

- [SMB Data Generator](https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/blob/main/src/data/generate_synthetic_data.py): `src/data/generate_synthetic_data.py`
- [Schema and Time Split](https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/blob/main/src/data/loader.py): `src/data/loader.py`
- [Historical Transactions](https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/blob/main/data/sample/raw_platform_cashflow_sample.csv): `data/sample/raw_platform_cashflow_sample.csv`

### Feature Engineering

- [Leakage-Safe Features](https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/blob/main/src/features/build_features.py): `src/features/build_features.py`

### Modeling and Evaluation

- [Chronological Model Training](https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/blob/main/src/models/train.py): `src/models/train.py`
- [Financial Baselines](https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/blob/main/src/models/baseline.py): `src/models/baseline.py`
- [Forecast and Risk Metrics](https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/blob/main/src/evaluation/metrics.py): `src/evaluation/metrics.py`
- [Trained Model Artifacts](https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/tree/main/reports/models): `reports/models`

### Inference and Advisory

- [Interactive Diagnostics](https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/blob/main/app/app.py): `app/app.py`
- [Prediction Engine](https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/blob/main/src/inference/pipeline.py): `src/inference/pipeline.py`
- [Liquidity Risk Tiering](https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/blob/main/src/inference/pipeline.py): `src/inference/pipeline.py`
- [TAPW Interventions](https://github.com/bhupesh-debug/ml-project-client-cashflow-early-warning/blob/main/src/inference/pipeline.py): `src/inference/pipeline.py`
- **Platform Triad Review**

### Other components

- **Finance Manager**

## Connections

- Finance Manager → Interactive Diagnostics: enters inputs (evidence: `app/app.py`)
- Interactive Diagnostics → Prediction Engine: requests predictions (evidence: `app/app.py`)
- SMB Data Generator → Historical Transactions: generates records (evidence: `README.md`)
- Historical Transactions → Schema and Time Split: loads and validates (evidence: `src/data/loader.py`)
- Schema and Time Split → Leakage-Safe Features: provides records (evidence: `README.md`)
- Leakage-Safe Features → Chronological Model Training: builds training inputs (evidence: `README.md`)
- Chronological Model Training → Financial Baselines: benchmarks against (evidence: `src/models/train.py`)
- Chronological Model Training → Forecast and Risk Metrics: evaluates predictions (evidence: `src/models/train.py`)
- Chronological Model Training → Trained Model Artifacts: serializes models (evidence: `src/models/train.py`)
- Chronological Model Training → Leakage-Safe Features: uses feature matrices (evidence: `README.md`)
- Prediction Engine → Trained Model Artifacts: loads trained models (evidence: `src/inference/pipeline.py`)
- Prediction Engine → Leakage-Safe Features: transforms inputs (evidence: `src/inference/pipeline.py`)
- Prediction Engine → Liquidity Risk Tiering: assigns risk tier (evidence: `src/inference/pipeline.py`)
- Prediction Engine → TAPW Interventions: prescribes actions (evidence: `src/inference/pipeline.py`)
- Interactive Diagnostics → Liquidity Risk Tiering: displays diagnostics (evidence: `app/app.py`)
- Interactive Diagnostics → TAPW Interventions: presents interventions (evidence: `app/app.py`)
- TAPW Interventions → Platform Triad Review: guides review (evidence: `README.md`)
