# mohtasim01/loan-default-app architecture

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

- Interactive diagram: https://gitdiagram.com/mohtasim01/loan-default-app
- Repository: https://github.com/mohtasim01/loan-default-app

## Overview

This is a full-stack loan-default risk checker: a borrower enters 25 application features in the Angular form, which validates and submits them to Flask; Flask checks the schema, runs the saved preprocessing-plus-XGBoost pipeline, and returns a default prediction and probability. Separately, the training notebook compares five models and produces the deployable bundle and frontend feature schema. The README documents health and schema endpoints and a static GitHub Pages mode that cannot make predictions. Unsampled template, proxy, and deployment wiring is represented only where the README or excerpts support it.

Main entry points: [`notebooks/train_and_compare.py`](https://github.com/mohtasim01/loan-default-app/blob/main/notebooks/train_and_compare.py) (Training and comparison), [`backend/app.py`](https://github.com/mohtasim01/loan-default-app/blob/main/backend/app.py) (Flask API), [`frontend/src/app/app.ts`](https://github.com/mohtasim01/loan-default-app/blob/main/frontend/src/app/app.ts) (Application form), [`frontend/src/app/prediction.service.ts`](https://github.com/mohtasim01/loan-default-app/blob/main/frontend/src/app/prediction.service.ts) (Prediction service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Borrower interface"]
  node_form["Application form<br/>[app.ts]"]
  node_fields["Feature schema<br/>[feature-schema.ts]"]
  node_http["Prediction service"]
end

subgraph group_api["Prediction API"]
  node_api["Flask API<br/>[app.py]"]
  node_bundle["Model bundle"]
  node_pipeline["Prediction pipeline"]
end

subgraph group_ml["Model development"]
  node_training["Training and comparison"]
  node_dataset["Loan dataset"]
  node_results["Metrics and reports"]
  node_schemaout["Generated form schema<br/>[feature-schema.ts]"]
  node_sample["Sample input row<br/>[sample_inputs.csv]"]
end

node_borrower(("Borrower"))
node_pages(("GitHub Pages visitor"))

node_borrower -->|"enters application"| node_form
node_fields -->|"defines fields"| node_form
node_form -->|"submits payload"| node_http
node_http -->|"POST /predict"| node_api
node_api -->|"loads model data"| node_bundle
node_api -->|"predicts probability"| node_pipeline
node_pipeline -->|"returns prediction"| node_api
node_api -->|"returns result"| node_form
node_dataset -->|"trains from"| node_training
node_training -->|"saves pipeline"| node_bundle
node_training -->|"writes metrics"| node_results
node_training -->|"generates schema"| node_schemaout
node_training -->|"writes sample row"| node_sample
node_pages -->|"views static app"| node_form

click node_form "https://github.com/mohtasim01/loan-default-app/blob/main/frontend/src/app/app.ts"
click node_fields "https://github.com/mohtasim01/loan-default-app/blob/main/frontend/src/app/feature-schema.ts"
click node_http "https://github.com/mohtasim01/loan-default-app/blob/main/frontend/src/app/prediction.service.ts"
click node_api "https://github.com/mohtasim01/loan-default-app/blob/main/backend/app.py"
click node_bundle "https://github.com/mohtasim01/loan-default-app/blob/main/backend/models/model_bundle.joblib"
click node_pipeline "https://github.com/mohtasim01/loan-default-app/blob/main/backend/models/model_bundle.joblib"
click node_training "https://github.com/mohtasim01/loan-default-app/blob/main/notebooks/train_and_compare.py"
click node_dataset "https://github.com/mohtasim01/loan-default-app/tree/main/data"
click node_results "https://github.com/mohtasim01/loan-default-app/tree/main/docs"
click node_schemaout "https://github.com/mohtasim01/loan-default-app/blob/main/frontend/src/app/feature-schema.ts"
click node_sample "https://github.com/mohtasim01/loan-default-app/blob/main/data/sample_inputs.csv"

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_form,node_fields,node_http toneBlue
class node_api,node_bundle,node_pipeline toneAmber
class node_training,node_dataset,node_results,node_schemaout,node_sample toneMint
class node_borrower,node_pages toneIndigo
```

## Components

### Borrower interface

- [Application form](https://github.com/mohtasim01/loan-default-app/blob/main/frontend/src/app/app.ts): `frontend/src/app/app.ts`
- [Feature schema](https://github.com/mohtasim01/loan-default-app/blob/main/frontend/src/app/feature-schema.ts): `frontend/src/app/feature-schema.ts`
- [Prediction service](https://github.com/mohtasim01/loan-default-app/blob/main/frontend/src/app/prediction.service.ts): `frontend/src/app/prediction.service.ts`

### Prediction API

- [Flask API](https://github.com/mohtasim01/loan-default-app/blob/main/backend/app.py): `backend/app.py`
- [Model bundle](https://github.com/mohtasim01/loan-default-app/blob/main/backend/models/model_bundle.joblib): `backend/models/model_bundle.joblib`
- [Prediction pipeline](https://github.com/mohtasim01/loan-default-app/blob/main/backend/models/model_bundle.joblib): `backend/models/model_bundle.joblib`

### Model development

- [Training and comparison](https://github.com/mohtasim01/loan-default-app/blob/main/notebooks/train_and_compare.py): `notebooks/train_and_compare.py`
- [Loan dataset](https://github.com/mohtasim01/loan-default-app/tree/main/data): `data`
- [Metrics and reports](https://github.com/mohtasim01/loan-default-app/tree/main/docs): `docs`
- [Generated form schema](https://github.com/mohtasim01/loan-default-app/blob/main/frontend/src/app/feature-schema.ts): `frontend/src/app/feature-schema.ts`
- [Sample input row](https://github.com/mohtasim01/loan-default-app/blob/main/data/sample_inputs.csv): `data/sample_inputs.csv`

### Other components

- **Borrower**
- **GitHub Pages visitor**

## Connections

- Borrower → Application form: enters application (evidence: `README.md`)
- Feature schema → Application form: defines fields (evidence: `frontend/src/app/app.ts`)
- Application form → Prediction service: submits payload (evidence: `frontend/src/app/app.ts`)
- Prediction service → Flask API: POST /predict (evidence: `README.md`)
- Flask API → Model bundle: loads model data (evidence: `backend/app.py`)
- Flask API → Prediction pipeline: predicts probability (evidence: `backend/app.py`)
- Prediction pipeline → Flask API: returns prediction (evidence: `backend/app.py`)
- Flask API → Application form: returns result
- Loan dataset → Training and comparison: trains from (evidence: `notebooks/train_and_compare.py`)
- Training and comparison → Model bundle: saves pipeline (evidence: `notebooks/train_and_compare.py`)
- Training and comparison → Metrics and reports: writes metrics (evidence: `notebooks/train_and_compare.py`)
- Training and comparison → Generated form schema: generates schema (evidence: `notebooks/train_and_compare.py`)
- Training and comparison → Sample input row: writes sample row (evidence: `notebooks/train_and_compare.py`)
- GitHub Pages visitor → Application form: views static app (evidence: `README.md`)
