# panda7ad/credit-sure architecture

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

- Interactive diagram: https://gitdiagram.com/panda7ad/credit-sure
- Repository: https://github.com/panda7ad/credit-sure

## Overview

Credit-Sure is a synthetic-input credit-risk research calculator with an optional, separate model-reproduction pipeline. Its main workflow runs from a browser assessment through FastAPI validation and protected inference to a probability, score, risk band, and explanatory factors displayed in the browser. Training prepares Home Credit data, explores it, and fits candidate models. README-documented capabilities are included; relationships for the unsampled browser implementation and some training wiring rely on README statements or indexed references.

Main entry points: [`src/train.py`](https://github.com/panda7ad/credit-sure/blob/main/src/train.py) (Model training), [`app/main.py`](https://github.com/panda7ad/credit-sure/blob/main/app/main.py) (FastAPI routes), [`app/model_service.py`](https://github.com/panda7ad/credit-sure/blob/main/app/model_service.py) (Risk inference), [`src/build_dataset.py`](https://github.com/panda7ad/credit-sure/blob/main/src/build_dataset.py) (Dataset preparation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_serving["Assessment service"]
  node_api["FastAPI routes<br/>[main.py]"]
  node_validation["Request validation<br/>[schemas.py]"]
  node_security["Request protection<br/>[security.py]"]
  node_model_service["Risk inference<br/>[model_service.py]"]
  node_redis[("Redis counters")]
end

subgraph group_experience["Web experience"]
  node_workspace["Assessment form<br/>[workspace.html]"]
  node_workspace_js["Form interaction<br/>[workspace.js]"]
  node_result_ui["Result display<br/>[workspace.js]"]
end

subgraph group_training["Model pipeline"]
  node_features["Feature engineering<br/>[features.py]"]
  node_config["Path configuration<br/>[config.py]"]
  node_raw_data["Raw datasets"]
  node_dataset["Dataset preparation<br/>[build_dataset.py]"]
  node_processed_data["Training table"]
  node_eda["Exploratory analysis<br/>[eda.py]"]
  node_reports["Experiment reports"]
  node_trainer["Model training<br/>[train.py]"]
  node_pipeline["Pipeline runner<br/>[run_pipeline.py]"]
end

subgraph group_artifacts["Model artifacts"]
  node_model_file["Trained estimator"]
  node_metadata["Model metadata<br/>[metadata.json]"]
  node_manifest["Integrity manifest<br/>[manifest.json]"]
end

node_applicant(("Synthetic applicant"))

node_applicant -->|"enters values"| node_workspace
node_workspace -->|"uses interaction"| node_workspace_js
node_workspace_js -->|"submits assessment"| node_api
node_api -->|"validates request"| node_validation
node_api -->|"applies protection"| node_security
node_security -.->|"checks shared limits"| node_redis
node_api -->|"invokes prediction"| node_model_service
node_model_service -->|"engineers features"| node_features
node_model_service -->|"loads estimator"| node_model_file
node_model_service -->|"loads metadata"| node_metadata
node_model_service -->|"verifies artifacts"| node_manifest
node_api -->|"returns JSON result"| node_result_ui
node_workspace_js -.->|"renders result"| node_result_ui
node_pipeline -->|"runs stage"| node_dataset
node_pipeline -->|"runs stage"| node_eda
node_pipeline -->|"runs stage"| node_trainer
node_dataset -->|"reads tables"| node_raw_data
node_dataset -->|"writes table"| node_processed_data
node_eda -->|"reads table"| node_processed_data
node_eda -->|"writes summaries"| node_reports
node_trainer -->|"reads table"| node_processed_data
node_trainer -->|"engineers features"| node_features
node_trainer -->|"writes estimator"| node_model_file
node_trainer -->|"writes metadata"| node_metadata
node_trainer -->|"writes metrics"| node_reports
node_dataset -->|"uses paths"| node_config
node_eda -->|"uses paths"| node_config
node_trainer -->|"uses paths"| node_config

click node_workspace "https://github.com/panda7ad/credit-sure/blob/main/web/workspace.html"
click node_workspace_js "https://github.com/panda7ad/credit-sure/blob/main/web/workspace.js"
click node_result_ui "https://github.com/panda7ad/credit-sure/blob/main/web/workspace.js"
click node_api "https://github.com/panda7ad/credit-sure/blob/main/app/main.py"
click node_validation "https://github.com/panda7ad/credit-sure/blob/main/app/schemas.py"
click node_security "https://github.com/panda7ad/credit-sure/blob/main/app/security.py"
click node_model_service "https://github.com/panda7ad/credit-sure/blob/main/app/model_service.py"
click node_features "https://github.com/panda7ad/credit-sure/blob/main/src/features.py"
click node_config "https://github.com/panda7ad/credit-sure/blob/main/config.py"
click node_raw_data "https://github.com/panda7ad/credit-sure/tree/main/data/raw"
click node_dataset "https://github.com/panda7ad/credit-sure/blob/main/src/build_dataset.py"
click node_processed_data "https://github.com/panda7ad/credit-sure/tree/main/data/processed"
click node_eda "https://github.com/panda7ad/credit-sure/blob/main/src/eda.py"
click node_reports "https://github.com/panda7ad/credit-sure/tree/main/reports"
click node_trainer "https://github.com/panda7ad/credit-sure/blob/main/src/train.py"
click node_pipeline "https://github.com/panda7ad/credit-sure/blob/main/run_pipeline.py"
click node_model_file "https://github.com/panda7ad/credit-sure/blob/main/models/credit_model.joblib"
click node_metadata "https://github.com/panda7ad/credit-sure/blob/main/models/metadata.json"
click node_manifest "https://github.com/panda7ad/credit-sure/blob/main/models/manifest.json"

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_api,node_validation,node_security,node_model_service,node_redis toneBlue
class node_workspace,node_workspace_js,node_result_ui toneAmber
class node_features,node_config,node_raw_data,node_dataset,node_processed_data,node_eda,node_reports,node_trainer,node_pipeline toneMint
class node_model_file,node_metadata,node_manifest toneRose
class node_applicant toneIndigo
```

## Components

### Assessment service

- [FastAPI routes](https://github.com/panda7ad/credit-sure/blob/main/app/main.py): `app/main.py`
- [Request validation](https://github.com/panda7ad/credit-sure/blob/main/app/schemas.py): `app/schemas.py`
- [Request protection](https://github.com/panda7ad/credit-sure/blob/main/app/security.py): `app/security.py`
- [Risk inference](https://github.com/panda7ad/credit-sure/blob/main/app/model_service.py): `app/model_service.py`
- **Redis counters**

### Web experience

- [Assessment form](https://github.com/panda7ad/credit-sure/blob/main/web/workspace.html): `web/workspace.html`
- [Form interaction](https://github.com/panda7ad/credit-sure/blob/main/web/workspace.js): `web/workspace.js`
- [Result display](https://github.com/panda7ad/credit-sure/blob/main/web/workspace.js): `web/workspace.js`

### Model pipeline

- [Feature engineering](https://github.com/panda7ad/credit-sure/blob/main/src/features.py): `src/features.py`
- [Path configuration](https://github.com/panda7ad/credit-sure/blob/main/config.py): `config.py`
- [Raw datasets](https://github.com/panda7ad/credit-sure/tree/main/data/raw): `data/raw`
- [Dataset preparation](https://github.com/panda7ad/credit-sure/blob/main/src/build_dataset.py): `src/build_dataset.py`
- [Training table](https://github.com/panda7ad/credit-sure/tree/main/data/processed): `data/processed`
- [Exploratory analysis](https://github.com/panda7ad/credit-sure/blob/main/src/eda.py): `src/eda.py`
- [Experiment reports](https://github.com/panda7ad/credit-sure/tree/main/reports): `reports`
- [Model training](https://github.com/panda7ad/credit-sure/blob/main/src/train.py): `src/train.py`
- [Pipeline runner](https://github.com/panda7ad/credit-sure/blob/main/run_pipeline.py): `run_pipeline.py`

### Model artifacts

- [Trained estimator](https://github.com/panda7ad/credit-sure/blob/main/models/credit_model.joblib): `models/credit_model.joblib`
- [Model metadata](https://github.com/panda7ad/credit-sure/blob/main/models/metadata.json): `models/metadata.json`
- [Integrity manifest](https://github.com/panda7ad/credit-sure/blob/main/models/manifest.json): `models/manifest.json`

### Other components

- **Synthetic applicant**

## Connections

- Synthetic applicant → Assessment form: enters values (evidence: `README.md`)
- Assessment form → Form interaction: uses interaction (evidence: `README.md`)
- Form interaction → FastAPI routes: submits assessment (evidence: `README.md`)
- FastAPI routes → Request validation: validates request (evidence: `app/main.py`)
- FastAPI routes → Request protection: applies protection (evidence: `app/main.py`)
- Request protection → Redis counters: checks shared limits (evidence: `app/security.py`)
- FastAPI routes → Risk inference: invokes prediction (evidence: `app/main.py`)
- Risk inference → Feature engineering: engineers features (evidence: `app/model_service.py`)
- Risk inference → Trained estimator: loads estimator (evidence: `app/model_service.py`)
- Risk inference → Model metadata: loads metadata (evidence: `app/model_service.py`)
- Risk inference → Integrity manifest: verifies artifacts (evidence: `app/model_service.py`)
- FastAPI routes → Result display: returns JSON result (evidence: `README.md`)
- Form interaction → Result display: renders result (evidence: `README.md`)
- Pipeline runner → Dataset preparation: runs stage (evidence: `run_pipeline.py`)
- Pipeline runner → Exploratory analysis: runs stage (evidence: `run_pipeline.py`)
- Pipeline runner → Model training: runs stage (evidence: `run_pipeline.py`)
- Dataset preparation → Raw datasets: reads tables (evidence: `src/build_dataset.py`)
- Dataset preparation → Training table: writes table (evidence: `src/build_dataset.py`)
- Exploratory analysis → Training table: reads table (evidence: `src/eda.py`)
- Exploratory analysis → Experiment reports: writes summaries (evidence: `src/eda.py`)
- Model training → Training table: reads table (evidence: `src/train.py`)
- Model training → Feature engineering: engineers features (evidence: `src/train.py`)
- Model training → Trained estimator: writes estimator (evidence: `src/train.py`)
- Model training → Model metadata: writes metadata (evidence: `src/train.py`)
- Model training → Experiment reports: writes metrics (evidence: `src/train.py`)
- Dataset preparation → Path configuration: uses paths (evidence: `src/build_dataset.py`)
- Exploratory analysis → Path configuration: uses paths (evidence: `src/eda.py`)
- Model training → Path configuration: uses paths (evidence: `src/train.py`)
