# bozya/saccopred architecture

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

- Interactive diagram: https://gitdiagram.com/bozya/saccopred
- Repository: https://github.com/bozya/saccopred

## Overview

This repository predicts financial distress in SACCOs through a Streamlit web app and a command-line pipeline. Users provide a panel dataset or generate synthetic data, train and compare Logistic Regression, Random Forest, XGBoost, and optionally an LSTM, then inspect diagnostics or score an individual SACCO. The README documents file-based outputs and data exploration. The excerpts show the web app’s calls into the predictor, but omit much of the core pipeline, so internal CLI and reporting links rely on README statements rather than inspected implementation details.

Main entry points: [`sacco_predictor.py`](https://github.com/bozya/saccopred/blob/main/sacco_predictor.py) (CLI pipeline), [`app.py`](https://github.com/bozya/saccopred/blob/main/app.py) (Web model training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_streamlit_app["Streamlit app<br/>[app.py]"]
  node_cli_pipeline["CLI pipeline<br/>[sacco_predictor.py]"]
end

subgraph group_data["Data preparation"]
  node_dataset_input["Dataset input<br/>[app.py]"]
  node_synthetic_data["Synthetic data<br/>[sacco_predictor.py]"]
  node_feature_prep["Feature preparation<br/>[sacco_predictor.py]"]
  node_sequence_prep["Sequence preparation<br/>[sacco_predictor.py]"]
end

subgraph group_models["Modeling"]
  node_tabular_models["Tabular models<br/>[sacco_predictor.py]"]
  node_lstm_model["LSTM model<br/>[sacco_predictor.py]"]
  node_web_training["Web model training<br/>[app.py]"]
end

subgraph group_results["Prediction and analysis"]
  node_evaluation["Model evaluation<br/>[sacco_predictor.py]"]
  node_comparison["Model comparison<br/>[app.py]"]
  node_sacco_scoring["SACCO scoring<br/>[app.py]"]
  node_data_explorer["Data explorer<br/>[app.py]"]
  node_diagnostics["Model diagnostics<br/>[sacco_predictor.py]"]
  node_output_files["Result files"]
end

node_web_user(("Web user"))
node_cli_user(("CLI user"))

node_web_user -->|"uses"| node_streamlit_app
node_cli_user -->|"runs"| node_cli_pipeline
node_streamlit_app -->|"loads"| node_dataset_input
node_streamlit_app -->|"generates"| node_synthetic_data
node_streamlit_app -->|"starts"| node_web_training
node_web_training -->|"prepares features"| node_feature_prep
node_web_training -->|"trains"| node_tabular_models
node_web_training -->|"builds sequences"| node_sequence_prep
node_web_training -->|"trains optionally"| node_lstm_model
node_web_training -->|"collects metrics"| node_evaluation
node_web_training -->|"builds comparison"| node_comparison
node_streamlit_app -->|"scores SACCO"| node_sacco_scoring
node_streamlit_app -->|"explores data"| node_data_explorer
node_cli_pipeline -->|"generates optionally"| node_synthetic_data
node_cli_pipeline -->|"loads optionally"| node_dataset_input
node_cli_pipeline -->|"prepares data"| node_feature_prep
node_cli_pipeline -->|"trains"| node_tabular_models
node_cli_pipeline -->|"trains optionally"| node_lstm_model
node_cli_pipeline -->|"evaluates models"| node_evaluation
node_cli_pipeline -->|"produces"| node_diagnostics
node_cli_pipeline -->|"writes"| node_output_files

click node_streamlit_app "https://github.com/bozya/saccopred/blob/main/app.py"
click node_cli_pipeline "https://github.com/bozya/saccopred/blob/main/sacco_predictor.py"
click node_dataset_input "https://github.com/bozya/saccopred/blob/main/app.py"
click node_synthetic_data "https://github.com/bozya/saccopred/blob/main/sacco_predictor.py"
click node_feature_prep "https://github.com/bozya/saccopred/blob/main/sacco_predictor.py"
click node_sequence_prep "https://github.com/bozya/saccopred/blob/main/sacco_predictor.py"
click node_tabular_models "https://github.com/bozya/saccopred/blob/main/sacco_predictor.py"
click node_lstm_model "https://github.com/bozya/saccopred/blob/main/sacco_predictor.py"
click node_web_training "https://github.com/bozya/saccopred/blob/main/app.py"
click node_evaluation "https://github.com/bozya/saccopred/blob/main/sacco_predictor.py"
click node_comparison "https://github.com/bozya/saccopred/blob/main/app.py"
click node_sacco_scoring "https://github.com/bozya/saccopred/blob/main/app.py"
click node_data_explorer "https://github.com/bozya/saccopred/blob/main/app.py"
click node_diagnostics "https://github.com/bozya/saccopred/blob/main/sacco_predictor.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_app,node_cli_pipeline,node_web_user,node_cli_user toneBlue
class node_dataset_input,node_synthetic_data,node_feature_prep,node_sequence_prep toneAmber
class node_tabular_models,node_lstm_model,node_web_training toneMint
class node_evaluation,node_comparison,node_sacco_scoring,node_data_explorer,node_diagnostics,node_output_files toneRose
```

## Components

### User interfaces

- [Streamlit app](https://github.com/bozya/saccopred/blob/main/app.py): `app.py`
- [CLI pipeline](https://github.com/bozya/saccopred/blob/main/sacco_predictor.py): `sacco_predictor.py`

### Data preparation

- [Dataset input](https://github.com/bozya/saccopred/blob/main/app.py): `app.py`
- [Synthetic data](https://github.com/bozya/saccopred/blob/main/sacco_predictor.py): `sacco_predictor.py`
- [Feature preparation](https://github.com/bozya/saccopred/blob/main/sacco_predictor.py): `sacco_predictor.py`
- [Sequence preparation](https://github.com/bozya/saccopred/blob/main/sacco_predictor.py): `sacco_predictor.py`

### Modeling

- [Tabular models](https://github.com/bozya/saccopred/blob/main/sacco_predictor.py): `sacco_predictor.py`
- [LSTM model](https://github.com/bozya/saccopred/blob/main/sacco_predictor.py): `sacco_predictor.py`
- [Web model training](https://github.com/bozya/saccopred/blob/main/app.py): `app.py`

### Prediction and analysis

- [Model evaluation](https://github.com/bozya/saccopred/blob/main/sacco_predictor.py): `sacco_predictor.py`
- [Model comparison](https://github.com/bozya/saccopred/blob/main/app.py): `app.py`
- [SACCO scoring](https://github.com/bozya/saccopred/blob/main/app.py): `app.py`
- [Data explorer](https://github.com/bozya/saccopred/blob/main/app.py): `app.py`
- [Model diagnostics](https://github.com/bozya/saccopred/blob/main/sacco_predictor.py): `sacco_predictor.py`
- **Result files**

### Other components

- **Web user**
- **CLI user**

## Connections

- Web user → Streamlit app: uses (evidence: `README.md`)
- CLI user → CLI pipeline: runs (evidence: `README.md`)
- Streamlit app → Dataset input: loads (evidence: `app.py`)
- Streamlit app → Synthetic data: generates (evidence: `app.py`)
- Streamlit app → Web model training: starts (evidence: `app.py`)
- Web model training → Feature preparation: prepares features (evidence: `app.py`)
- Web model training → Tabular models: trains (evidence: `README.md`)
- Web model training → Sequence preparation: builds sequences (evidence: `app.py`)
- Web model training → LSTM model: trains optionally (evidence: `app.py`)
- Web model training → Model evaluation: collects metrics (evidence: `app.py`)
- Web model training → Model comparison: builds comparison (evidence: `app.py`)
- Streamlit app → SACCO scoring: scores SACCO (evidence: `README.md`)
- Streamlit app → Data explorer: explores data (evidence: `README.md`)
- CLI pipeline → Synthetic data: generates optionally (evidence: `README.md`)
- CLI pipeline → Dataset input: loads optionally (evidence: `README.md`)
- CLI pipeline → Feature preparation: prepares data (evidence: `README.md`)
- CLI pipeline → Tabular models: trains (evidence: `README.md`)
- CLI pipeline → LSTM model: trains optionally (evidence: `README.md`)
- CLI pipeline → Model evaluation: evaluates models (evidence: `README.md`)
- CLI pipeline → Model diagnostics: produces (evidence: `README.md`)
- CLI pipeline → Result files: writes (evidence: `README.md`)
