# olasumboor/fraud-detection architecture

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

- Interactive diagram: https://gitdiagram.com/olasumboor/fraud-detection
- Repository: https://github.com/olasumboor/fraud-detection

## Overview

This repository implements a credit-card fraud detection workflow: transaction data is scaled and split, classifiers are trained and evaluated, XGBoost can be tuned, and a FastAPI service returns fraud probabilities and threshold-based decisions. The notebooks suggest additional analysis and reporting, but their contents were not sampled; the README is empty, so those capabilities and their wiring are not detailed. The graph focuses on behavior evidenced by source and the artifact tree.

Main entry points: [`src/train.py`](https://github.com/olasumboor/fraud-detection/blob/master/src/train.py) (Train classifiers), [`src/api.py`](https://github.com/olasumboor/fraud-detection/blob/master/src/api.py) (Fraud scoring API), [`src/preprocess.py`](https://github.com/olasumboor/fraud-detection/blob/master/src/preprocess.py) (Scale and split), [`src/tune.py`](https://github.com/olasumboor/fraud-detection/blob/master/src/tune.py) (Tune XGBoost)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_preprocess["Scale and split<br/>[preprocess.py]"]
  node_splits["Processed splits"]
end

subgraph group_models["Model development"]
  node_train["Train classifiers<br/>[train.py]"]
  node_evaluation["Model evaluation<br/>[train.py]"]
  node_baseline_lr["Logistic model"]
  node_baseline_rf["Random forest"]
  node_baseline_xgb["XGBoost model<br/>[xgboost.joblib]"]
  node_tune["Tune XGBoost<br/>[tune.py]"]
  node_tuned_model["Tuned model"]
  node_model_meta["Threshold metadata"]
end

subgraph group_serving["Prediction service"]
  node_api["Fraud scoring API<br/>[api.py]"]
  node_transaction["Transaction input<br/>[api.py]"]
  node_prediction["Fraud prediction<br/>[api.py]"]
end

node_dataset["Credit-card data"]
node_client(("API client"))

node_dataset -->|"reads"| node_preprocess
node_preprocess -->|"writes"| node_splits
node_splits -->|"loads"| node_train
node_train -->|"evaluates"| node_evaluation
node_train -->|"saves"| node_baseline_lr
node_train -->|"saves"| node_baseline_rf
node_train -->|"saves"| node_baseline_xgb
node_splits -->|"tunes on"| node_tune
node_tune -->|"saves"| node_tuned_model
node_client -->|"requests score"| node_api
node_api -->|"validates"| node_transaction
node_api -->|"loads"| node_tuned_model
node_api -->|"loads"| node_model_meta
node_api -->|"returns"| node_prediction

click node_preprocess "https://github.com/olasumboor/fraud-detection/blob/master/src/preprocess.py"
click node_train "https://github.com/olasumboor/fraud-detection/blob/master/src/train.py"
click node_evaluation "https://github.com/olasumboor/fraud-detection/blob/master/src/train.py"
click node_baseline_lr "https://github.com/olasumboor/fraud-detection/blob/master/models/logistic_regression.joblib"
click node_baseline_rf "https://github.com/olasumboor/fraud-detection/blob/master/models/random_forest.joblib"
click node_baseline_xgb "https://github.com/olasumboor/fraud-detection/blob/master/models/xgboost.joblib"
click node_tune "https://github.com/olasumboor/fraud-detection/blob/master/src/tune.py"
click node_tuned_model "https://github.com/olasumboor/fraud-detection/blob/master/models/xgboost_tuned.joblib"
click node_model_meta "https://github.com/olasumboor/fraud-detection/blob/master/models/xgboost_tuned_meta.json"
click node_api "https://github.com/olasumboor/fraud-detection/blob/master/src/api.py"
click node_transaction "https://github.com/olasumboor/fraud-detection/blob/master/src/api.py"
click node_prediction "https://github.com/olasumboor/fraud-detection/blob/master/src/api.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_preprocess,node_splits,node_client toneBlue
class node_train,node_evaluation,node_baseline_lr,node_baseline_rf,node_baseline_xgb,node_tune,node_tuned_model,node_model_meta toneAmber
class node_api,node_transaction,node_prediction toneMint
class node_dataset toneIndigo
```

## Components

### Data preparation

- [Scale and split](https://github.com/olasumboor/fraud-detection/blob/master/src/preprocess.py): `src/preprocess.py`
- **Processed splits**

### Model development

- [Train classifiers](https://github.com/olasumboor/fraud-detection/blob/master/src/train.py): `src/train.py`
- [Model evaluation](https://github.com/olasumboor/fraud-detection/blob/master/src/train.py): `src/train.py`
- [Logistic model](https://github.com/olasumboor/fraud-detection/blob/master/models/logistic_regression.joblib): `models/logistic_regression.joblib`
- [Random forest](https://github.com/olasumboor/fraud-detection/blob/master/models/random_forest.joblib): `models/random_forest.joblib`
- [XGBoost model](https://github.com/olasumboor/fraud-detection/blob/master/models/xgboost.joblib): `models/xgboost.joblib`
- [Tune XGBoost](https://github.com/olasumboor/fraud-detection/blob/master/src/tune.py): `src/tune.py`
- [Tuned model](https://github.com/olasumboor/fraud-detection/blob/master/models/xgboost_tuned.joblib): `models/xgboost_tuned.joblib`
- [Threshold metadata](https://github.com/olasumboor/fraud-detection/blob/master/models/xgboost_tuned_meta.json): `models/xgboost_tuned_meta.json`

### Prediction service

- [Fraud scoring API](https://github.com/olasumboor/fraud-detection/blob/master/src/api.py): `src/api.py`
- [Transaction input](https://github.com/olasumboor/fraud-detection/blob/master/src/api.py): `src/api.py`
- [Fraud prediction](https://github.com/olasumboor/fraud-detection/blob/master/src/api.py): `src/api.py`

### Other components

- **Credit-card data**
- **API client**

## Connections

- Credit-card data → Scale and split: reads
- Scale and split → Processed splits: writes
- Processed splits → Train classifiers: loads
- Train classifiers → Model evaluation: evaluates
- Train classifiers → Logistic model: saves
- Train classifiers → Random forest: saves
- Train classifiers → XGBoost model: saves
- Processed splits → Tune XGBoost: tunes on
- Tune XGBoost → Tuned model: saves
- API client → Fraud scoring API: requests score
- Fraud scoring API → Transaction input: validates
- Fraud scoring API → Tuned model: loads
- Fraud scoring API → Threshold metadata: loads
- Fraud scoring API → Fraud prediction: returns
