# funaturalstone/credit-risk-analytics architecture

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

- Interactive diagram: https://gitdiagram.com/funaturalstone/credit-risk-analytics
- Repository: https://github.com/funaturalstone/credit-risk-analytics

## Overview

This repository is a Lending Club credit-risk analytics project: its main workflow prepares loan data, trains and evaluates models, selects an approval threshold for expected profit, and reports results. Separate SQL analysis examines the loan book, while two dashboard generators present model results and portfolio breakdowns. The README documents notebook outputs and analysis capabilities; sampled excerpts show dashboard input/output behavior and CSV-to-SQLite loading. The notebook and SQL query contents were not sampled, so their internal relationships are limited to documented links.

Main entry points: [`src/credit_risk_pipeline.py`](https://github.com/funaturalstone/credit-risk-analytics/blob/main/src/credit_risk_pipeline.py) (Model Training), [`docs/data`](https://github.com/funaturalstone/credit-risk-analytics/tree/main/docs/data) (Result CSVs), [`notebooks/credit_risk_pipeline.ipynb`](https://github.com/funaturalstone/credit-risk-analytics/blob/main/notebooks/credit_risk_pipeline.ipynb) (Full Pipeline Notebook), [`sql/load_data.py`](https://github.com/funaturalstone/credit-risk-analytics/blob/main/sql/load_data.py) (SQLite Loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_modeling["Credit Modeling"]
  node_notebook["Full Pipeline Notebook"]
  node_script_pipeline["Script Pipeline"]
  node_clean["Clean And Impute"]
  node_split["Stratified Split"]
  node_preprocess["Feature Encoding"]
  node_train["Model Training"]
  node_threshold["Profit Threshold"]
  node_validation["Model Checks"]
  node_test["Held-Out Test"]
  node_explain["Model Explanations"]
end

subgraph group_analysis["Loan Book Analysis"]
  node_loader["SQLite Loader<br/>[load_data.py]"]
  node_loan_db[("Loans Database")]
  node_sql_analysis["Portfolio Queries<br/>[analysis.sql]"]
end

subgraph group_reporting["Reporting"]
  node_results["Result CSVs"]
  node_dashboard_one["Results Dashboard"]
  node_dashboard_two["Portfolio Dashboard"]
  node_dashboard_html["Dashboard Output<br/>[dashboard.html]"]
  node_dashboard_v2_html["Second Dashboard<br/>[dashboard_v2.html]"]
end

node_analyst(("Analyst"))
node_raw_loans["Loan CSV"]

node_analyst -->|"runs pipeline"| node_notebook
node_raw_loans -->|"provides loans"| node_notebook
node_analyst -->|"runs pipeline"| node_script_pipeline
node_raw_loans -->|"provides loans"| node_script_pipeline
node_script_pipeline -->|"performs"| node_clean
node_clean -->|"then splits"| node_split
node_split -->|"then encodes"| node_preprocess
node_preprocess -->|"then trains"| node_train
node_train -->|"tunes on validation"| node_threshold
node_threshold -->|"compares baselines"| node_validation
node_validation -->|"selects final run"| node_test
node_train -->|"explains predictions"| node_explain
node_notebook -->|"saves results"| node_results
node_analyst -->|"loads loan CSV"| node_loader
node_raw_loans -->|"reads rows"| node_loader
node_loader -->|"writes loans"| node_loan_db
node_loan_db -->|"queries loan book"| node_sql_analysis
node_results -->|"reads results"| node_dashboard_one
node_dashboard_one -->|"writes dashboard"| node_dashboard_html
node_results -->|"reads results"| node_dashboard_two
node_loan_db -->|"queries loan data"| node_dashboard_two
node_dashboard_two -->|"writes dashboard"| node_dashboard_v2_html

click node_notebook "https://github.com/funaturalstone/credit-risk-analytics/blob/main/notebooks/credit_risk_pipeline.ipynb"
click node_script_pipeline "https://github.com/funaturalstone/credit-risk-analytics/blob/main/src/credit_risk_pipeline.py"
click node_clean "https://github.com/funaturalstone/credit-risk-analytics/blob/main/src/credit_risk_pipeline.py"
click node_split "https://github.com/funaturalstone/credit-risk-analytics/blob/main/src/credit_risk_pipeline.py"
click node_preprocess "https://github.com/funaturalstone/credit-risk-analytics/blob/main/src/credit_risk_pipeline.py"
click node_train "https://github.com/funaturalstone/credit-risk-analytics/blob/main/src/credit_risk_pipeline.py"
click node_threshold "https://github.com/funaturalstone/credit-risk-analytics/blob/main/src/credit_risk_pipeline.py"
click node_validation "https://github.com/funaturalstone/credit-risk-analytics/blob/main/src/credit_risk_pipeline.py"
click node_test "https://github.com/funaturalstone/credit-risk-analytics/blob/main/src/credit_risk_pipeline.py"
click node_explain "https://github.com/funaturalstone/credit-risk-analytics/blob/main/src/credit_risk_pipeline.py"
click node_results "https://github.com/funaturalstone/credit-risk-analytics/tree/main/docs/data"
click node_loader "https://github.com/funaturalstone/credit-risk-analytics/blob/main/sql/load_data.py"
click node_sql_analysis "https://github.com/funaturalstone/credit-risk-analytics/blob/main/sql/analysis.sql"
click node_dashboard_one "https://github.com/funaturalstone/credit-risk-analytics/blob/main/src/create_dashboard.py"
click node_dashboard_two "https://github.com/funaturalstone/credit-risk-analytics/blob/main/src/create_dashboard_v2.py"
click node_dashboard_html "https://github.com/funaturalstone/credit-risk-analytics/blob/main/docs/dashboard.html"
click node_dashboard_v2_html "https://github.com/funaturalstone/credit-risk-analytics/blob/main/docs/dashboard_v2.html"

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_notebook,node_script_pipeline,node_clean,node_split,node_preprocess,node_train,node_threshold,node_validation,node_test,node_explain toneBlue
class node_loader,node_loan_db,node_sql_analysis toneAmber
class node_results,node_dashboard_one,node_dashboard_two,node_dashboard_html,node_dashboard_v2_html toneMint
class node_analyst,node_raw_loans toneIndigo
```

## Components

### Credit Modeling

- [Full Pipeline Notebook](https://github.com/funaturalstone/credit-risk-analytics/blob/main/notebooks/credit_risk_pipeline.ipynb): `notebooks/credit_risk_pipeline.ipynb`
- [Script Pipeline](https://github.com/funaturalstone/credit-risk-analytics/blob/main/src/credit_risk_pipeline.py): `src/credit_risk_pipeline.py`
- [Clean And Impute](https://github.com/funaturalstone/credit-risk-analytics/blob/main/src/credit_risk_pipeline.py): `src/credit_risk_pipeline.py`
- [Stratified Split](https://github.com/funaturalstone/credit-risk-analytics/blob/main/src/credit_risk_pipeline.py): `src/credit_risk_pipeline.py`
- [Feature Encoding](https://github.com/funaturalstone/credit-risk-analytics/blob/main/src/credit_risk_pipeline.py): `src/credit_risk_pipeline.py`
- [Model Training](https://github.com/funaturalstone/credit-risk-analytics/blob/main/src/credit_risk_pipeline.py): `src/credit_risk_pipeline.py`
- [Profit Threshold](https://github.com/funaturalstone/credit-risk-analytics/blob/main/src/credit_risk_pipeline.py): `src/credit_risk_pipeline.py`
- [Model Checks](https://github.com/funaturalstone/credit-risk-analytics/blob/main/src/credit_risk_pipeline.py): `src/credit_risk_pipeline.py`
- [Held-Out Test](https://github.com/funaturalstone/credit-risk-analytics/blob/main/src/credit_risk_pipeline.py): `src/credit_risk_pipeline.py`
- [Model Explanations](https://github.com/funaturalstone/credit-risk-analytics/blob/main/src/credit_risk_pipeline.py): `src/credit_risk_pipeline.py`

### Loan Book Analysis

- [SQLite Loader](https://github.com/funaturalstone/credit-risk-analytics/blob/main/sql/load_data.py): `sql/load_data.py`
- **Loans Database**
- [Portfolio Queries](https://github.com/funaturalstone/credit-risk-analytics/blob/main/sql/analysis.sql): `sql/analysis.sql`

### Reporting

- [Result CSVs](https://github.com/funaturalstone/credit-risk-analytics/tree/main/docs/data): `docs/data`
- [Results Dashboard](https://github.com/funaturalstone/credit-risk-analytics/blob/main/src/create_dashboard.py): `src/create_dashboard.py`
- [Portfolio Dashboard](https://github.com/funaturalstone/credit-risk-analytics/blob/main/src/create_dashboard_v2.py): `src/create_dashboard_v2.py`
- [Dashboard Output](https://github.com/funaturalstone/credit-risk-analytics/blob/main/docs/dashboard.html): `docs/dashboard.html`
- [Second Dashboard](https://github.com/funaturalstone/credit-risk-analytics/blob/main/docs/dashboard_v2.html): `docs/dashboard_v2.html`

### Other components

- **Analyst**
- **Loan CSV**

## Connections

- Analyst → Full Pipeline Notebook: runs pipeline (evidence: `README.md`)
- Loan CSV → Full Pipeline Notebook: provides loans (evidence: `README.md`)
- Analyst → Script Pipeline: runs pipeline (evidence: `README.md`)
- Loan CSV → Script Pipeline: provides loans (evidence: `README.md`)
- Script Pipeline → Clean And Impute: performs (evidence: `src/credit_risk_pipeline.py`)
- Clean And Impute → Stratified Split: then splits (evidence: `README.md`)
- Stratified Split → Feature Encoding: then encodes (evidence: `README.md`)
- Feature Encoding → Model Training: then trains (evidence: `README.md`)
- Model Training → Profit Threshold: tunes on validation (evidence: `README.md`)
- Profit Threshold → Model Checks: compares baselines (evidence: `README.md`)
- Model Checks → Held-Out Test: selects final run (evidence: `README.md`)
- Model Training → Model Explanations: explains predictions (evidence: `README.md`)
- Full Pipeline Notebook → Result CSVs: saves results (evidence: `README.md`)
- Analyst → SQLite Loader: loads loan CSV (evidence: `README.md`)
- Loan CSV → SQLite Loader: reads rows (evidence: `sql/load_data.py`)
- SQLite Loader → Loans Database: writes loans (evidence: `sql/load_data.py`)
- Loans Database → Portfolio Queries: queries loan book (evidence: `README.md`)
- Result CSVs → Results Dashboard: reads results (evidence: `src/create_dashboard.py`)
- Results Dashboard → Dashboard Output: writes dashboard (evidence: `src/create_dashboard.py`)
- Result CSVs → Portfolio Dashboard: reads results (evidence: `src/create_dashboard_v2.py`)
- Loans Database → Portfolio Dashboard: queries loan data (evidence: `src/create_dashboard_v2.py`)
- Portfolio Dashboard → Second Dashboard: writes dashboard (evidence: `src/create_dashboard_v2.py`)
