# pypcoder/ledger architecture

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

- Interactive diagram: https://gitdiagram.com/pypcoder/ledger
- Repository: https://github.com/pypcoder/ledger

## Overview

Ledger is a Streamlit loan-approval prediction app. An applicant enters loan and personal details, chooses the ensemble or an individual model and a decision threshold, then submits an evaluation. The app preprocesses the fields and sends them to the selected inference path; it displays an approval probability and decision, with per-model probabilities for ensemble runs. A separate performance view presents saved test metrics. The source excerpts show these runtime connections; model artifacts are present in the tree, but a results-summary CSV is not.

Main entry points: [`app.py`](https://github.com/pypcoder/ledger/blob/main/app.py) (Streamlit application), [`ensemble.py`](https://github.com/pypcoder/ledger/blob/main/ensemble.py) (Model loading and inference), [`config.py`](https://github.com/pypcoder/ledger/blob/main/config.py) (Feature and model settings), [`preprocessing.py`](https://github.com/pypcoder/ledger/blob/main/preprocessing.py) (Input preprocessing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Applicant interface"]
  node_app["Streamlit application<br/>[app.py]"]
end

subgraph group_inference["Prediction pipeline"]
  node_preprocess["Input preprocessing<br/>[preprocessing.py]"]
  node_ensemble["Model loading and inference<br/>[ensemble.py]"]
  node_mlp["Monotonic MLP<br/>[models.py]"]
end

subgraph group_assets["Models and configuration"]
  node_config["Feature and model settings<br/>[config.py]"]
  node_artifacts["Saved model artifacts"]
end

subgraph group_presentation["Results and styling"]
  node_theme["UI styling and result HTML<br/>[theme.py]"]
  node_metrics["Held-out performance summary"]
end

node_applicant(("Applicant"))

node_applicant -->|"submits application"| node_app
node_app -->|"preprocesses fields"| node_preprocess
node_app -->|"requests predictions"| node_ensemble
node_ensemble -->|"uses architecture"| node_mlp
node_ensemble -->|"loads paths"| node_config
node_preprocess -->|"uses mappings"| node_config
node_ensemble -->|"loads models"| node_artifacts
node_ensemble -->|"reads metrics"| node_metrics
node_app -->|"uses choices"| node_config
node_app -->|"renders interface"| node_theme

click node_app "https://github.com/pypcoder/ledger/blob/main/app.py"
click node_preprocess "https://github.com/pypcoder/ledger/blob/main/preprocessing.py"
click node_ensemble "https://github.com/pypcoder/ledger/blob/main/ensemble.py"
click node_mlp "https://github.com/pypcoder/ledger/blob/main/models.py"
click node_config "https://github.com/pypcoder/ledger/blob/main/config.py"
click node_artifacts "https://github.com/pypcoder/ledger/tree/main/models_saved"
click node_theme "https://github.com/pypcoder/ledger/blob/main/theme.py"
click node_metrics "https://github.com/pypcoder/ledger/tree/main/models_saved"

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_app toneBlue
class node_preprocess,node_ensemble,node_mlp toneAmber
class node_config,node_artifacts toneMint
class node_theme,node_metrics toneRose
class node_applicant toneIndigo
```

## Components

### Applicant interface

- [Streamlit application](https://github.com/pypcoder/ledger/blob/main/app.py): `app.py`

### Prediction pipeline

- [Input preprocessing](https://github.com/pypcoder/ledger/blob/main/preprocessing.py): `preprocessing.py`
- [Model loading and inference](https://github.com/pypcoder/ledger/blob/main/ensemble.py): `ensemble.py`
- [Monotonic MLP](https://github.com/pypcoder/ledger/blob/main/models.py): `models.py`

### Models and configuration

- [Feature and model settings](https://github.com/pypcoder/ledger/blob/main/config.py): `config.py`
- [Saved model artifacts](https://github.com/pypcoder/ledger/tree/main/models_saved): `models_saved`

### Results and styling

- [UI styling and result HTML](https://github.com/pypcoder/ledger/blob/main/theme.py): `theme.py`
- [Held-out performance summary](https://github.com/pypcoder/ledger/tree/main/models_saved): `models_saved`

### Other components

- **Applicant**

## Connections

- Applicant → Streamlit application: submits application (evidence: `app.py`)
- Streamlit application → Input preprocessing: preprocesses fields (evidence: `app.py`)
- Streamlit application → Model loading and inference: requests predictions (evidence: `app.py`)
- Model loading and inference → Monotonic MLP: uses architecture (evidence: `ensemble.py`)
- Model loading and inference → Feature and model settings: loads paths (evidence: `ensemble.py`)
- Input preprocessing → Feature and model settings: uses mappings (evidence: `preprocessing.py`)
- Model loading and inference → Saved model artifacts: loads models (evidence: `ensemble.py`)
- Model loading and inference → Held-out performance summary: reads metrics (evidence: `ensemble.py`)
- Streamlit application → Feature and model settings: uses choices (evidence: `app.py`)
- Streamlit application → UI styling and result HTML: renders interface (evidence: `app.py`)
