# padmajaghute339-svg/fraud-detection-system architecture

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

- Interactive diagram: https://gitdiagram.com/padmajaghute339-svg/fraud-detection-system
- Repository: https://github.com/padmajaghute339-svg/fraud-detection-system

## Overview

This is a single-file real-time transaction fraud detection service. Its main workflow accepts a transaction over HTTP, updates per-user in-memory history, derives velocity and spend features, preprocesses them for a LightGBM prediction, and returns a fraud decision with explanations. The module also builds the model offline and includes a live API simulation. The excerpt does not show every training or response step, so the graph omits uncertain connections.

Main entry points: [`fraud_system.py`](https://github.com/padmajaghute339-svg/fraud-detection-system/blob/master/fraud_system.py) (Prediction endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Offline training"]
  node_feature_engineering["Feature engineering<br/>[fraud_system.py]"]
  node_offline_data["Mock transactions<br/>[fraud_system.py]"]
  node_preprocessor["Feature preprocessor<br/>[fraud_system.py]"]
  node_classifier["LightGBM model<br/>[fraud_system.py]"]
end

subgraph group_serving["Scoring service"]
  node_api["Prediction endpoint<br/>[fraud_system.py]"]
  node_model_bundle["Model bundle<br/>[fraud_system.py]"]
  node_explanations["SHAP reasons<br/>[fraud_system.py]"]
end

subgraph group_state["Transaction state"]
  node_state_store[("User history store<br/>[fraud_system.py]")]
end

subgraph group_simulation["Live simulation"]
  node_simulation["Traffic simulation<br/>[fraud_system.py]"]
end

node_caller(("API client"))

node_caller -->|"requests"| node_api
node_api -->|"updates history"| node_state_store
node_api -->|"computes features"| node_state_store
node_offline_data -->|"feeds"| node_feature_engineering
node_feature_engineering -->|"configures"| node_preprocessor
node_preprocessor -->|"transforms training data"| node_classifier
node_classifier -->|"bundles model"| node_model_bundle
node_api -->|"transforms payload"| node_preprocessor
node_api -->|"scores transaction"| node_classifier
node_api -->|"builds reasons"| node_explanations
node_simulation -->|"posts requests"| node_api

click node_api "https://github.com/padmajaghute339-svg/fraud-detection-system/blob/master/fraud_system.py"
click node_state_store "https://github.com/padmajaghute339-svg/fraud-detection-system/blob/master/fraud_system.py"
click node_feature_engineering "https://github.com/padmajaghute339-svg/fraud-detection-system/blob/master/fraud_system.py"
click node_offline_data "https://github.com/padmajaghute339-svg/fraud-detection-system/blob/master/fraud_system.py"
click node_preprocessor "https://github.com/padmajaghute339-svg/fraud-detection-system/blob/master/fraud_system.py"
click node_classifier "https://github.com/padmajaghute339-svg/fraud-detection-system/blob/master/fraud_system.py"
click node_model_bundle "https://github.com/padmajaghute339-svg/fraud-detection-system/blob/master/fraud_system.py"
click node_explanations "https://github.com/padmajaghute339-svg/fraud-detection-system/blob/master/fraud_system.py"
click node_simulation "https://github.com/padmajaghute339-svg/fraud-detection-system/blob/master/fraud_system.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_feature_engineering,node_offline_data,node_preprocessor,node_classifier,node_caller toneBlue
class node_api,node_model_bundle,node_explanations toneAmber
class node_state_store toneMint
class node_simulation toneRose
```

## Components

### Offline training

- [Feature engineering](https://github.com/padmajaghute339-svg/fraud-detection-system/blob/master/fraud_system.py): `fraud_system.py`
- [Mock transactions](https://github.com/padmajaghute339-svg/fraud-detection-system/blob/master/fraud_system.py): `fraud_system.py`
- [Feature preprocessor](https://github.com/padmajaghute339-svg/fraud-detection-system/blob/master/fraud_system.py): `fraud_system.py`
- [LightGBM model](https://github.com/padmajaghute339-svg/fraud-detection-system/blob/master/fraud_system.py): `fraud_system.py`

### Scoring service

- [Prediction endpoint](https://github.com/padmajaghute339-svg/fraud-detection-system/blob/master/fraud_system.py): `fraud_system.py`
- [Model bundle](https://github.com/padmajaghute339-svg/fraud-detection-system/blob/master/fraud_system.py): `fraud_system.py`
- [SHAP reasons](https://github.com/padmajaghute339-svg/fraud-detection-system/blob/master/fraud_system.py): `fraud_system.py`

### Transaction state

- [User history store](https://github.com/padmajaghute339-svg/fraud-detection-system/blob/master/fraud_system.py): `fraud_system.py`

### Live simulation

- [Traffic simulation](https://github.com/padmajaghute339-svg/fraud-detection-system/blob/master/fraud_system.py): `fraud_system.py`

### Other components

- **API client**

## Connections

- API client → Prediction endpoint: requests (evidence: `fraud_system.py`)
- Prediction endpoint → User history store: updates history (evidence: `fraud_system.py`)
- Prediction endpoint → User history store: computes features (evidence: `fraud_system.py`)
- Mock transactions → Feature engineering: feeds (evidence: `fraud_system.py`)
- Feature engineering → Feature preprocessor: configures (evidence: `fraud_system.py`)
- Feature preprocessor → LightGBM model: transforms training data (evidence: `fraud_system.py`)
- LightGBM model → Model bundle: bundles model (evidence: `fraud_system.py`)
- Prediction endpoint → Feature preprocessor: transforms payload (evidence: `fraud_system.py`)
- Prediction endpoint → LightGBM model: scores transaction (evidence: `fraud_system.py`)
- Prediction endpoint → SHAP reasons: builds reasons (evidence: `fraud_system.py`)
- Traffic simulation → Prediction endpoint: posts requests (evidence: `fraud_system.py`)
