# egebasturmen/production-mlops-credit-risk architecture

> Architecture diagram of the GitHub repository egebasturmen/production-mlops-credit-risk, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/egebasturmen/production-mlops-credit-risk
- Repository: https://github.com/egebasturmen/production-mlops-credit-risk

## Overview

This is a credit-default prediction MLOps application: raw credit data is cleaned and split, candidate models are trained and evaluated, a latest/champion artifact is selected, and a FastAPI service scores requests while recording predictions for monitoring. Operational capabilities include drift analysis, explanations, metrics, and a Streamlit dashboard. The graph includes documented subsystems whose source was not sampled; those links are marked unverified where implementation-level evidence is unavailable.

Main entry points: [`src/credit_risk/app.py`](https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/app.py) (Prediction API), [`src/credit_risk/split.py`](https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/split.py) (Stratified splits), [`src/credit_risk/train.py`](https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/train.py) (Logistic baseline), [`src/credit_risk/train_random_forest.py`](https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/train_random_forest.py) (Random Forest)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_loader["Data loader<br/>[data_load.py]"]
  node_report["Quality report<br/>[data_report.py]"]
  node_schema["Schema inference<br/>[schema.py]"]
  node_split["Stratified splits<br/>[split.py]"]
  node_splitjob["Split workflow<br/>[make_split.py]"]
  node_reportjob["Report workflow<br/>[make_report.py]"]
  node_schemajob["Schema workflow<br/>[make_schema.py]"]
end

subgraph group_model["Model lifecycle"]
  node_featuredefs["Feature definitions<br/>[features.py]"]
  node_baseline["Drift baseline stats<br/>[baseline_stats.py]"]
  node_logreg["Logistic baseline<br/>[train.py]"]
  node_rf["Random Forest"]
  node_hgb["Gradient boosting<br/>[train_hgb.py]"]
  node_artifacts["Model artifacts"]
  node_promotion["Promotion gate"]
  node_promotejob["Manual promotion<br/>[promote_model.py]"]
end

