# khushikumari-2003/credit-risk-analysis-system architecture

> Architecture diagram of the GitHub repository khushikumari-2003/credit-risk-analysis-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/khushikumari-2003/credit-risk-analysis-system
- Repository: https://github.com/khushikumari-2003/credit-risk-analysis-system

## Overview

This is a Streamlit credit-risk assessment application. An applicant supplies personal, loan, and credit details; the app predicts default probability, derives a CIBIL-like score, applies policy overrides, and presents a decision. It also stores assessment history, explains predictions with SHAP, and generates a downloadable PDF. The runtime is implemented primarily in app.py; separate nodes represent its meaningful responsibilities. README capabilities and relationships are included where documented, but unsampled internals are not inferred.

Main entry points: [`app.py`](https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/app.py) (Assessment Controller), [`credit_model.pkl`](https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/credit_model.pkl) (Trained Model), [`Loan_default.csv`](https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/Loan_default.csv) (Loan Data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Applicant Experience"]
  node_streamlit_ui["Streamlit Interface<br/>[app.py]"]
  node_applicant_inputs["Applicant Inputs<br/>[app.py]"]
end

subgraph group_assessment["Risk Assessment"]
  node_assessment_controller["Assessment Controller<br/>[app.py]"]
  node_training_data["Loan Data<br/>[Loan_default.csv]"]
  node_trained_model["Trained Model<br/>[credit_model.pkl]"]
  node_default_prediction["Default Prediction<br/>[app.py]"]
  node_credit_score["Credit Score<br/>[app.py]"]
  node_policy_decision["Policy Decision<br/>[app.py]"]
end

subgraph group_insight["Explainability and Reports"]
  node_shap_analysis["SHAP Analysis<br/>[app.py]"]
  node_risk_visualization["Risk Visualization<br/>[app.py]"]
  node_report_generation["PDF Report Generation<br/>[app.py]"]
  node_downloaded_report["Credit Report"]
end

subgraph group_records["Assessment Records"]
  node_assessment_history[("History Store<br/>[app.py]")]
  node_history_view["History View<br/>[app.py]"]
end

node_applicant(("Applicant"))

node_applicant -->|"enters details"| node_streamlit_ui
node_streamlit_ui -->|"collects inputs"| node_applicant_inputs
node_applicant_inputs -->|"submits assessment"| node_assessment_controller
node_assessment_controller -->|"loads features"| node_training_data
node_assessment_controller -->|"loads model"| node_trained_model
node_assessment_controller -->|"requests prediction"| node_default_prediction
node_default_prediction -->|"predicts probability"| node_trained_model
node_assessment_controller -->|"calculates score"| node_credit_score
node_assessment_controller -->|"applies policy"| node_policy_decision
node_assessment_controller -->|"writes assessment"| node_assessment_history
node_assessment_controller -->|"explains prediction"| node_shap_analysis
node_shap_analysis -->|"samples background"| node_training_data
node_shap_analysis -->|"uses model pipeline"| node_trained_model
node_assessment_controller -->|"renders explanation"| node_risk_visualization
node_assessment_controller -->|"generates report"| node_report_generation
node_report_generation -->|"builds PDF"| node_downloaded_report
node_assessment_controller -->|"shows results"| node_streamlit_ui
node_streamlit_ui -->|"displays history"| node_history_view
node_history_view -->|"reads records"| node_assessment_history

click node_streamlit_ui "https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/app.py"
click node_applicant_inputs "https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/app.py"
click node_assessment_controller "https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/app.py"
click node_training_data "https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/Loan_default.csv"
click node_trained_model "https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/credit_model.pkl"
click node_default_prediction "https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/app.py"
click node_credit_score "https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/app.py"
click node_policy_decision "https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/app.py"
click node_shap_analysis "https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/app.py"
click node_risk_visualization "https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/app.py"
click node_report_generation "https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/app.py"
click node_assessment_history "https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/app.py"
click node_history_view "https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/app.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_streamlit_ui,node_applicant_inputs toneBlue
class node_assessment_controller,node_training_data,node_trained_model,node_default_prediction,node_credit_score,node_policy_decision toneAmber
class node_shap_analysis,node_risk_visualization,node_report_generation,node_downloaded_report toneMint
class node_assessment_history,node_history_view toneRose
class node_applicant toneIndigo
```

## Components

### Applicant Experience

- [Streamlit Interface](https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/app.py): `app.py`
- [Applicant Inputs](https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/app.py): `app.py`

### Risk Assessment

- [Assessment Controller](https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/app.py): `app.py`
- [Loan Data](https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/Loan_default.csv): `Loan_default.csv`
- [Trained Model](https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/credit_model.pkl): `credit_model.pkl`
- [Default Prediction](https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/app.py): `app.py`
- [Credit Score](https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/app.py): `app.py`
- [Policy Decision](https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/app.py): `app.py`

### Explainability and Reports

- [SHAP Analysis](https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/app.py): `app.py`
- [Risk Visualization](https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/app.py): `app.py`
- [PDF Report Generation](https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/app.py): `app.py`
- **Credit Report**

### Assessment Records

- [History Store](https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/app.py): `app.py`
- [History View](https://github.com/khushikumari-2003/credit-risk-analysis-system/blob/main/app.py): `app.py`

### Other components

- **Applicant**

## Connections

- Applicant → Streamlit Interface: enters details (evidence: `app.py`)
- Streamlit Interface → Applicant Inputs: collects inputs (evidence: `app.py`)
- Applicant Inputs → Assessment Controller: submits assessment (evidence: `app.py`)
- Assessment Controller → Loan Data: loads features (evidence: `app.py`)
- Assessment Controller → Trained Model: loads model (evidence: `app.py`)
- Assessment Controller → Default Prediction: requests prediction (evidence: `app.py`)
- Default Prediction → Trained Model: predicts probability (evidence: `app.py`)
- Assessment Controller → Credit Score: calculates score (evidence: `app.py`)
- Assessment Controller → Policy Decision: applies policy (evidence: `app.py`)
- Assessment Controller → History Store: writes assessment (evidence: `app.py`)
- Assessment Controller → SHAP Analysis: explains prediction (evidence: `app.py`)
- SHAP Analysis → Loan Data: samples background (evidence: `app.py`)
- SHAP Analysis → Trained Model: uses model pipeline (evidence: `app.py`)
- Assessment Controller → Risk Visualization: renders explanation (evidence: `app.py`)
- Assessment Controller → PDF Report Generation: generates report (evidence: `app.py`)
- PDF Report Generation → Credit Report: builds PDF (evidence: `app.py`)
- Assessment Controller → Streamlit Interface: shows results (evidence: `app.py`)
- Streamlit Interface → History View: displays history (evidence: `app.py`)
- History View → History Store: reads records (evidence: `app.py`)
