# offbyone-dev/smart-loan-risk-analyzer architecture

> Architecture diagram of the GitHub repository offbyone-dev/smart-loan-risk-analyzer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/offbyone-dev/smart-loan-risk-analyzer
- Repository: https://github.com/offbyone-dev/smart-loan-risk-analyzer

## Overview

Smart Loan Risk Analyzer is a Streamlit dashboard for assessing loan-approval risk. Applicants enter demographic and financial details, submit them for a model prediction, and see a risk label, probability, recommendation, and visual explanations. A separate training script reads the loan dataset, fits a Random Forest, and saves the model artifact used by the application. The README also documents feature importance, confusion matrix, and ROC visualizations. The prediction and preprocessing modules are indexed but empty in the supplied excerpts, so no behavior is attributed to them.

Main entry points: [`app/streamlit_app.py`](https://github.com/offbyone-dev/smart-loan-risk-analyzer/blob/main/app/streamlit_app.py) (Streamlit dashboard), [`src/train_model.py`](https://github.com/offbyone-dev/smart-loan-risk-analyzer/blob/main/src/train_model.py) (Model training), [`models/loan_model.pkl`](https://github.com/offbyone-dev/smart-loan-risk-analyzer/blob/main/models/loan_model.pkl) (Trained model), [`data/loan_data.csv`](https://github.com/offbyone-dev/smart-loan-risk-analyzer/blob/main/data/loan_data.csv) (Loan dataset)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Risk dashboard"]
  node_dashboard["Streamlit dashboard<br/>[streamlit_app.py]"]
  node_inputs["Applicant inputs<br/>[streamlit_app.py]"]
  node_risk_result["Risk result<br/>[streamlit_app.py]"]
  node_visualizations["Model visualizations<br/>[streamlit_app.py]"]
end

subgraph group_inference["Model inference"]
  node_model["Trained model<br/>[loan_model.pkl]"]
end

subgraph group_training["Model training"]
  node_training_script["Model training<br/>[train_model.py]"]
  node_loan_data[("Loan dataset<br/>[loan_data.csv]")]
end

node_applicant(("Applicant"))

node_applicant -->|"uses"| node_dashboard
node_dashboard -->|"presents"| node_inputs
node_dashboard -->|"predicts with"| node_model
node_dashboard -->|"shows"| node_risk_result
node_dashboard -->|"renders"| node_visualizations
node_training_script -->|"reads"| node_loan_data
node_training_script -->|"saves"| node_model

click node_dashboard "https://github.com/offbyone-dev/smart-loan-risk-analyzer/blob/main/app/streamlit_app.py"
click node_inputs "https://github.com/offbyone-dev/smart-loan-risk-analyzer/blob/main/app/streamlit_app.py"
click node_risk_result "https://github.com/offbyone-dev/smart-loan-risk-analyzer/blob/main/app/streamlit_app.py"
click node_visualizations "https://github.com/offbyone-dev/smart-loan-risk-analyzer/blob/main/app/streamlit_app.py"
click node_model "https://github.com/offbyone-dev/smart-loan-risk-analyzer/blob/main/models/loan_model.pkl"
click node_training_script "https://github.com/offbyone-dev/smart-loan-risk-analyzer/blob/main/src/train_model.py"
click node_loan_data "https://github.com/offbyone-dev/smart-loan-risk-analyzer/blob/main/data/loan_data.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_dashboard,node_inputs,node_risk_result,node_visualizations toneBlue
class node_model toneAmber
class node_training_script,node_loan_data toneMint
class node_applicant toneIndigo
```

## Components

### Risk dashboard

- [Streamlit dashboard](https://github.com/offbyone-dev/smart-loan-risk-analyzer/blob/main/app/streamlit_app.py): `app/streamlit_app.py`
- [Applicant inputs](https://github.com/offbyone-dev/smart-loan-risk-analyzer/blob/main/app/streamlit_app.py): `app/streamlit_app.py`
- [Risk result](https://github.com/offbyone-dev/smart-loan-risk-analyzer/blob/main/app/streamlit_app.py): `app/streamlit_app.py`
- [Model visualizations](https://github.com/offbyone-dev/smart-loan-risk-analyzer/blob/main/app/streamlit_app.py): `app/streamlit_app.py`

### Model inference

- [Trained model](https://github.com/offbyone-dev/smart-loan-risk-analyzer/blob/main/models/loan_model.pkl): `models/loan_model.pkl`

### Model training

- [Model training](https://github.com/offbyone-dev/smart-loan-risk-analyzer/blob/main/src/train_model.py): `src/train_model.py`
- [Loan dataset](https://github.com/offbyone-dev/smart-loan-risk-analyzer/blob/main/data/loan_data.csv): `data/loan_data.csv`

### Other components

- **Applicant**

## Connections

- Applicant → Streamlit dashboard: uses (evidence: `README.md`)
- Streamlit dashboard → Applicant inputs: presents (evidence: `app/streamlit_app.py`)
- Streamlit dashboard → Trained model: predicts with (evidence: `README.md`)
- Streamlit dashboard → Risk result: shows (evidence: `app/streamlit_app.py`)
- Streamlit dashboard → Model visualizations: renders (evidence: `app/streamlit_app.py`)
- Model training → Loan dataset: reads (evidence: `src/train_model.py`)
- Model training → Trained model: saves (evidence: `src/train_model.py`)