subgraph group_serving["Online serving"]
  node_api["Prediction API<br/>[app.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
end

subgraph group_ops["Monitoring and operations"]
  node_predictions["Production prediction log"]
  node_drift["Drift analysis<br/>[drift.py]"]
  node_logging["Structured logging<br/>[logging_utils.py]"]
  node_dashboard["Operations dashboard<br/>[app.py]"]
end

node_operator(("Credit operator"))
node_rawdata["Raw credit data"]

node_rawdata -->|"loads and cleans"| node_loader
node_reportjob -->|"loads data"| node_loader
node_reportjob -->|"builds report"| node_report
node_schemajob -->|"loads data"| node_loader
node_schemajob -->|"infers schema"| node_schema
node_splitjob -->|"loads data"| node_loader
node_splitjob -->|"creates splits"| node_split
node_logreg -->|"uses features"| node_featuredefs
node_rf -->|"uses features"| node_featuredefs
node_hgb -->|"uses features"| node_featuredefs
node_logreg -->|"computes baseline"| node_baseline
node_rf -->|"computes baseline"| node_baseline
node_hgb -->|"computes baseline"| node_baseline
node_split -.->|"provides splits"| node_logreg
node_split -.->|"provides splits"| node_rf
node_split -.->|"provides splits"| node_hgb
node_logreg -.->|"writes model bundle"| node_artifacts
node_rf -->|"writes model bundle"| node_artifacts
node_hgb -.->|"writes model bundle"| node_artifacts
node_promotion -.->|"evaluates candidates"| node_artifacts
node_promotejob -.->|"updates champion"| node_artifacts
node_operator -->|"submits prediction"| node_api
node_api -->|"reads settings"| node_config
node_api -.->|"loads selected model"| node_artifacts
node_api -->|"computes drift"| node_drift
node_api -->|"uses feature lists"| node_featuredefs
node_api -->|"configures logging"| node_logging
node_api -.->|"logs predictions"| node_predictions
node_dashboard -.->|"reads operations data"| node_api

click node_loader "https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/data_load.py"
click node_report "https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/data_report.py"
click node_schema "https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/schema.py"
click node_split "https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/split.py"
click node_splitjob "https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/scripts/make_split.py"
click node_reportjob "https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/scripts/make_report.py"
click node_schemajob "https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/scripts/make_schema.py"
click node_featuredefs "https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/features.py"
click node_baseline "https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/baseline_stats.py"
click node_logreg "https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/train.py"
click node_rf "https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/train_random_forest.py"
click node_hgb "https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/train_hgb.py"
click node_promotion "https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/scripts/evaluate_and_promote.py"
click node_promotejob "https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/scripts/promote_model.py"
click node_api "https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/app.py"
click node_drift "https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/drift.py"
click node_logging "https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/logging_utils.py"
click node_dashboard "https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/dashboard/app.py"
click node_config "https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/config.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_loader,node_report,node_schema,node_split,node_splitjob,node_reportjob,node_schemajob toneBlue
class node_featuredefs,node_baseline,node_logreg,node_rf,node_hgb,node_artifacts,node_promotion,node_promotejob toneAmber
class node_api,node_config toneMint
class node_predictions,node_drift,node_logging,node_dashboard toneRose
class node_operator,node_rawdata toneIndigo
```

## Components

### Data preparation

- [Data loader](https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/data_load.py): `src/credit_risk/data_load.py`
- [Quality report](https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/data_report.py): `src/credit_risk/data_report.py`
- [Schema inference](https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/schema.py): `src/credit_risk/schema.py`
- [Stratified splits](https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/split.py): `src/credit_risk/split.py`
- [Split workflow](https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/scripts/make_split.py): `src/credit_risk/scripts/make_split.py`
- [Report workflow](https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/scripts/make_report.py): `src/credit_risk/scripts/make_report.py`
- [Schema workflow](https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/scripts/make_schema.py): `src/credit_risk/scripts/make_schema.py`

### Model lifecycle

- [Feature definitions](https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/features.py): `src/credit_risk/features.py`
- [Drift baseline stats](https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/baseline_stats.py): `src/credit_risk/baseline_stats.py`
- [Logistic baseline](https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/train.py): `src/credit_risk/train.py`
- [Random Forest](https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/train_random_forest.py): `src/credit_risk/train_random_forest.py`
- [Gradient boosting](https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/train_hgb.py): `src/credit_risk/train_hgb.py`
- **Model artifacts**
- [Promotion gate](https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/scripts/evaluate_and_promote.py): `src/credit_risk/scripts/evaluate_and_promote.py`
- [Manual promotion](https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/scripts/promote_model.py): `src/credit_risk/scripts/promote_model.py`

### Online serving

- [Prediction API](https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/app.py): `src/credit_risk/app.py`
- [Runtime configuration](https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/config.py): `src/credit_risk/config.py`

### Monitoring and operations

- **Production prediction log**
- [Drift analysis](https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/drift.py): `src/credit_risk/drift.py`
- [Structured logging](https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/logging_utils.py): `src/credit_risk/logging_utils.py`
- [Operations dashboard](https://github.com/egebasturmen/production-mlops-credit-risk/blob/main/src/credit_risk/dashboard/app.py): `src/credit_risk/dashboard/app.py`

### Other components

- **Credit operator**
- **Raw credit data**

## Connections

- Raw credit data → Data loader: loads and cleans (evidence: `src/credit_risk/data_load.py`)
- Report workflow → Data loader: loads data (evidence: `src/credit_risk/scripts/make_report.py`)
- Report workflow → Quality report: builds report (evidence: `src/credit_risk/scripts/make_report.py`)
- Schema workflow → Data loader: loads data (evidence: `src/credit_risk/scripts/make_schema.py`)
- Schema workflow → Schema inference: infers schema (evidence: `src/credit_risk/scripts/make_schema.py`)
- Split workflow → Data loader: loads data (evidence: `src/credit_risk/scripts/make_split.py`)
- Split workflow → Stratified splits: creates splits (evidence: `src/credit_risk/scripts/make_split.py`)
- Logistic baseline → Feature definitions: uses features (evidence: `src/credit_risk/train.py`)
- Random Forest → Feature definitions: uses features (evidence: `src/credit_risk/train_random_forest.py`)
- Gradient boosting → Feature definitions: uses features (evidence: `src/credit_risk/train_hgb.py`)
- Logistic baseline → Drift baseline stats: computes baseline (evidence: `src/credit_risk/train.py`)
- Random Forest → Drift baseline stats: computes baseline (evidence: `src/credit_risk/train_random_forest.py`)
- Gradient boosting → Drift baseline stats: computes baseline (evidence: `src/credit_risk/train_hgb.py`)
- Stratified splits → Logistic baseline: provides splits
- Stratified splits → Random Forest: provides splits
- Stratified splits → Gradient boosting: provides splits
- Logistic baseline → Model artifacts: writes model bundle
- Random Forest → Model artifacts: writes model bundle (evidence: `src/credit_risk/train_random_forest.py`)
- Gradient boosting → Model artifacts: writes model bundle
- Promotion gate → Model artifacts: evaluates candidates (evidence: `README.md`)
- Manual promotion → Model artifacts: updates champion (evidence: `README.md`)
- Credit operator → Prediction API: submits prediction (evidence: `README.md`)
- Prediction API → Runtime configuration: reads settings (evidence: `src/credit_risk/app.py`)
- Prediction API → Model artifacts: loads selected model (evidence: `README.md`)
- Prediction API → Drift analysis: computes drift (evidence: `src/credit_risk/app.py`)
- Prediction API → Feature definitions: uses feature lists (evidence: `src/credit_risk/app.py`)
- Prediction API → Structured logging: configures logging (evidence: `src/credit_risk/app.py`)
- Prediction API → Production prediction log: logs predictions (evidence: `README.md`)
- Operations dashboard → Prediction API: reads operations data
