# abhi0323/machine-learning-based-loan-default-early-warning-system architecture

> Architecture diagram of the GitHub repository abhi0323/machine-learning-based-loan-default-early-warning-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abhi0323/machine-learning-based-loan-default-early-warning-system
- Repository: https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system

## Overview

This is a loan-default prediction application with a model-training workflow and a Flask prediction interface. Training ingests and splits credit-risk data, transforms features, evaluates candidate classifiers, and saves a processor and model; the web workflow converts submitted fields to a dataframe, loads those artifacts, and returns a default-risk message. The README also describes Azure deployment, but the supplied source does not show its runtime configuration. Shared logging and exception handling are internal support layers; some edges are based on the SOURCE INDEX rather than full-file inspection.

Main entry points: [`app.py`](https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/app.py) (Flask routes), [`src/pipeline/pred_pipeline.py`](https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/src/pipeline/pred_pipeline.py) (Prediction pipeline), [`src/components/data_ingestion.py`](https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/src/components/data_ingestion.py) (Data ingestion), [`src/components/model_trainer.py`](https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/src/components/model_trainer.py) (Model training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Model training"]
  node_ingestion["Data ingestion<br/>[data_ingestion.py]"]
  node_dataset["Credit-risk data<br/>[credit_risk.csv]"]
  node_transform["Feature transformation"]
  node_trainer["Model training<br/>[model_trainer.py]"]
  node_evaluation["Model evaluation<br/>[utils.py]"]
  node_artifacts[("Model artifacts")]
end

subgraph group_serving["Prediction application"]
  node_webapp["Flask routes<br/>[app.py]"]
  node_input["Input dataframe<br/>[pred_pipeline.py]"]
  node_prediction["Prediction pipeline<br/>[pred_pipeline.py]"]
  node_home["Prediction form<br/>[home.html]"]
  node_landing["Landing page<br/>[index.html]"]
end

subgraph group_support["Shared support"]
  node_persistence["Object persistence<br/>[utils.py]"]
  node_logging["Logging<br/>[logger.py]"]
  node_errors["Custom exceptions<br/>[exception.py]"]
end

node_user(("Loan applicant"))
node_azure["Azure Web App"]

node_user -->|"submits fields"| node_webapp
node_webapp -->|"renders form"| node_home
node_webapp -->|"renders page"| node_landing
node_user -.->|"enters data"| node_home
node_webapp -->|"constructs dataframe"| node_input
node_webapp -->|"calls predict"| node_prediction
node_input -->|"provides features"| node_prediction
node_prediction -->|"loads model and processor"| node_artifacts
node_prediction -->|"loads objects"| node_persistence
node_prediction -->|"returns risk score"| node_webapp
node_webapp -->|"renders result"| node_home
node_dataset -.->|"input source"| node_ingestion
node_ingestion -->|"starts transformation"| node_transform
node_ingestion -->|"starts training"| node_trainer
node_ingestion -->|"reads CSV"| node_dataset
node_transform -->|"saves processor"| node_artifacts
node_trainer -->|"evaluates candidates"| node_evaluation
node_trainer -->|"saves best model"| node_artifacts
node_trainer -->|"saves object"| node_persistence
node_evaluation -->|"uses model search"| node_persistence
node_webapp -.->|"deployed on"| node_azure
node_ingestion -->|"logs activity"| node_logging
node_transform -->|"logs activity"| node_logging
node_trainer -->|"logs activity"| node_logging
node_prediction -->|"logs activity"| node_logging
node_errors -->|"imports logger"| node_logging
node_ingestion -->|"raises on failure"| node_errors
node_transform -->|"raises on failure"| node_errors
node_trainer -->|"raises on failure"| node_errors
node_prediction -->|"raises on failure"| node_errors
node_persistence -->|"raises on failure"| node_errors

click node_ingestion "https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/src/components/data_ingestion.py"
click node_dataset "https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/Notebook/Data/credit_risk.csv"
click node_transform "https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/src/components/data_transformation.py"
click node_trainer "https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/src/components/model_trainer.py"
click node_evaluation "https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/src/utils.py"
click node_artifacts "https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/tree/main/artificats"
click node_webapp "https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/app.py"
click node_input "https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/src/pipeline/pred_pipeline.py"
click node_prediction "https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/src/pipeline/pred_pipeline.py"
click node_home "https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/templates/home.html"
click node_landing "https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/templates/index.html"
click node_persistence "https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/src/utils.py"
click node_logging "https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/src/logger.py"
click node_errors "https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/src/exception.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_ingestion,node_dataset,node_transform,node_trainer,node_evaluation,node_artifacts toneBlue
class node_webapp,node_input,node_prediction,node_home,node_landing toneAmber
class node_persistence,node_logging,node_errors toneMint
class node_user,node_azure toneIndigo
```

## Components

### Model training

- [Data ingestion](https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/src/components/data_ingestion.py): `src/components/data_ingestion.py`
- [Credit-risk data](https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/Notebook/Data/credit_risk.csv): `Notebook/Data/credit_risk.csv`
- [Feature transformation](https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/src/components/data_transformation.py): `src/components/data_transformation.py`
- [Model training](https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/src/components/model_trainer.py): `src/components/model_trainer.py`
- [Model evaluation](https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/src/utils.py): `src/utils.py`
- [Model artifacts](https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/tree/main/artificats): `artificats`

### Prediction application

- [Flask routes](https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/app.py): `app.py`
- [Input dataframe](https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/src/pipeline/pred_pipeline.py): `src/pipeline/pred_pipeline.py`
- [Prediction pipeline](https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/src/pipeline/pred_pipeline.py): `src/pipeline/pred_pipeline.py`
- [Prediction form](https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/templates/home.html): `templates/home.html`
- [Landing page](https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/templates/index.html): `templates/index.html`

### Shared support

- [Object persistence](https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/src/utils.py): `src/utils.py`
- [Logging](https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/src/logger.py): `src/logger.py`
- [Custom exceptions](https://github.com/abhi0323/machine-learning-based-loan-default-early-warning-system/blob/main/src/exception.py): `src/exception.py`

### Other components

- **Loan applicant**
- **Azure Web App**

## Connections

- Loan applicant → Flask routes: submits fields (evidence: `README.md`)
- Flask routes → Prediction form: renders form (evidence: `app.py`)
- Flask routes → Landing page: renders page (evidence: `app.py`)
- Loan applicant → Prediction form: enters data
- Flask routes → Input dataframe: constructs dataframe (evidence: `app.py`)
- Flask routes → Prediction pipeline: calls predict (evidence: `app.py`)
- Input dataframe → Prediction pipeline: provides features (evidence: `src/pipeline/pred_pipeline.py`)
- Prediction pipeline → Model artifacts: loads model and processor (evidence: `src/pipeline/pred_pipeline.py`)
- Prediction pipeline → Object persistence: loads objects (evidence: `src/pipeline/pred_pipeline.py`)
- Prediction pipeline → Flask routes: returns risk score (evidence: `app.py`)
- Flask routes → Prediction form: renders result (evidence: `app.py`)
- Credit-risk data → Data ingestion: input source
- Data ingestion → Feature transformation: starts transformation (evidence: `src/components/data_ingestion.py`)
- Data ingestion → Model training: starts training (evidence: `src/components/data_ingestion.py`)
- Data ingestion → Credit-risk data: reads CSV (evidence: `src/components/data_ingestion.py`)
- Feature transformation → Model artifacts: saves processor (evidence: `src/components/data_transformation.py`)
- Model training → Model evaluation: evaluates candidates (evidence: `src/components/model_trainer.py`)
- Model training → Model artifacts: saves best model (evidence: `src/components/model_trainer.py`)
- Model training → Object persistence: saves object (evidence: `src/components/model_trainer.py`)
- Model evaluation → Object persistence: uses model search (evidence: `src/utils.py`)
- Flask routes → Azure Web App: deployed on (evidence: `README.md`)
- Data ingestion → Logging: logs activity (evidence: `src/components/data_ingestion.py`)
- Feature transformation → Logging: logs activity (evidence: `src/components/data_transformation.py`)
- Model training → Logging: logs activity (evidence: `src/components/model_trainer.py`)
- Prediction pipeline → Logging: logs activity (evidence: `src/pipeline/pred_pipeline.py`)
- Custom exceptions → Logging: imports logger (evidence: `src/exception.py`)
- Data ingestion → Custom exceptions: raises on failure (evidence: `src/components/data_ingestion.py`)
- Feature transformation → Custom exceptions: raises on failure (evidence: `src/components/data_transformation.py`)
- Model training → Custom exceptions: raises on failure (evidence: `src/components/model_trainer.py`)
- Prediction pipeline → Custom exceptions: raises on failure (evidence: `src/pipeline/pred_pipeline.py`)
- Object persistence → Custom exceptions: raises on failure (evidence: `src/utils.py`)
