# ramana-pro/loan-default-prediction-web-app architecture

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

- Interactive diagram: https://gitdiagram.com/ramana-pro/loan-default-prediction-web-app
- Repository: https://github.com/ramana-pro/loan-default-prediction-web-app

## Overview

This repository implements loan-default classification, with a batch workflow for generating or loading data, preprocessing it, training and evaluating classifiers, and saving a selected model; a Streamlit interface then accepts loan details and displays a risk prediction. Separate modules provide dataset generation, evaluation, prediction, and feature engineering. The README is empty, and feature-engineering behavior and any links to it are not shown, so that component is included without inferred connections.

Main entry points: [`app.py`](https://github.com/ramana-pro/loan-default-prediction-web-app/blob/main/app.py) (Training workflow), [`streamlit_app.py`](https://github.com/ramana-pro/loan-default-prediction-web-app/blob/main/streamlit_app.py) (Prediction interface), [`src/predict.py`](https://github.com/ramana-pro/loan-default-prediction-web-app/blob/main/src/predict.py) (Prediction helper), [`models/best_model.pkl`](https://github.com/ramana-pro/loan-default-prediction-web-app/blob/main/models/best_model.pkl) (Saved classifier)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data Preparation"]
  node_dataset_generator["Synthetic data generator"]
  node_loan_data[("Loan dataset<br/>[loan_data.csv]")]
  node_preprocessing["Data preprocessing"]
  node_feature_engineering["Feature engineering"]
end

subgraph group_model["Model Lifecycle"]
  node_training_app["Training workflow<br/>[app.py]"]
  node_trainer["Model training<br/>[train_model.py]"]
  node_evaluation["Model evaluation<br/>[evaluate_model.py]"]
  node_model_artifact[("Saved classifier<br/>[best_model.pkl]")]
end

subgraph group_prediction["Loan Prediction"]
  node_streamlit_ui["Prediction interface<br/>[streamlit_app.py]"]
  node_prediction_helper["Prediction helper<br/>[predict.py]"]
  node_risk_result["Default-risk result"]
end

node_operator(("Workflow operator"))
node_customer(("Loan applicant"))

node_operator -->|"runs generation"| node_dataset_generator
node_dataset_generator -->|"writes dataset"| node_loan_data
node_operator -->|"runs training"| node_training_app
node_training_app -->|"loads data"| node_loan_data
node_training_app -->|"calls preprocessing"| node_preprocessing
node_training_app -->|"calls training"| node_trainer
node_trainer -->|"saves classifier"| node_model_artifact
node_customer -->|"enters loan details"| node_streamlit_ui
node_streamlit_ui -->|"loads classifier"| node_model_artifact
node_streamlit_ui -->|"displays risk"| node_risk_result
node_customer -.->|"requests prediction"| node_prediction_helper
node_prediction_helper -->|"loads classifier"| node_model_artifact
node_prediction_helper -->|"returns classification"| node_risk_result

click node_dataset_generator "https://github.com/ramana-pro/loan-default-prediction-web-app/blob/main/src/generate_dataset.py"
click node_loan_data "https://github.com/ramana-pro/loan-default-prediction-web-app/blob/main/data/loan_data.csv"
click node_preprocessing "https://github.com/ramana-pro/loan-default-prediction-web-app/blob/main/src/data_preprocessing.py"
click node_feature_engineering "https://github.com/ramana-pro/loan-default-prediction-web-app/blob/main/src/feature_engineering.py"
click node_training_app "https://github.com/ramana-pro/loan-default-prediction-web-app/blob/main/app.py"
click node_trainer "https://github.com/ramana-pro/loan-default-prediction-web-app/blob/main/src/train_model.py"
click node_evaluation "https://github.com/ramana-pro/loan-default-prediction-web-app/blob/main/src/evaluate_model.py"
click node_model_artifact "https://github.com/ramana-pro/loan-default-prediction-web-app/blob/main/models/best_model.pkl"
click node_streamlit_ui "https://github.com/ramana-pro/loan-default-prediction-web-app/blob/main/streamlit_app.py"
click node_prediction_helper "https://github.com/ramana-pro/loan-default-prediction-web-app/blob/main/src/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_generator,node_loan_data,node_preprocessing,node_feature_engineering toneBlue
class node_training_app,node_trainer,node_evaluation,node_model_artifact toneAmber
class node_streamlit_ui,node_prediction_helper,node_risk_result toneMint
class node_operator,node_customer toneIndigo
```

## Components

### Data Preparation

- [Synthetic data generator](https://github.com/ramana-pro/loan-default-prediction-web-app/blob/main/src/generate_dataset.py): `src/generate_dataset.py`
- [Loan dataset](https://github.com/ramana-pro/loan-default-prediction-web-app/blob/main/data/loan_data.csv): `data/loan_data.csv`
- [Data preprocessing](https://github.com/ramana-pro/loan-default-prediction-web-app/blob/main/src/data_preprocessing.py): `src/data_preprocessing.py`
- [Feature engineering](https://github.com/ramana-pro/loan-default-prediction-web-app/blob/main/src/feature_engineering.py): `src/feature_engineering.py`

### Model Lifecycle

- [Training workflow](https://github.com/ramana-pro/loan-default-prediction-web-app/blob/main/app.py): `app.py`
- [Model training](https://github.com/ramana-pro/loan-default-prediction-web-app/blob/main/src/train_model.py): `src/train_model.py`
- [Model evaluation](https://github.com/ramana-pro/loan-default-prediction-web-app/blob/main/src/evaluate_model.py): `src/evaluate_model.py`
- [Saved classifier](https://github.com/ramana-pro/loan-default-prediction-web-app/blob/main/models/best_model.pkl): `models/best_model.pkl`

### Loan Prediction

- [Prediction interface](https://github.com/ramana-pro/loan-default-prediction-web-app/blob/main/streamlit_app.py): `streamlit_app.py`
- [Prediction helper](https://github.com/ramana-pro/loan-default-prediction-web-app/blob/main/src/predict.py): `src/predict.py`
- **Default-risk result**

### Other components

- **Workflow operator**
- **Loan applicant**

## Connections

- Workflow operator → Synthetic data generator: runs generation (evidence: `src/generate_dataset.py`)
- Synthetic data generator → Loan dataset: writes dataset (evidence: `src/generate_dataset.py`)
- Workflow operator → Training workflow: runs training (evidence: `app.py`)
- Training workflow → Loan dataset: loads data (evidence: `app.py`)
- Training workflow → Data preprocessing: calls preprocessing (evidence: `app.py`)
- Training workflow → Model training: calls training (evidence: `app.py`)
- Model training → Saved classifier: saves classifier (evidence: `src/train_model.py`)
- Loan applicant → Prediction interface: enters loan details (evidence: `streamlit_app.py`)
- Prediction interface → Saved classifier: loads classifier (evidence: `streamlit_app.py`)
- Prediction interface → Default-risk result: displays risk (evidence: `streamlit_app.py`)
- Loan applicant → Prediction helper: requests prediction
- Prediction helper → Saved classifier: loads classifier (evidence: `src/predict.py`)
- Prediction helper → Default-risk result: returns classification (evidence: `src/predict.py`)
