# hussainbasha559/bank-personal-loan-predictor architecture

> Architecture diagram of the GitHub repository hussainbasha559/bank-personal-loan-predictor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hussainbasha559/bank-personal-loan-predictor
- Repository: https://github.com/hussainbasha559/bank-personal-loan-predictor

## Overview

The system offers two prediction interfaces: a Streamlit app and a FastAPI endpoint. In the main user workflow, an applicant enters details in Streamlit; the agent gets a prediction and SHAP contributions, turns them into a decision, confidence, insights, and suggestions, and the app displays a waterfall explanation. The app also provides overview, dashboard, and dataset views backed by SQLite. The README describes broader training and dataset capabilities, but the sampled runtime source does not establish their implementation, so they are not mapped as runtime components.

Main entry points: [`app/streamlit.py`](https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/app/streamlit.py) (Home Overview), [`src/agent.py`](https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/src/agent.py) (Decision Agent), [`src/predictor.py`](https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/src/predictor.py) (Prediction and SHAP), [`app/api.py`](https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/app/api.py) (Prediction Endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Streamlit App"]
  node_overview["Home Overview<br/>[streamlit.py]"]
  node_dashboard["Dashboard<br/>[streamlit.py]"]
  node_entryform["Prediction Form<br/>[streamlit.py]"]
  node_explanation_view["Explanation View<br/>[streamlit.py]"]
  node_data_view["Dataset View<br/>[streamlit.py]"]
end

subgraph group_inference["Explainable Inference"]
  node_agent["Decision Agent<br/>[agent.py]"]
  node_predictor["Prediction and SHAP<br/>[predictor.py]"]
  node_shap["SHAP Explainer<br/>[predictor.py]"]
end

subgraph group_data["Data and Models"]
  node_model["Loan Model<br/>[loan_model.pkl]"]
  node_loan_db[("Clean Loan Data<br/>[bank_loan.db]")]
  node_model_scaler["Feature Scaler<br/>[scaler.pkl]"]
end

subgraph group_api["Prediction API"]
  node_api["Prediction Endpoint<br/>[api.py]"]
end

node_customer(("Applicant"))
node_api_client(("API Client"))

node_customer -->|"opens app"| node_overview
node_customer -->|"enters details"| node_entryform
node_entryform -->|"submits profile"| node_agent
node_agent -->|"requests prediction"| node_predictor
node_predictor -->|"predicts with"| node_model
node_predictor -->|"calculates contributions"| node_shap
node_agent -->|"returns decision and insights"| node_explanation_view
node_explanation_view -->|"renders waterfall"| node_shap
node_overview -->|"navigates to"| node_dashboard
node_overview -->|"navigates to"| node_data_view
node_dashboard -->|"reads dataset"| node_loan_db
node_data_view -->|"displays dataset"| node_loan_db
node_api_client -->|"posts customer data"| node_api
node_api -->|"predicts with"| node_model
node_api -->|"scales features"| node_model_scaler

click node_overview "https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/app/streamlit.py"
click node_dashboard "https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/app/streamlit.py"
click node_entryform "https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/app/streamlit.py"
click node_explanation_view "https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/app/streamlit.py"
click node_data_view "https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/app/streamlit.py"
click node_agent "https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/src/agent.py"
click node_predictor "https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/src/predictor.py"
click node_model "https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/models/loan_model.pkl"
click node_shap "https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/src/predictor.py"
click node_loan_db "https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/data/bank_loan.db"
click node_model_scaler "https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/models/scaler.pkl"
click node_api "https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/app/api.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_overview,node_dashboard,node_entryform,node_explanation_view,node_data_view,node_api_client toneBlue
class node_agent,node_predictor,node_shap toneAmber
class node_model,node_loan_db,node_model_scaler toneMint
class node_api toneRose
class node_customer toneIndigo
```

## Components

### Streamlit App

- [Home Overview](https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/app/streamlit.py): `app/streamlit.py`
- [Dashboard](https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/app/streamlit.py): `app/streamlit.py`
- [Prediction Form](https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/app/streamlit.py): `app/streamlit.py`
- [Explanation View](https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/app/streamlit.py): `app/streamlit.py`
- [Dataset View](https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/app/streamlit.py): `app/streamlit.py`

### Explainable Inference

- [Decision Agent](https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/src/agent.py): `src/agent.py`
- [Prediction and SHAP](https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/src/predictor.py): `src/predictor.py`
- [SHAP Explainer](https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/src/predictor.py): `src/predictor.py`

### Data and Models

- [Loan Model](https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/models/loan_model.pkl): `models/loan_model.pkl`
- [Clean Loan Data](https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/data/bank_loan.db): `data/bank_loan.db`
- [Feature Scaler](https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/models/scaler.pkl): `models/scaler.pkl`

### Prediction API

- [Prediction Endpoint](https://github.com/hussainbasha559/bank-personal-loan-predictor/blob/main/app/api.py): `app/api.py`

### Other components

- **Applicant**
- **API Client**

## Connections

- Applicant → Home Overview: opens app (evidence: `README.md`)
- Applicant → Prediction Form: enters details (evidence: `README.md`)
- Prediction Form → Decision Agent: submits profile (evidence: `app/streamlit.py`)
- Decision Agent → Prediction and SHAP: requests prediction (evidence: `src/agent.py`)
- Prediction and SHAP → Loan Model: predicts with (evidence: `src/predictor.py`)
- Prediction and SHAP → SHAP Explainer: calculates contributions (evidence: `src/predictor.py`)
- Decision Agent → Explanation View: returns decision and insights (evidence: `app/streamlit.py`)
- Explanation View → SHAP Explainer: renders waterfall (evidence: `app/streamlit.py`)
- Home Overview → Dashboard: navigates to (evidence: `app/streamlit.py`)
- Home Overview → Dataset View: navigates to (evidence: `app/streamlit.py`)
- Dashboard → Clean Loan Data: reads dataset (evidence: `app/streamlit.py`)
- Dataset View → Clean Loan Data: displays dataset (evidence: `app/streamlit.py`)
- API Client → Prediction Endpoint: posts customer data (evidence: `app/api.py`)
- Prediction Endpoint → Loan Model: predicts with (evidence: `app/api.py`)
- Prediction Endpoint → Feature Scaler: scales features (evidence: `app/api.py`)
