KatInterview

Real-Time Transaction Risk Scoring System Design

Machine LearningModel answer
HardModel answerMachine Learningfraud detectionfeature engineeringimbalanced learning

Last updated

Design an end-to-end ML system that scores payment transactions in real time and decides whether to approve, block, challenge, or escalate them.

Scenario

You are joining the risk engineering team at a high-volume online payment platform processing around one billion transactions per month. The business loses revenue to fraudulent transactions but also loses customers when legitimate purchases are incorrectly blocked. Your task is to design the machine learning system that sits inside the transaction authorization path and assigns a risk score to each transaction.

The system's output drives one of four decisions: approve, block, challenge (trigger step-up authentication), or send to manual review. Review-queue capacity is finite, so the system cannot punt every uncertain case to humans.

What to cover

1. Problem framing and trade-offs What are the competing business objectives? How do you turn them into a cost function or optimization target? What latency budget does the system have, and why does it matter?

2. Training data and labels Where do fraud labels come from, and what are their failure modes? How do you handle the fact that blocked transactions never receive labels? What does point-in-time correctness mean here, and how do you enforce it?

3. Feature engineering What signals do you extract from the transaction itself, the cardholder, the merchant, the device, the IP, and historical behavior? What role do graph-based features play, and how do you keep velocity features fresh?

4. Modeling Which model family fits this problem, and why? How do you handle severe class imbalance (roughly 0.1% fraud rate)? How do you deal with the fact that chargebacks can arrive weeks or months after the transaction?

5. Serving architecture Sketch the real-time pipeline from checkout event to decision. Where do features come from online, and what are their freshness requirements? What happens when a downstream dependency times out?

6. Evaluation, thresholds, and experimentation Which metrics reflect business value better than raw accuracy? How do you set and tune decision thresholds? How do you run an A/B test on a fraud model safely?

7. Monitoring and adversarial robustness How do you detect model degradation before it shows up in chargeback rates? How does the system respond when fraudsters adapt their behavior?

Constraints and assumptions

  • ~400 TPS average, up to ~8,000 TPS during peak sales events
  • p99 end-to-end latency budget for risk scoring: ~100 ms, with ~30 ms for feature retrieval and ~10 ms for model inference
  • Chargeback labels arrive anywhere from a few days to 120+ days after the transaction
  • Manual review team can handle a fixed number of cases per day (on the order of a few thousand)
  • The system must be explainable enough to produce reason codes for merchant dashboards and internal review

A strong answer demonstrates that you understand the production ML concerns — not just the modeling choices — and can reason through the trade-offs between fraud loss, false positives, user friction, and operational cost.

Hints

Hint 1

Before choosing a model, frame the problem as expected-cost minimization rather than binary classification. Different actions (block vs. challenge vs. review) have different costs, and the optimal decision depends on both the predicted probability and the transaction amount.

Hint 2

Blocked transactions are permanently unlabeled — the model never finds out whether they were actually fraudulent. Think about how you would use a small exploration holdout and propensity weighting to correct for this selection bias in both training and offline evaluation.

Hint 3

Velocity features (counts and sums over short windows keyed by card, device, IP) are among the highest-signal inputs and the hardest for fraudsters to fake, but they require near-real-time updates. Separate your feature store into two tiers: a streaming tier updated within seconds for velocity signals, and a batch tier updated hourly or daily for graph and merchant-level features.