# paragdhomne/loan-default-prediction architecture

> Architecture diagram of the GitHub repository paragdhomne/loan-default-prediction, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/paragdhomne/loan-default-prediction
- Repository: https://github.com/paragdhomne/loan-default-prediction

## Overview

Loan Default Prediction is a batch-trained binary-classification application with a FastAPI prediction service. Its documented workflow moves from raw data validation and preprocessing through leakage investigation, feature preparation, model comparison and threshold selection; the trained model and preprocessor then support online predictions. Reporting produces metrics and visualizations. The source excerpts confirm dataset processing, training, reporting, and API-to-prediction calls; README statements support the broader workflow. Data files are not present in the tree, so those stages point to their implementing source files.

Main entry points: [`loan_default_prediction/train.py`](https://github.com/paragdhomne/loan-default-prediction/blob/main/loan_default_prediction/train.py) (Train and tune models), [`loan_default_prediction/dataset.py`](https://github.com/paragdhomne/loan-default-prediction/blob/main/loan_default_prediction/dataset.py) (Validate and preprocess), [`loan_default_prediction/predict.py`](https://github.com/paragdhomne/loan-default-prediction/blob/main/loan_default_prediction/predict.py) (Loan prediction), [`loan_default_prediction/config.py`](https://github.com/paragdhomne/loan-default-prediction/blob/main/loan_default_prediction/config.py) (Runtime configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_dataset["Validate and preprocess<br/>[dataset.py]"]
  node_leakage["Leakage investigation"]
  node_features["Feature preparation<br/>[features.py]"]
end

subgraph group_model["Model development"]
  node_training["Train and tune models<br/>[train.py]"]
  node_comparison["Model comparison<br/>[train.py]"]
  node_threshold["Threshold evaluation<br/>[train.py]"]
  node_reporting["Metrics and visualizations<br/>[reporting.py]"]
end

subgraph group_serve["Prediction service"]
  node_api["FastAPI endpoints<br/>[api.py]"]
  node_prediction["Loan prediction<br/>[predict.py]"]
end

subgraph group_support["Configuration and outputs"]
  node_artifacts["Model artifacts"]
  node_config["Runtime configuration<br/>[config.py]"]
end

node_analyst(("Project operator"))
node_raw["Raw loan data"]
node_client(("Prediction caller"))
node_response["Risk result"]

node_analyst -->|"runs processing"| node_dataset
node_raw -->|"loads CSV"| node_dataset
node_dataset -->|"investigates leakage"| node_leakage
node_leakage -->|"informs selection"| node_features
node_features -->|"prepares features"| node_training
node_dataset -->|"uses processed data"| node_training
node_training -->|"compares models"| node_comparison
node_training -->|"evaluates thresholds"| node_threshold
node_reporting -->|"calls training routines"| node_training
node_reporting -->|"reports threshold results"| node_threshold
node_training -->|"saves models"| node_artifacts
node_client -->|"submits loan"| node_api
node_api -->|"calls predictor"| node_prediction
node_prediction -->|"loads model files"| node_artifacts
node_prediction -->|"returns risk"| node_response
node_api -->|"formats API result"| node_response
node_dataset -->|"uses configured paths"| node_config
node_features -->|"uses configured paths"| node_config
node_training -->|"uses training settings"| node_config
node_prediction -->|"uses decision threshold"| node_config

click node_dataset "https://github.com/paragdhomne/loan-default-prediction/blob/main/loan_default_prediction/dataset.py"
click node_leakage "https://github.com/paragdhomne/loan-default-prediction/blob/main/references/leakage_analysis/check_clean_model.py"
click node_features "https://github.com/paragdhomne/loan-default-prediction/blob/main/loan_default_prediction/features.py"
click node_training "https://github.com/paragdhomne/loan-default-prediction/blob/main/loan_default_prediction/train.py"
click node_comparison "https://github.com/paragdhomne/loan-default-prediction/blob/main/loan_default_prediction/train.py"
click node_threshold "https://github.com/paragdhomne/loan-default-prediction/blob/main/loan_default_prediction/train.py"
click node_reporting "https://github.com/paragdhomne/loan-default-prediction/blob/main/loan_default_prediction/reporting.py"
click node_artifacts "https://github.com/paragdhomne/loan-default-prediction/tree/main/models"
click node_config "https://github.com/paragdhomne/loan-default-prediction/blob/main/loan_default_prediction/config.py"
click node_api "https://github.com/paragdhomne/loan-default-prediction/blob/main/loan_default_prediction/api.py"
click node_prediction "https://github.com/paragdhomne/loan-default-prediction/blob/main/loan_default_prediction/predict.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_dataset,node_leakage,node_features toneBlue
class node_training,node_comparison,node_threshold,node_reporting toneAmber
class node_api,node_prediction toneMint
class node_artifacts,node_config toneRose
class node_analyst,node_raw,node_client,node_response toneIndigo
```

## Components

### Data preparation

- [Validate and preprocess](https://github.com/paragdhomne/loan-default-prediction/blob/main/loan_default_prediction/dataset.py): `loan_default_prediction/dataset.py`
- [Leakage investigation](https://github.com/paragdhomne/loan-default-prediction/blob/main/references/leakage_analysis/check_clean_model.py): `references/leakage_analysis/check_clean_model.py`
- [Feature preparation](https://github.com/paragdhomne/loan-default-prediction/blob/main/loan_default_prediction/features.py): `loan_default_prediction/features.py`

### Model development

- [Train and tune models](https://github.com/paragdhomne/loan-default-prediction/blob/main/loan_default_prediction/train.py): `loan_default_prediction/train.py`
- [Model comparison](https://github.com/paragdhomne/loan-default-prediction/blob/main/loan_default_prediction/train.py): `loan_default_prediction/train.py`
- [Threshold evaluation](https://github.com/paragdhomne/loan-default-prediction/blob/main/loan_default_prediction/train.py): `loan_default_prediction/train.py`
- [Metrics and visualizations](https://github.com/paragdhomne/loan-default-prediction/blob/main/loan_default_prediction/reporting.py): `loan_default_prediction/reporting.py`

### Prediction service

- [FastAPI endpoints](https://github.com/paragdhomne/loan-default-prediction/blob/main/loan_default_prediction/api.py): `loan_default_prediction/api.py`
- [Loan prediction](https://github.com/paragdhomne/loan-default-prediction/blob/main/loan_default_prediction/predict.py): `loan_default_prediction/predict.py`

### Configuration and outputs

- [Model artifacts](https://github.com/paragdhomne/loan-default-prediction/tree/main/models): `models`
- [Runtime configuration](https://github.com/paragdhomne/loan-default-prediction/blob/main/loan_default_prediction/config.py): `loan_default_prediction/config.py`

### Other components

- **Project operator**
- **Raw loan data**
- **Prediction caller**
- **Risk result**

## Connections

- Project operator → Validate and preprocess: runs processing (evidence: `loan_default_prediction/dataset.py`)
- Raw loan data → Validate and preprocess: loads CSV (evidence: `loan_default_prediction/dataset.py`)
- Validate and preprocess → Leakage investigation: investigates leakage (evidence: `README.md`)
- Leakage investigation → Feature preparation: informs selection (evidence: `README.md`)
- Feature preparation → Train and tune models: prepares features (evidence: `README.md`)
- Validate and preprocess → Train and tune models: uses processed data (evidence: `loan_default_prediction/train.py`)
- Train and tune models → Model comparison: compares models (evidence: `loan_default_prediction/train.py`)
- Train and tune models → Threshold evaluation: evaluates thresholds (evidence: `loan_default_prediction/train.py`)
- Metrics and visualizations → Train and tune models: calls training routines (evidence: `loan_default_prediction/reporting.py`)
- Metrics and visualizations → Threshold evaluation: reports threshold results (evidence: `loan_default_prediction/reporting.py`)
- Train and tune models → Model artifacts: saves models (evidence: `loan_default_prediction/train.py`)
- Prediction caller → FastAPI endpoints: submits loan (evidence: `loan_default_prediction/api.py`)
- FastAPI endpoints → Loan prediction: calls predictor (evidence: `loan_default_prediction/api.py`)
- Loan prediction → Model artifacts: loads model files (evidence: `loan_default_prediction/predict.py`)
- Loan prediction → Risk result: returns risk (evidence: `loan_default_prediction/predict.py`)
- FastAPI endpoints → Risk result: formats API result (evidence: `loan_default_prediction/api.py`)
- Validate and preprocess → Runtime configuration: uses configured paths (evidence: `loan_default_prediction/dataset.py`)
- Feature preparation → Runtime configuration: uses configured paths (evidence: `loan_default_prediction/features.py`)
- Train and tune models → Runtime configuration: uses training settings (evidence: `loan_default_prediction/train.py`)
- Loan prediction → Runtime configuration: uses decision threshold (evidence: `loan_default_prediction/predict.py`)
