KatInterview

Design a Real-Time Fraud Prevention Platform

Machine LearningModel answer
HardModel answerMachine Learningsystem-designmachine-learningfraud-detection

Last updated

Architect a scalable, low-latency system to score payment transactions for fraud under severe class imbalance and delayed feedback loops.

Architect an end-to-end real-time fraud detection engine for an enterprise online marketplace. The service evaluates incoming card payment authorizations to block fraudulent behavior, issue verification challenges, or approve transactions.

Key Operational Constraints & Requirements

  1. Low-Latency & High-Throughput: The system must process an average of 5,000 transactions per second (TPS) with peaks reaching 30,000 TPS. Strict budget: total authorization flow budget allocation for fraud risk scoring is < 100ms at the 99th percentile ($p_{99}$).
  2. High Availability: Must maintain 99.99% uptime. System outages must fail open safely without blocking valid checkouts.
  3. Data & ML Challenges:
    • Severe Imbalance: Fraud rates represent < 0.2% of all transactions (~1:500 ratio).
    • Delayed Ground Truth: Confirmed negative/positive labels arrive asynchronously. User disputes and credit card chargebacks can take 30 to 90 days to finalize.
    • Adversarial Drift: Tactics evolve quickly; static rules degrade over time.

System Requirements

Your architecture proposal should clearly cover:

  • API & System Architecture: Define the primary risk scoring API contract and overall data flow topology.
  • Data Engineering & Feature Infrastructure: How online features (real-time velocity aggregate features) and offline features are maintained without training-serving skew.
  • Modeling & Training Strategy: Model selection, addressing extreme imbalance, calibrating probabilities, and adjusting business thresholds.
  • Label Ingestion & Delayed Feedback: Techniques to train effectively given multi-week chargeback arrival latencies and selection bias from previously blocked transactions.
  • Deployment & Monitoring: Continuous validation, shadow/canary rollouts, and detecting feature/concept drift.

Hints

Hint 1

Establish a clear latency budget Breakdown (e.g., Network + Online Store Lookup + Inference + Rules Engine) before designing the feature pipeline.

Hint 2

Address training-serving skew by combining a dual-storage Feature Store (Redis/DynamoDB + S3/Iceberg) with point-in-time correct joins or direct request-log join pipelines.

Hint 3

For delayed feedback, consider importance weighting based on empirical delay distributions, as well as an exploration slice to mitigate selection bias from declined transactions.