52

FraudSense

Real-time fraud scoring API using behavioral features and ML-driven decisions.

Overview

FraudSense is a containerized, real-time fraud detection system that evaluates transactions through a production-style API, enriches them with behavioral features, and returns actionable decisions (approve / review / decline).

The system combines online feature aggregation, rule-based decisioning, and a trained machine learning model to simulate a modern fraud scoring architecture used in financial risk systems.

FraudSense processes each transaction through the following pipeline:

1. Incoming transaction request hits a FastAPI scoring endpoint

2. Behavioral features are computed in real time using Redis-based rolling windows

3. Feature vector is evaluated by a trained fraud classification model

4. Rule-based policy is applied to determine the final decision

5. Transaction, prediction, and decision are persisted in PostgreSQL for auditing and retraining

The entire system is containerized using Docker.

Architecture

Backend: FastAPI

Data Store: PostgreSQL

Online Feature Store: Redis

Model Layer: Scikit-learn classifier

Containerization: Docker

Key system components:

  • REST API for transaction scoring
  • Redis-based rolling window velocity features
  • Device and merchant behavioral aggregation
  • Threshold-calibrated ML scoring
  • Rule-based override logic
  • Persisted audit logging for model retraining
  • Model Training

    The fraud classifier was trained using Kaggle's 250K-row credit card fraud dataset.

    Key metrics:

  • ROC-AUC: 0.941
  • Threshold calibration under severe class imbalance
  • Imbalance awareness was critical due to the ~0.17% fraud rate in the dataset.

    Thresholds were tuned to balance precision and recall appropriately for real-world fraud detection scenarios.

    Benchmarks

    The scoring API was load-tested using a transaction replay pipeline.

    Results:

  • 10,000 simulated transactions processed
  • Sustained throughput: 233 requests per second
  • Median latency (p50): 3.73 ms
  • 95th percentile latency (p95): 6.33 ms
  • These results demonstrate stable, low-latency fraud scoring performance under high transaction volume.