# njorogepaul-moghul/alternative_credit_scoring-app architecture

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

- Interactive diagram: https://gitdiagram.com/njorogepaul-moghul/alternative_credit_scoring-app
- Repository: https://github.com/njorogepaul-moghul/alternative_credit_scoring-app

## Overview

This Streamlit application collects demographic and alternative financial-behavior signals, derives encoded features, scales them with the fitted preprocessing artifact, and invokes an XGBoost model. A tuned 0.4 probability threshold produces the high/low-risk result, while model feature importances generate an approximate contribution chart. The sampled source fully supports the interactive prediction path; the underlying survey and training pipeline are documented but not present in this repository.

Main entry points: [`Alternative_app.py`](https://github.com/njorogepaul-moghul/alternative_credit_scoring-app/blob/main/Alternative_app.py) (Feature Assembly), [`xgb_credit_model.joblib`](https://github.com/njorogepaul-moghul/alternative_credit_scoring-app/blob/main/xgb_credit_model.joblib) (XGBoost Model), [`scaler.joblib`](https://github.com/njorogepaul-moghul/alternative_credit_scoring-app/blob/main/scaler.joblib) (Standard Scaler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["User Interaction"]
  node_input_ui["Input Interface<br/>[Alternative_app.py]"]
  node_demographics["Demographic Inputs<br/>[Alternative_app.py]"]
  node_behavior["Behavior Inputs<br/>[Alternative_app.py]"]
  node_risk_result["Risk Result<br/>[Alternative_app.py]"]
end

subgraph group_features["Feature Engineering"]
  node_income_derivation["Income Grouping<br/>[Alternative_app.py]"]
  node_feature_assembly["Feature Assembly<br/>[Alternative_app.py]"]
end

subgraph group_inference["Risk Inference"]
  node_scaler["Standard Scaler<br/>[scaler.joblib]"]
  node_xgb_model["XGBoost Model"]
  node_risk_threshold["Risk Threshold<br/>[Alternative_app.py]"]
end

subgraph group_explanation["Result Explanation"]
  node_contribution_calc["Contribution Analysis<br/>[Alternative_app.py]"]
  node_contribution_chart["Contribution Chart<br/>[Alternative_app.py]"]
end

node_user(("Applicant User"))

node_user -->|"enters inputs"| node_input_ui
node_input_ui -->|"captures demographics"| node_demographics
node_input_ui -->|"captures behavior"| node_behavior
node_behavior -->|"derives income group"| node_income_derivation
node_demographics -->|"supplies fields"| node_feature_assembly
node_behavior -->|"supplies fields"| node_feature_assembly
node_income_derivation -->|"supplies encoding"| node_feature_assembly
node_feature_assembly -->|"scales features"| node_scaler
node_scaler -->|"provides features"| node_xgb_model
node_xgb_model -->|"returns probability"| node_risk_threshold
node_risk_threshold -->|"classifies risk"| node_risk_result
node_xgb_model -->|"provides importances"| node_contribution_calc
node_feature_assembly -->|"provides values"| node_contribution_calc
node_contribution_calc -->|"renders chart"| node_contribution_chart
node_risk_result -->|"displays decision"| node_user
node_contribution_chart -->|"displays explanation"| node_user

click node_input_ui "https://github.com/njorogepaul-moghul/alternative_credit_scoring-app/blob/main/Alternative_app.py"
click node_demographics "https://github.com/njorogepaul-moghul/alternative_credit_scoring-app/blob/main/Alternative_app.py"
click node_behavior "https://github.com/njorogepaul-moghul/alternative_credit_scoring-app/blob/main/Alternative_app.py"
click node_income_derivation "https://github.com/njorogepaul-moghul/alternative_credit_scoring-app/blob/main/Alternative_app.py"
click node_feature_assembly "https://github.com/njorogepaul-moghul/alternative_credit_scoring-app/blob/main/Alternative_app.py"
click node_scaler "https://github.com/njorogepaul-moghul/alternative_credit_scoring-app/blob/main/scaler.joblib"
click node_xgb_model "https://github.com/njorogepaul-moghul/alternative_credit_scoring-app/blob/main/xgb_credit_model.joblib"
click node_risk_threshold "https://github.com/njorogepaul-moghul/alternative_credit_scoring-app/blob/main/Alternative_app.py"
click node_risk_result "https://github.com/njorogepaul-moghul/alternative_credit_scoring-app/blob/main/Alternative_app.py"
click node_contribution_calc "https://github.com/njorogepaul-moghul/alternative_credit_scoring-app/blob/main/Alternative_app.py"
click node_contribution_chart "https://github.com/njorogepaul-moghul/alternative_credit_scoring-app/blob/main/Alternative_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_input_ui,node_demographics,node_behavior,node_risk_result,node_user toneBlue
class node_income_derivation,node_feature_assembly toneAmber
class node_scaler,node_xgb_model,node_risk_threshold toneMint
class node_contribution_calc,node_contribution_chart toneRose
```

## Components

### User Interaction

- [Input Interface](https://github.com/njorogepaul-moghul/alternative_credit_scoring-app/blob/main/Alternative_app.py): `Alternative_app.py`
- [Demographic Inputs](https://github.com/njorogepaul-moghul/alternative_credit_scoring-app/blob/main/Alternative_app.py): `Alternative_app.py`
- [Behavior Inputs](https://github.com/njorogepaul-moghul/alternative_credit_scoring-app/blob/main/Alternative_app.py): `Alternative_app.py`
- [Risk Result](https://github.com/njorogepaul-moghul/alternative_credit_scoring-app/blob/main/Alternative_app.py): `Alternative_app.py`

### Feature Engineering

- [Income Grouping](https://github.com/njorogepaul-moghul/alternative_credit_scoring-app/blob/main/Alternative_app.py): `Alternative_app.py`
- [Feature Assembly](https://github.com/njorogepaul-moghul/alternative_credit_scoring-app/blob/main/Alternative_app.py): `Alternative_app.py`

### Risk Inference

- [Standard Scaler](https://github.com/njorogepaul-moghul/alternative_credit_scoring-app/blob/main/scaler.joblib): `scaler.joblib`
- [XGBoost Model](https://github.com/njorogepaul-moghul/alternative_credit_scoring-app/blob/main/xgb_credit_model.joblib): `xgb_credit_model.joblib`
- [Risk Threshold](https://github.com/njorogepaul-moghul/alternative_credit_scoring-app/blob/main/Alternative_app.py): `Alternative_app.py`

### Result Explanation

- [Contribution Analysis](https://github.com/njorogepaul-moghul/alternative_credit_scoring-app/blob/main/Alternative_app.py): `Alternative_app.py`
- [Contribution Chart](https://github.com/njorogepaul-moghul/alternative_credit_scoring-app/blob/main/Alternative_app.py): `Alternative_app.py`

### Other components

- **Applicant User**

## Connections

- Applicant User → Input Interface: enters inputs
- Input Interface → Demographic Inputs: captures demographics
- Input Interface → Behavior Inputs: captures behavior
- Behavior Inputs → Income Grouping: derives income group
- Demographic Inputs → Feature Assembly: supplies fields
- Behavior Inputs → Feature Assembly: supplies fields
- Income Grouping → Feature Assembly: supplies encoding
- Feature Assembly → Standard Scaler: scales features
- Standard Scaler → XGBoost Model: provides features
- XGBoost Model → Risk Threshold: returns probability
- Risk Threshold → Risk Result: classifies risk
- XGBoost Model → Contribution Analysis: provides importances
- Feature Assembly → Contribution Analysis: provides values
- Contribution Analysis → Contribution Chart: renders chart
- Risk Result → Applicant User: displays decision
- Contribution Chart → Applicant User: displays explanation
