# aashishtetali/fraud_detector architecture

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

- Interactive diagram: https://gitdiagram.com/aashishtetali/fraud_detector
- Repository: https://github.com/aashishtetali/fraud_detector

## Overview

This is a runnable fraud-detection lifecycle demo, not a deployed service: `main.py` generates synthetic historical and streaming data, trains and evaluates a baseline, then monitors the stream and retrains after detected drift. `dataset.py` supplies controlled data and two drift patterns. The README documents the intended run and reported results; the sampled source shows the core flow, though portions of `main.py` are omitted.

Main entry points: [`main.py`](https://github.com/aashishtetali/fraud_detector/blob/main/main.py) (Stream evaluation), [`dataset.py`](https://github.com/aashishtetali/fraud_detector/blob/main/dataset.py) (Pool and stream generator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Synthetic data"]
  node_generator["Pool and stream generator<br/>[dataset.py]"]
  node_drift["Drift injection<br/>[dataset.py]"]
end

subgraph group_model["Model lifecycle"]
  node_split["Stratified split<br/>[main.py]"]
  node_baseline["Baseline training<br/>[main.py]"]
  node_evaluation["Held-out evaluation<br/>[main.py]"]
end

subgraph group_adapt["Drift adaptation"]
  node_stream_loop["Stream evaluation<br/>[main.py]"]
  node_monitor["ADWIN monitor<br/>[main.py]"]
  node_retraining["Window retraining<br/>[main.py]"]
end

subgraph group_results["Results"]
  node_reporting["Metrics and plots<br/>[main.py]"]
end

node_user(("Runner"))

node_user -->|"starts pipeline"| node_generator
node_generator -->|"applies patterns"| node_drift
node_user -->|"requests data"| node_generator
node_generator -->|"returns history"| node_split
node_generator -->|"returns batches"| node_stream_loop
node_split -->|"provides split"| node_baseline
node_baseline -->|"predicts test set"| node_evaluation
node_baseline -->|"seeds live model"| node_stream_loop
node_stream_loop -->|"feeds errors"| node_monitor
node_monitor -->|"triggers on drift"| node_retraining
node_stream_loop -->|"buffers recent batches"| node_retraining
node_retraining -->|"updates live model"| node_stream_loop
node_evaluation -->|"provides metrics"| node_reporting
node_stream_loop -->|"provides stream results"| node_reporting

click node_generator "https://github.com/aashishtetali/fraud_detector/blob/main/dataset.py"
click node_drift "https://github.com/aashishtetali/fraud_detector/blob/main/dataset.py"
click node_split "https://github.com/aashishtetali/fraud_detector/blob/main/main.py"
click node_baseline "https://github.com/aashishtetali/fraud_detector/blob/main/main.py"
click node_evaluation "https://github.com/aashishtetali/fraud_detector/blob/main/main.py"
click node_stream_loop "https://github.com/aashishtetali/fraud_detector/blob/main/main.py"
click node_monitor "https://github.com/aashishtetali/fraud_detector/blob/main/main.py"
click node_retraining "https://github.com/aashishtetali/fraud_detector/blob/main/main.py"
click node_reporting "https://github.com/aashishtetali/fraud_detector/blob/main/main.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_generator,node_drift toneBlue
class node_split,node_baseline,node_evaluation toneAmber
class node_stream_loop,node_monitor,node_retraining toneMint
class node_reporting toneRose
class node_user toneIndigo
```

## Components

### Synthetic data

- [Pool and stream generator](https://github.com/aashishtetali/fraud_detector/blob/main/dataset.py): `dataset.py`
- [Drift injection](https://github.com/aashishtetali/fraud_detector/blob/main/dataset.py): `dataset.py`

### Model lifecycle

- [Stratified split](https://github.com/aashishtetali/fraud_detector/blob/main/main.py): `main.py`
- [Baseline training](https://github.com/aashishtetali/fraud_detector/blob/main/main.py): `main.py`
- [Held-out evaluation](https://github.com/aashishtetali/fraud_detector/blob/main/main.py): `main.py`

### Drift adaptation

- [Stream evaluation](https://github.com/aashishtetali/fraud_detector/blob/main/main.py): `main.py`
- [ADWIN monitor](https://github.com/aashishtetali/fraud_detector/blob/main/main.py): `main.py`
- [Window retraining](https://github.com/aashishtetali/fraud_detector/blob/main/main.py): `main.py`

### Results

- [Metrics and plots](https://github.com/aashishtetali/fraud_detector/blob/main/main.py): `main.py`

### Other components

- **Runner**

## Connections

- Runner → Pool and stream generator: starts pipeline (evidence: `README.md`)
- Pool and stream generator → Drift injection: applies patterns (evidence: `dataset.py`)
- Runner → Pool and stream generator: requests data
- Pool and stream generator → Stratified split: returns history (evidence: `main.py`)
- Pool and stream generator → Stream evaluation: returns batches (evidence: `main.py`)
- Stratified split → Baseline training: provides split (evidence: `main.py`)
- Baseline training → Held-out evaluation: predicts test set (evidence: `main.py`)
- Baseline training → Stream evaluation: seeds live model (evidence: `main.py`)
- Stream evaluation → ADWIN monitor: feeds errors (evidence: `main.py`)
- ADWIN monitor → Window retraining: triggers on drift (evidence: `main.py`)
- Stream evaluation → Window retraining: buffers recent batches (evidence: `main.py`)
- Window retraining → Stream evaluation: updates live model (evidence: `main.py`)
- Held-out evaluation → Metrics and plots: provides metrics (evidence: `main.py`)
- Stream evaluation → Metrics and plots: provides stream results (evidence: `main.py`)
