# lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection architecture

> Architecture diagram of the GitHub repository lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection
- Repository: https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection

## Overview

DriftGuard is a streaming fraud-detection and continual-learning framework. Its principal workflow is to generate card-level transaction sequences, score them with a deep sequence model, detect performance drift, and adapt the learner while retaining prior examples; results are evaluated and visualized. The README also describes preprocessing, static baselines, adaptive business thresholds, replay, A-GEM, and EWC. Some learner integrations are unsampled, so uncertain runtime connections are left dashed rather than inferred as confirmed calls.

Main entry points: [`src/continual_learner.py`](https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/continual_learner.py) (Continual Learner), [`src/realtime_generator.py`](https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/realtime_generator.py) (Sequence Generator), [`src/drift_detection/dual.py`](https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/drift_detection/dual.py) (Dual Drift Detector), [`src/preprocess_data.py`](https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/preprocess_data.py) (Data Preprocessing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_stream["Stream and Inputs"]
  node_preprocess["Data Preprocessing<br/>[preprocess_data.py]"]
  node_prepared["Prepared Data"]
  node_generator["Sequence Generator"]
  node_metadata["Feature Metadata<br/>[metadata.json]"]
end

subgraph group_learning["Continual Learning"]
  node_learner["Continual Learner"]
  node_lstm["Sequence Model<br/>[lstm_model.py]"]
  node_threshold["Adaptive Threshold"]
  node_replay_random["Random Replay<br/>[random.py]"]
  node_replay_balanced["Balanced Replay<br/>[balanced.py]"]
  node_replay_prioritized["Prioritized Replay<br/>[prioritized.py]"]
  node_regularization["Gradient and EWC"]
end

subgraph group_drift["Drift Monitoring"]
  node_dual["Dual Drift Detector<br/>[dual.py]"]
  node_adwin["ADWIN Detector<br/>[adwin.py]"]
  node_window["Recall Window<br/>[window.py]"]
end

subgraph group_results["Evaluation and Results"]
  node_baseline["Static Baselines<br/>[baselines.py]"]
  node_evaluator["Model Evaluator<br/>[model_evaluator.py]"]
  node_dashboard["Interactive Dashboard<br/>[dashboard.py]"]
end

node_transactions["Transaction Data"]

node_transactions -.->|"preprocesses"| node_preprocess
node_prepared -.->|"loads sequences"| node_generator
node_generator -->|"reads features"| node_metadata
node_generator -->|"supplies batches"| node_learner
node_learner -->|"uses model"| node_lstm
node_learner -->|"tunes threshold"| node_threshold
node_learner -->|"uses replay"| node_replay_random
node_learner -->|"uses replay"| node_replay_balanced
node_learner -->|"uses replay"| node_replay_prioritized
node_learner -.->|"applies mitigation"| node_regularization
node_learner -.->|"checks drift"| node_dual
node_dual -->|"updates"| node_adwin
node_dual -->|"updates"| node_window
node_learner -.->|"compares strategies"| node_baseline
node_learner -.->|"evaluates metrics"| node_evaluator
node_learner -.->|"visualizes stream"| node_dashboard

click node_preprocess "https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/preprocess_data.py"
click node_generator "https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/realtime_generator.py"
click node_metadata "https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/data/metadata.json"
click node_learner "https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/continual_learner.py"
click node_lstm "https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/models/lstm_model.py"
click node_threshold "https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/continual_learner.py"
click node_replay_random "https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/memory/random.py"
click node_replay_balanced "https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/memory/balanced.py"
click node_replay_prioritized "https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/memory/prioritized.py"
click node_regularization "https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/continual_learner.py"
click node_dual "https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/drift_detection/dual.py"
click node_adwin "https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/drift_detection/adwin.py"
click node_window "https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/drift_detection/window.py"
click node_baseline "https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/baselines.py"
click node_evaluator "https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/model_evaluator.py"
click node_dashboard "https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/dashboard.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_prepared,node_generator,node_metadata toneBlue
class node_learner,node_lstm,node_threshold,node_replay_random,node_replay_balanced,node_replay_prioritized,node_regularization toneAmber
class node_dual,node_adwin,node_window toneMint
class node_baseline,node_evaluator,node_dashboard toneRose
class node_transactions toneIndigo
```

## Components

### Stream and Inputs

- [Data Preprocessing](https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/preprocess_data.py): `src/preprocess_data.py`
- **Prepared Data**
- [Sequence Generator](https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/realtime_generator.py): `src/realtime_generator.py`
- [Feature Metadata](https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/data/metadata.json): `data/metadata.json`

### Continual Learning

- [Continual Learner](https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/continual_learner.py): `src/continual_learner.py`
- [Sequence Model](https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/models/lstm_model.py): `src/models/lstm_model.py`
- [Adaptive Threshold](https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/continual_learner.py): `src/continual_learner.py`
- [Random Replay](https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/memory/random.py): `src/memory/random.py`
- [Balanced Replay](https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/memory/balanced.py): `src/memory/balanced.py`
- [Prioritized Replay](https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/memory/prioritized.py): `src/memory/prioritized.py`
- [Gradient and EWC](https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/continual_learner.py): `src/continual_learner.py`

### Drift Monitoring

- [Dual Drift Detector](https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/drift_detection/dual.py): `src/drift_detection/dual.py`
- [ADWIN Detector](https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/drift_detection/adwin.py): `src/drift_detection/adwin.py`
- [Recall Window](https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/drift_detection/window.py): `src/drift_detection/window.py`

### Evaluation and Results

- [Static Baselines](https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/baselines.py): `src/baselines.py`
- [Model Evaluator](https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/model_evaluator.py): `src/model_evaluator.py`
- [Interactive Dashboard](https://github.com/lakshmikanthan07/drift-aware-continual-lstm-for-emerging-fraud-detection/blob/main/src/dashboard.py): `src/dashboard.py`

### Other components

- **Transaction Data**

## Connections

- Transaction Data → Data Preprocessing: preprocesses (evidence: `README.md`)
- Prepared Data → Sequence Generator: loads sequences (evidence: `README.md`)
- Sequence Generator → Feature Metadata: reads features (evidence: `src/realtime_generator.py`)
- Sequence Generator → Continual Learner: supplies batches (evidence: `src/continual_learner.py`)
- Continual Learner → Sequence Model: uses model (evidence: `src/continual_learner.py`)
- Continual Learner → Adaptive Threshold: tunes threshold (evidence: `src/continual_learner.py`)
- Continual Learner → Random Replay: uses replay (evidence: `src/continual_learner.py`)
- Continual Learner → Balanced Replay: uses replay (evidence: `src/continual_learner.py`)
- Continual Learner → Prioritized Replay: uses replay (evidence: `src/continual_learner.py`)
- Continual Learner → Gradient and EWC: applies mitigation (evidence: `README.md`)
- Continual Learner → Dual Drift Detector: checks drift (evidence: `src/continual_learner.py`)
- Dual Drift Detector → ADWIN Detector: updates (evidence: `src/drift_detection/dual.py`)
- Dual Drift Detector → Recall Window: updates (evidence: `src/drift_detection/dual.py`)
- Continual Learner → Static Baselines: compares strategies (evidence: `README.md`)
- Continual Learner → Model Evaluator: evaluates metrics (evidence: `src/continual_learner.py`)
- Continual Learner → Interactive Dashboard: visualizes stream (evidence: `README.md`)
