37

FraudSense

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

Overview

FraudSense is a containerized, real-time fraud detection system that scores 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 ML model to simulate a modern fraud scoring architecture.

FraudSense processes each transaction through the following pipeline:

1. Incoming transaction hits FastAPI endpoint

2. Behavioral features computed in real time using Redis

3. Feature vector scored by trained fraud classifier

4. Rule-based policy applied to determine final decision

5. Transaction, prediction, and decision persisted in PostgreSQL

The system is fully 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 retraining
  • Model Training

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

    Key metrics:

  • ROC-AUC: 0.941
  • Calibrated threshold tuning 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 fraud detection environments.

    Benchmarks

    The live 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
  • This validated system stability and low-latency scoring under high-volume conditions.