# harshkaushik2203/fraud-detection-classifier architecture

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

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

## Overview

The product develops a fraud classifier for highly imbalanced transactions, selects a business-cost threshold, and serves predictions through FastAPI. The README documents preprocessing, baseline and imbalance-handling comparisons, and threshold tuning; their implementation is represented at the existing notebooks/ directory because notebook source was not sampled. The sampled API shows request validation, amount scaling, model scoring, and threshold-based decisions. Training-stage connections follow the README; runtime connections follow api/main.py. This map omits tests and delivery tooling.

Main entry points: [`api/main.py`](https://github.com/harshkaushik2203/fraud-detection-classifier/blob/main/api/main.py) (Prediction and health API), [`notebooks`](https://github.com/harshkaushik2203/fraud-detection-classifier/tree/main/notebooks) (Data preprocessing), [`src/config.py`](https://github.com/harshkaushik2203/fraud-detection-classifier/blob/main/src/config.py) (Runtime configuration), [`models/xgb_fraud_model.joblib`](https://github.com/harshkaushik2203/fraud-detection-classifier/blob/main/models/xgb_fraud_model.joblib) (Fraud classifier)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_development["Model development"]
  node_preprocessing["Data preprocessing"]
  node_baseline["Baseline model"]
  node_imbalance["Imbalance comparison"]
  node_threshold["Cost threshold tuning"]
end

subgraph group_serving["Prediction API"]
  node_api["Prediction and health API<br/>[main.py]"]
  node_schemas["Request and response schemas<br/>[schemas.py]"]
end

subgraph group_configuration["Runtime configuration"]
  node_config["Runtime configuration<br/>[config.py]"]
end

subgraph group_artifacts["Model artifacts"]
  node_model["Fraud classifier"]
  node_scaler["Amount scaler"]
end

node_user(("Transaction caller"))

node_preprocessing -->|"prepares data for"| node_baseline
node_preprocessing -->|"prepares data for"| node_imbalance
node_imbalance -->|"provides probabilities to"| node_threshold
node_user -->|"submits transaction"| node_api
node_api -->|"validates and formats"| node_schemas
node_api -->|"reads paths and threshold"| node_config
node_api -->|"loads and transforms amount with"| node_scaler
node_api -->|"loads and scores with"| node_model
node_api -->|"returns prediction"| node_user
node_baseline -.->|"compares trained approaches"| node_model
node_threshold -->|"sets decision threshold"| node_config

click node_preprocessing "https://github.com/harshkaushik2203/fraud-detection-classifier/tree/main/notebooks"
click node_baseline "https://github.com/harshkaushik2203/fraud-detection-classifier/tree/main/notebooks"
click node_imbalance "https://github.com/harshkaushik2203/fraud-detection-classifier/tree/main/notebooks"
click node_threshold "https://github.com/harshkaushik2203/fraud-detection-classifier/tree/main/notebooks"
click node_api "https://github.com/harshkaushik2203/fraud-detection-classifier/blob/main/api/main.py"
click node_schemas "https://github.com/harshkaushik2203/fraud-detection-classifier/blob/main/api/schemas.py"
click node_config "https://github.com/harshkaushik2203/fraud-detection-classifier/blob/main/src/config.py"
click node_model "https://github.com/harshkaushik2203/fraud-detection-classifier/blob/main/models/xgb_fraud_model.joblib"
click node_scaler "https://github.com/harshkaushik2203/fraud-detection-classifier/blob/main/models/amount_scaler.joblib"

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_preprocessing,node_baseline,node_imbalance,node_threshold toneBlue
class node_api,node_schemas toneAmber
class node_config toneMint
class node_model,node_scaler toneRose
class node_user toneIndigo
```

## Components

### Model development

- [Data preprocessing](https://github.com/harshkaushik2203/fraud-detection-classifier/tree/main/notebooks): `notebooks`
- [Baseline model](https://github.com/harshkaushik2203/fraud-detection-classifier/tree/main/notebooks): `notebooks`
- [Imbalance comparison](https://github.com/harshkaushik2203/fraud-detection-classifier/tree/main/notebooks): `notebooks`
- [Cost threshold tuning](https://github.com/harshkaushik2203/fraud-detection-classifier/tree/main/notebooks): `notebooks`

### Prediction API

- [Prediction and health API](https://github.com/harshkaushik2203/fraud-detection-classifier/blob/main/api/main.py): `api/main.py`
- [Request and response schemas](https://github.com/harshkaushik2203/fraud-detection-classifier/blob/main/api/schemas.py): `api/schemas.py`

### Runtime configuration

- [Runtime configuration](https://github.com/harshkaushik2203/fraud-detection-classifier/blob/main/src/config.py): `src/config.py`

### Model artifacts

- [Fraud classifier](https://github.com/harshkaushik2203/fraud-detection-classifier/blob/main/models/xgb_fraud_model.joblib): `models/xgb_fraud_model.joblib`
- [Amount scaler](https://github.com/harshkaushik2203/fraud-detection-classifier/blob/main/models/amount_scaler.joblib): `models/amount_scaler.joblib`

### Other components

- **Transaction caller**

## Connections

- Data preprocessing → Baseline model: prepares data for (evidence: `README.md`)
- Data preprocessing → Imbalance comparison: prepares data for (evidence: `README.md`)
- Imbalance comparison → Cost threshold tuning: provides probabilities to (evidence: `README.md`)
- Transaction caller → Prediction and health API: submits transaction (evidence: `README.md`)
- Prediction and health API → Request and response schemas: validates and formats (evidence: `api/main.py`)
- Prediction and health API → Runtime configuration: reads paths and threshold (evidence: `api/main.py`)
- Prediction and health API → Amount scaler: loads and transforms amount with (evidence: `api/main.py`)
- Prediction and health API → Fraud classifier: loads and scores with (evidence: `api/main.py`)
- Prediction and health API → Transaction caller: returns prediction (evidence: `README.md`)
- Baseline model → Fraud classifier: compares trained approaches
- Cost threshold tuning → Runtime configuration: sets decision threshold (evidence: `README.md`)
