# gyrojoestar/fraud-detection architecture

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

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

## Overview

This repository combines offline fraud-model development with a small prediction API and a separate Supabase data-preparation/storage path. The principal serving workflow accepts 29 transaction features, loads the highest-PR-AUC model from MLflow at startup, and returns a fraud probability and label. Database seeding and exploratory user grouping are not wired into prediction in the sampled source; the README provides no further capability detail.

Main entry points: [`backend/main.py`](https://github.com/gyrojoestar/fraud-detection/blob/main/backend/main.py) (Prediction service), [`database/populate_supabase.py`](https://github.com/gyrojoestar/fraud-detection/blob/main/database/populate_supabase.py) (Database seeding), [`model_training/train.py`](https://github.com/gyrojoestar/fraud-detection/blob/main/model_training/train.py) (Model training), [`eda.py`](https://github.com/gyrojoestar/fraud-detection/blob/main/eda.py) (EDA and grouping)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_serving["Prediction API"]
  node_api["Prediction service<br/>[main.py]"]
  node_model["XGBoost model<br/>[main.py]"]
end

subgraph group_ml["Model lifecycle"]
  node_train["Model training<br/>[train.py]"]
  node_mlflow[("MLflow tracking")]
  node_rawdata["Transaction dataset"]
end

subgraph group_data["Transaction data"]
  node_eda["EDA and grouping<br/>[eda.py]"]
  node_seed["Database seeding"]
  node_schema["Transaction schema<br/>[model.py]"]
  node_connection["DB sessions<br/>[connection.py]"]
  node_postgres[("Supabase PostgreSQL")]
  node_query["Sample query<br/>[app.py]"]
end

node_client(("API client"))

node_client -->|"submits features"| node_api
node_api -->|"predicts probability"| node_model
node_api -->|"loads best run"| node_mlflow
node_train -->|"reads dataset"| node_rawdata
node_train -->|"logs model"| node_mlflow
node_eda -->|"reads dataset"| node_rawdata
node_eda -->|"writes seed CSV"| node_seed
node_seed -->|"requests session"| node_connection
node_seed -->|"inserts records"| node_schema
node_connection -->|"opens sessions"| node_postgres
node_query -->|"queries transactions"| node_postgres

click node_api "https://github.com/gyrojoestar/fraud-detection/blob/main/backend/main.py"
click node_model "https://github.com/gyrojoestar/fraud-detection/blob/main/backend/main.py"
click node_train "https://github.com/gyrojoestar/fraud-detection/blob/main/model_training/train.py"
click node_eda "https://github.com/gyrojoestar/fraud-detection/blob/main/eda.py"
click node_seed "https://github.com/gyrojoestar/fraud-detection/blob/main/database/populate_supabase.py"
click node_schema "https://github.com/gyrojoestar/fraud-detection/blob/main/database/model.py"
click node_connection "https://github.com/gyrojoestar/fraud-detection/blob/main/database/connection.py"
click node_query "https://github.com/gyrojoestar/fraud-detection/blob/main/app.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_api,node_model,node_client toneBlue
class node_train,node_mlflow,node_rawdata toneAmber
class node_eda,node_seed,node_schema,node_connection,node_postgres,node_query toneMint
```

## Components

### Prediction API

- [Prediction service](https://github.com/gyrojoestar/fraud-detection/blob/main/backend/main.py): `backend/main.py`
- [XGBoost model](https://github.com/gyrojoestar/fraud-detection/blob/main/backend/main.py): `backend/main.py`

### Model lifecycle

- [Model training](https://github.com/gyrojoestar/fraud-detection/blob/main/model_training/train.py): `model_training/train.py`
- **MLflow tracking**
- **Transaction dataset**

### Transaction data

- [EDA and grouping](https://github.com/gyrojoestar/fraud-detection/blob/main/eda.py): `eda.py`
- [Database seeding](https://github.com/gyrojoestar/fraud-detection/blob/main/database/populate_supabase.py): `database/populate_supabase.py`
- [Transaction schema](https://github.com/gyrojoestar/fraud-detection/blob/main/database/model.py): `database/model.py`
- [DB sessions](https://github.com/gyrojoestar/fraud-detection/blob/main/database/connection.py): `database/connection.py`
- **Supabase PostgreSQL**
- [Sample query](https://github.com/gyrojoestar/fraud-detection/blob/main/app.py): `app.py`

### Other components

- **API client**

## Connections

- API client → Prediction service: submits features
- Prediction service → XGBoost model: predicts probability
- Prediction service → MLflow tracking: loads best run
- Model training → Transaction dataset: reads dataset
- Model training → MLflow tracking: logs model
- EDA and grouping → Transaction dataset: reads dataset
- EDA and grouping → Database seeding: writes seed CSV
- Database seeding → DB sessions: requests session
- Database seeding → Transaction schema: inserts records
- DB sessions → Supabase PostgreSQL: opens sessions
- Sample query → Supabase PostgreSQL: queries transactions
