Requirements
- Detect fraudulent transactions in real time (<200ms per transaction decision)
- Flag suspicious user behavior: account takeover, card testing, synthetic identities
- False positive rate <0.5% (legitimate transactions must not be blocked)
- 10K transactions/second
Architecture: Rule Engine + ML Scoring
Transaction → Rule Engine (fast, deterministic) → ML Scorer (probabilistic)
↓ block/allow ↓ risk score 0-1
Decisioning Service → ALLOW / REVIEW / BLOCK
↓
Kafka (events for model training, analytics, manual review)
Rule Engine (First Layer)
Fast deterministic rules that catch obvious fraud. Evaluated in order, short-circuit on first match:
- Velocity rules: INCR tx_count:{user_id}:{minute_bucket} in Redis. If >5 transactions in 60s: block. TTL=120s.
- Amount rules: transaction amount >3x the user’s 30-day average → REVIEW
- Geographic rules: billing address country != IP geolocation country → REVIEW
- Device fingerprint: device_id associated with previous fraud → block
- Card BIN check: card BIN (first 6 digits) on blocklist → block
- Account age: account created <24h ago + high-value transaction → REVIEW
ML Risk Scorer (Second Layer)
For transactions not immediately blocked by rules, compute a risk score. Features:
- User behavior features: average transaction amount, transaction frequency, typical hours of activity
- Device features: is_new_device, device_age_days, device_risk_score
- Network features: IP reputation score, is_VPN/proxy, IP-to-billing-address distance
- Merchant features: merchant_risk_category, transaction_count_at_merchant
- Velocity features: transactions in last 1h/24h/7d, amount in last 24h
Model: gradient boosting (XGBoost/LightGBM) trained on labeled fraud/non-fraud transactions. Feature store: Redis for real-time features (velocity counts), Cassandra for historical features (user’s 30-day stats). Model served via ONNX runtime in the fraud service for sub-50ms inference.
Risk Score → Decision
score 0.7: BLOCK (decline transaction)
Thresholds tuned based on business risk tolerance. REVIEW actions: send 3D Secure challenge (user verifies via SMS/app), add to manual review queue (agent reviews within 24h), or step-up authentication.
Feature Engineering
Real-time features computed at transaction time:
- Amount z-score: (amount – user_avg_30d) / user_stddev_30d
- Time since last transaction for this user
- Count of distinct merchants in last 24h
- Is the shipping address new (never used before)?
- Card testing signal: multiple small (<$1) transactions in last hour (testing if card is valid)
Feedback Loop
Labels come from: (1) chargebacks (confirmed fraud, typically 60-90 days after transaction), (2) user-reported fraud, (3) manual review decisions. Publish labeled examples to Kafka → training pipeline → retrain model weekly. Feature drift detection: if feature distributions shift significantly (e.g., new fraud pattern emerges), trigger retraining. A/B test new model versions: shadow mode (run new model but don’t use its decision) before full deployment.
Data Model
Transaction(tx_id, user_id, merchant_id, amount, currency, device_id,
ip_address, card_id, status ENUM(PENDING,ALLOWED,BLOCKED,REVIEW),
risk_score, created_at)
FraudSignal(signal_id, tx_id, signal_type, signal_value, created_at)
UserRiskProfile(user_id, avg_amount_30d, tx_count_30d, last_tx_at, risk_tier)
Key Design Decisions
- Rule engine runs first (fast) — blocks obvious fraud without ML inference cost
- ML model for ambiguous cases — probabilistic risk score, not binary
- Feature store separates real-time features (Redis) from historical features (Cassandra)
- False positive minimization: REVIEW instead of BLOCK for medium-risk scores
- Feedback loop: chargebacks and manual review labels retrain the model continuously
Stripe system design interviews cover fraud detection and risk scoring. See common questions for Stripe interview: fraud detection system design.
Coinbase system design covers fraud detection and transaction risk scoring. Review patterns for Coinbase interview: fraud detection and risk system design.
Amazon system design covers fraud detection and seller trust. See design patterns for Amazon interview: fraud detection and trust and safety system design.
See also: Meta Interview Guide 2026: Facebook, Instagram, WhatsApp Engineering