# yash-gif-pixel/momentum architecture

> Architecture diagram of the GitHub repository yash-gif-pixel/momentum, 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/yash-gif-pixel/momentum
- Repository: https://github.com/yash-gif-pixel/momentum

## Overview

Momentum is a prototype with three user-facing capabilities: Credify underwriting, simulated climate cash-flow analysis, and on-device Scam Guard warnings. Borrowers and lenders use the Flutter app to submit or select a profile and inspect decision-support results; the backend validates submissions, applies a sufficiency gate, scores eligible histories, and returns explanations and portfolio views. The graph also includes the synthetic-data and shared cash-flow layers that underpin scoring. Some frontend and Scam Guard implementation details were not sampled, so those links are documented or left unverified.

Main entry points: [`backend/api/main.py`](https://github.com/yash-gif-pixel/momentum/blob/main/backend/api/main.py) (FastAPI routes), [`backend/model/scorecard.py`](https://github.com/yash-gif-pixel/momentum/blob/main/backend/model/scorecard.py) (Analysis and response), [`backend/climate/router.py`](https://github.com/yash-gif-pixel/momentum/blob/main/backend/climate/router.py) (Climate API), [`frontend/lib/main.dart`](https://github.com/yash-gif-pixel/momentum/blob/main/frontend/lib/main.dart) (App shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Flutter app"]
  node_app["App shell<br/>[main.dart]"]
  node_credify_ui["Underwriting screens"]
  node_api_client["Credify API client"]
  node_climate_ui["Climate screens"]
  node_scam_ui["Scam Guard UI"]
end

subgraph group_underwriting["Credify underwriting"]
  node_api["FastAPI routes<br/>[main.py]"]
  node_profile_cache["Startup profile cache<br/>[dependencies.py]"]
  node_scorecard["Analysis and response<br/>[scorecard.py]"]
  node_feature_engine["Feature extraction<br/>[feature_engine.py]"]
  node_sufficiency["Sufficiency gate<br/>[sufficiency.py]"]
  node_reasons["Reason codes<br/>[reason_codes.py]"]
  node_authenticity["Authenticity checks<br/>[authenticity.py]"]
  node_model["Scorecard artifact<br/>[artifact.py]"]
  node_metrics["Validation metrics<br/>[metrics.json]"]
end

subgraph group_climate["Climate analysis"]
  node_climate_router["Climate API<br/>[router.py]"]
  node_climate_impact["Impact estimation<br/>[impact.py]"]
  node_rainfall["Scenario rainfall data"]
  node_climate_schema["Climate response schema<br/>[schemas.py]"]
end

subgraph group_scam["Scam Guard"]
  node_scam_package["On-device heuristic"]
  node_scam_rules["Warning rules<br/>[rules.dart]"]
end

subgraph group_foundation["Data and scoring"]
  node_transactions["Synthetic profiles"]
  node_schema["Profile schema<br/>[schema.py]"]
  node_cashflow["Cash-flow primitives<br/>[cashflow.py]"]
  node_windows["History windows<br/>[windows.py]"]
  node_labels["Holdout labels<br/>[label_engine.py]"]
  node_contract["API data contract<br/>[api_schema.py]"]
end

node_borrower(("Borrower"))
node_lender(("Lender"))

node_borrower -->|"uses"| node_app
node_lender -->|"uses"| node_app
node_app -.->|"presents"| node_credify_ui
node_credify_ui -.->|"requests scoring"| node_api_client
node_api_client -->|"calls API"| node_api
node_app -.->|"presents"| node_climate_ui
node_climate_ui -->|"requests estimates"| node_climate_router
node_app -.->|"presents"| node_scam_ui
node_scam_ui -.->|"uses heuristics"| node_scam_package
node_scam_package -.->|"applies rules"| node_scam_rules
node_api -->|"resolves profiles"| node_profile_cache
node_api -->|"analyzes profile"| node_scorecard
node_api -->|"mounts routes"| node_climate_router
node_api -->|"validates responses"| node_contract
node_scorecard -->|"extracts features"| node_feature_engine
node_scorecard -->|"checks sufficiency"| node_sufficiency
node_scorecard -->|"predicts score"| node_model
node_scorecard -->|"builds explanations"| node_reasons
node_scorecard -->|"checks authenticity"| node_authenticity
node_feature_engine -->|"uses primitives"| node_cashflow
node_feature_engine -->|"checks history"| node_windows
node_feature_engine -->|"reads profiles"| node_schema
node_sufficiency -->|"measures history"| node_cashflow
node_sufficiency -->|"assesses profile"| node_schema
node_reasons -->|"reads coefficients"| node_model
node_authenticity -->|"returns result"| node_contract
node_profile_cache -->|"loads demo profiles"| node_transactions
node_transactions -->|"creates profiles"| node_schema
node_labels -->|"derives labels"| node_cashflow
node_labels -->|"checks holdout"| node_windows
node_climate_router -->|"loads profiles"| node_profile_cache
node_climate_router -->|"calculates impact"| node_climate_impact
node_climate_router -->|"validates output"| node_climate_schema
node_climate_router -->|"reads scenarios"| node_rainfall
node_climate_impact -->|"uses cash-flow data"| node_cashflow
node_climate_impact -->|"reads profile"| node_schema
node_api -->|"serves model card"| node_metrics

click node_app "https://github.com/yash-gif-pixel/momentum/blob/main/frontend/lib/main.dart"
click node_credify_ui "https://github.com/yash-gif-pixel/momentum/tree/main/frontend/lib/screens"
click node_api_client "https://github.com/yash-gif-pixel/momentum/blob/main/frontend/lib/services/credify_http_service.dart"
click node_climate_ui "https://github.com/yash-gif-pixel/momentum/tree/main/frontend/lib/features/climate"
click node_scam_ui "https://github.com/yash-gif-pixel/momentum/tree/main/frontend/lib/features/scam_guard"
click node_api "https://github.com/yash-gif-pixel/momentum/blob/main/backend/api/main.py"
click node_profile_cache "https://github.com/yash-gif-pixel/momentum/blob/main/backend/api/dependencies.py"
click node_scorecard "https://github.com/yash-gif-pixel/momentum/blob/main/backend/model/scorecard.py"
click node_feature_engine "https://github.com/yash-gif-pixel/momentum/blob/main/backend/features/feature_engine.py"
click node_sufficiency "https://github.com/yash-gif-pixel/momentum/blob/main/backend/features/sufficiency.py"
click node_reasons "https://github.com/yash-gif-pixel/momentum/blob/main/backend/model/reason_codes.py"
click node_authenticity "https://github.com/yash-gif-pixel/momentum/blob/main/backend/model/authenticity.py"
click node_model "https://github.com/yash-gif-pixel/momentum/blob/main/backend/model/artifact.py"
click node_metrics "https://github.com/yash-gif-pixel/momentum/blob/main/backend/model/artifacts/metrics.json"
click node_climate_router "https://github.com/yash-gif-pixel/momentum/blob/main/backend/climate/router.py"
click node_climate_impact "https://github.com/yash-gif-pixel/momentum/blob/main/backend/climate/impact.py"
click node_rainfall "https://github.com/yash-gif-pixel/momentum/tree/main/data/climate"
click node_scam_package "https://github.com/yash-gif-pixel/momentum/blob/main/packages/scam_guard/lib/src/scam_guard_impl.dart"
click node_scam_rules "https://github.com/yash-gif-pixel/momentum/blob/main/packages/scam_guard/lib/src/rules.dart"
click node_transactions "https://github.com/yash-gif-pixel/momentum/blob/main/backend/generator/generate_dataset.py"
click node_schema "https://github.com/yash-gif-pixel/momentum/blob/main/backend/generator/schema.py"
click node_cashflow "https://github.com/yash-gif-pixel/momentum/blob/main/backend/common/cashflow.py"
click node_windows "https://github.com/yash-gif-pixel/momentum/blob/main/backend/common/windows.py"
click node_labels "https://github.com/yash-gif-pixel/momentum/blob/main/backend/labels/label_engine.py"
click node_contract "https://github.com/yash-gif-pixel/momentum/blob/main/backend/contract/api_schema.py"
click node_climate_schema "https://github.com/yash-gif-pixel/momentum/blob/main/backend/climate/schemas.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_app,node_credify_ui,node_api_client,node_climate_ui,node_scam_ui toneBlue
class node_api,node_profile_cache,node_scorecard,node_feature_engine,node_sufficiency,node_reasons,node_authenticity,node_model,node_metrics toneAmber
class node_climate_router,node_climate_impact,node_rainfall,node_climate_schema toneMint
class node_scam_package,node_scam_rules toneRose
class node_transactions,node_schema,node_cashflow,node_windows,node_labels,node_contract,node_borrower,node_lender toneIndigo
```

## Components

### Flutter app

- [App shell](https://github.com/yash-gif-pixel/momentum/blob/main/frontend/lib/main.dart): `frontend/lib/main.dart`
- [Underwriting screens](https://github.com/yash-gif-pixel/momentum/tree/main/frontend/lib/screens): `frontend/lib/screens`
- [Credify API client](https://github.com/yash-gif-pixel/momentum/blob/main/frontend/lib/services/credify_http_service.dart): `frontend/lib/services/credify_http_service.dart`
- [Climate screens](https://github.com/yash-gif-pixel/momentum/tree/main/frontend/lib/features/climate): `frontend/lib/features/climate`
- [Scam Guard UI](https://github.com/yash-gif-pixel/momentum/tree/main/frontend/lib/features/scam_guard): `frontend/lib/features/scam_guard`

### Credify underwriting

- [FastAPI routes](https://github.com/yash-gif-pixel/momentum/blob/main/backend/api/main.py): `backend/api/main.py`
- [Startup profile cache](https://github.com/yash-gif-pixel/momentum/blob/main/backend/api/dependencies.py): `backend/api/dependencies.py`
- [Analysis and response](https://github.com/yash-gif-pixel/momentum/blob/main/backend/model/scorecard.py): `backend/model/scorecard.py`
- [Feature extraction](https://github.com/yash-gif-pixel/momentum/blob/main/backend/features/feature_engine.py): `backend/features/feature_engine.py`
- [Sufficiency gate](https://github.com/yash-gif-pixel/momentum/blob/main/backend/features/sufficiency.py): `backend/features/sufficiency.py`
- [Reason codes](https://github.com/yash-gif-pixel/momentum/blob/main/backend/model/reason_codes.py): `backend/model/reason_codes.py`
- [Authenticity checks](https://github.com/yash-gif-pixel/momentum/blob/main/backend/model/authenticity.py): `backend/model/authenticity.py`
- [Scorecard artifact](https://github.com/yash-gif-pixel/momentum/blob/main/backend/model/artifact.py): `backend/model/artifact.py`
- [Validation metrics](https://github.com/yash-gif-pixel/momentum/blob/main/backend/model/artifacts/metrics.json): `backend/model/artifacts/metrics.json`

### Climate analysis

- [Climate API](https://github.com/yash-gif-pixel/momentum/blob/main/backend/climate/router.py): `backend/climate/router.py`
- [Impact estimation](https://github.com/yash-gif-pixel/momentum/blob/main/backend/climate/impact.py): `backend/climate/impact.py`
- [Scenario rainfall data](https://github.com/yash-gif-pixel/momentum/tree/main/data/climate): `data/climate`
- [Climate response schema](https://github.com/yash-gif-pixel/momentum/blob/main/backend/climate/schemas.py): `backend/climate/schemas.py`

### Scam Guard

- [On-device heuristic](https://github.com/yash-gif-pixel/momentum/blob/main/packages/scam_guard/lib/src/scam_guard_impl.dart): `packages/scam_guard/lib/src/scam_guard_impl.dart`
- [Warning rules](https://github.com/yash-gif-pixel/momentum/blob/main/packages/scam_guard/lib/src/rules.dart): `packages/scam_guard/lib/src/rules.dart`

### Data and scoring

- [Synthetic profiles](https://github.com/yash-gif-pixel/momentum/blob/main/backend/generator/generate_dataset.py): `backend/generator/generate_dataset.py`
- [Profile schema](https://github.com/yash-gif-pixel/momentum/blob/main/backend/generator/schema.py): `backend/generator/schema.py`
- [Cash-flow primitives](https://github.com/yash-gif-pixel/momentum/blob/main/backend/common/cashflow.py): `backend/common/cashflow.py`
- [History windows](https://github.com/yash-gif-pixel/momentum/blob/main/backend/common/windows.py): `backend/common/windows.py`
- [Holdout labels](https://github.com/yash-gif-pixel/momentum/blob/main/backend/labels/label_engine.py): `backend/labels/label_engine.py`
- [API data contract](https://github.com/yash-gif-pixel/momentum/blob/main/backend/contract/api_schema.py): `backend/contract/api_schema.py`

### Other components

- **Borrower**
- **Lender**

## Connections

- Borrower → App shell: uses (evidence: `README.md`)
- Lender → App shell: uses (evidence: `README.md`)
- App shell → Underwriting screens: presents
- Underwriting screens → Credify API client: requests scoring
- Credify API client → FastAPI routes: calls API (evidence: `README.md`)
- App shell → Climate screens: presents
- Climate screens → Climate API: requests estimates (evidence: `README.md`)
- App shell → Scam Guard UI: presents
- Scam Guard UI → On-device heuristic: uses heuristics
- On-device heuristic → Warning rules: applies rules
- FastAPI routes → Startup profile cache: resolves profiles (evidence: `backend/api/main.py`)
- FastAPI routes → Analysis and response: analyzes profile (evidence: `backend/api/main.py`)
- FastAPI routes → Climate API: mounts routes (evidence: `backend/api/main.py`)
- FastAPI routes → API data contract: validates responses (evidence: `backend/api/main.py`)
- Analysis and response → Feature extraction: extracts features (evidence: `backend/model/scorecard.py`)
- Analysis and response → Sufficiency gate: checks sufficiency (evidence: `backend/model/scorecard.py`)
- Analysis and response → Scorecard artifact: predicts score (evidence: `backend/model/scorecard.py`)
- Analysis and response → Reason codes: builds explanations (evidence: `backend/model/scorecard.py`)
- Analysis and response → Authenticity checks: checks authenticity (evidence: `backend/model/scorecard.py`)
- Feature extraction → Cash-flow primitives: uses primitives (evidence: `backend/features/feature_engine.py`)
- Feature extraction → History windows: checks history (evidence: `backend/features/feature_engine.py`)
- Feature extraction → Profile schema: reads profiles (evidence: `backend/features/feature_engine.py`)
- Sufficiency gate → Cash-flow primitives: measures history (evidence: `backend/features/sufficiency.py`)
- Sufficiency gate → Profile schema: assesses profile (evidence: `backend/features/sufficiency.py`)
- Reason codes → Scorecard artifact: reads coefficients (evidence: `backend/model/reason_codes.py`)
- Authenticity checks → API data contract: returns result (evidence: `backend/model/authenticity.py`)
- Startup profile cache → Synthetic profiles: loads demo profiles (evidence: `backend/api/dependencies.py`)
- Synthetic profiles → Profile schema: creates profiles (evidence: `backend/generator/generate_dataset.py`)
- Holdout labels → Cash-flow primitives: derives labels (evidence: `backend/labels/label_engine.py`)
- Holdout labels → History windows: checks holdout (evidence: `backend/labels/label_engine.py`)
- Climate API → Startup profile cache: loads profiles (evidence: `backend/climate/router.py`)
- Climate API → Impact estimation: calculates impact (evidence: `backend/climate/router.py`)
- Climate API → Climate response schema: validates output (evidence: `backend/climate/router.py`)
- Climate API → Scenario rainfall data: reads scenarios (evidence: `backend/climate/router.py`)
- Impact estimation → Cash-flow primitives: uses cash-flow data (evidence: `backend/climate/impact.py`)
- Impact estimation → Profile schema: reads profile (evidence: `backend/climate/impact.py`)
- FastAPI routes → Validation metrics: serves model card (evidence: `backend/api/main.py`)
