Fintech Engineering: The Engineering Behind Real-Time Fraud Detection
Introduction:
Fraud detection is one of the most technically demanding problems in financial engineering. Every transaction must be evaluated in milliseconds, the cost of a wrong decision in either direction is significant, and the adversary is actively adapting to whatever detection mechanisms are in place.
The systems that power real-time fraud detection are not simply machine learning models sitting in front of a database. They are complex pipelines that combine streaming data processing, feature engineering at low latency, ensemble model evaluation, rule engines, and feedback mechanisms — all operating under latency constraints that leave no room for the architectural shortcuts that are acceptable in less time-sensitive systems.
Understanding how these systems are built reveals engineering decisions that apply well beyond fraud detection to any domain where decisions must be made quickly, correctly, and at scale.
The Latency Constraint Changes Everything:
A fraud detection system that takes ten seconds to evaluate a transaction is not a real-time fraud detection system. By the time it produces a result, the user has already experienced a failed transaction or the fraud has already occurred. The latency budget for transaction scoring in most payment systems is between 100 and 300 milliseconds — end to end, including network time.
This constraint eliminates entire categories of architectural approaches that would otherwise be reasonable. Synchronous database queries that scan large tables are too slow. Model inference that requires fetching features from multiple sources sequentially cannot fit within the budget. Ensemble approaches that run models in series rather than parallel add latency that quickly exceeds the available window.
Every architectural decision in a fraud detection system must be evaluated against the latency budget first. Correctness and sophistication matter, but only within the bounds of what can be computed in time.
Feature Engineering Is the Core Engineering Challenge:
Machine learning models for fraud detection are only as good as the features they receive. A model that receives rich, accurately computed features describing a transaction's context will outperform a more sophisticated model receiving impoverished features. Feature engineering — deciding what signals to compute and how to compute them within latency constraints — is where most of the engineering complexity lives.
Useful features for fraud detection include the transaction amount relative to historical averages for that card, the velocity of recent transactions on the account, the distance between the current transaction location and the previous one, the time since the last transaction, and the merchant category relative to historical spending patterns. Each of these requires access to historical data that must be retrieved and computed within milliseconds.
Feature stores — systems that precompute and serve features at low latency — exist specifically to solve this problem. Historical aggregations that would take seconds to compute from raw transaction data are precomputed incrementally as transactions arrive and stored in low-latency key-value stores like Redis. At scoring time, the feature store serves precomputed values rather than computing them on demand.
Rule Engines and Models Work Together:
Pure machine learning approaches to fraud detection have a significant limitation — they are opaque. When a model declines a transaction, the reason is a weighted combination of hundreds of features that is difficult to explain to a customer, a regulator, or a fraud analyst. Explainability requirements in financial services make pure model approaches difficult to deploy without augmentation.
Rule engines address this by encoding explicit, human-readable logic — decline transactions above a certain amount from a new device in a new country, flag transactions that exceed three times the average transaction value for this account, block transactions from merchant categories the card has never used. Rules are transparent, auditable, and can be updated immediately in response to new fraud patterns without retraining a model.
Production fraud detection systems typically use rules and models in combination. Rules handle known fraud patterns with certainty and low latency. Models handle novel patterns that rules have not yet encoded. The combination produces better detection rates than either approach alone while maintaining the explainability that regulatory requirements demand.
Streaming Architecture Is Non-Negotiable:
Fraud detection systems must process transactions as they arrive, not in batches. A batch processing architecture that evaluates transactions every five minutes is useless for real-time fraud prevention — by the time the batch runs, dozens of fraudulent transactions may have been approved.
Streaming architectures using systems like Apache Kafka and Apache Flink process each transaction as an individual event, maintaining running state about account behaviour, updating velocity counters in real time, and triggering model scoring immediately as each transaction arrives. The streaming layer also handles the aggregation needed for feature computation — maintaining rolling windows of transaction history that can be queried at scoring time without touching a historical database.
The operational complexity of streaming infrastructure is significantly higher than batch alternatives. Stream processing jobs that fall behind their input rate accumulate backlogs that increase latency. Stateful stream processing requires careful management of checkpoints and recovery to ensure that accumulated state is not lost during failures.
The Feedback Loop Determines Long-Term Effectiveness:
A fraud detection system that makes decisions but never learns from them degrades over time as fraud patterns evolve. The feedback loop — connecting outcomes back to the model training pipeline — is what keeps detection rates high as adversaries adapt.
Confirmed fraud cases, successful chargebacks, and analyst-reviewed decisions all provide labelled data that can be used to retrain models and update rules. But feedback introduces its own challenges. There is a delay between when a fraudulent transaction occurs and when it is confirmed as fraud — customers may not report fraud immediately, and chargeback processes take time. Training on delayed labels requires careful handling of the time gap between prediction and confirmation.
False positives — legitimate transactions declined as fraud — are particularly important to capture in the feedback loop. A system that optimises only for catching fraud without accounting for the cost of declining legitimate transactions will become increasingly aggressive over time, damaging customer experience in ways that are as commercially significant as the fraud it prevents.
Explainability Is an Engineering Requirement, Not an Afterthought:
When a fraud detection system declines a transaction, someone needs to be able to explain why. The customer wants to know why their transaction was declined. The fraud analyst investigating a case needs to understand what signals triggered the decision. The regulator auditing the system needs evidence that decisions are made on legitimate grounds and do not discriminate unlawfully.
Producing explanations from complex ensemble models requires additional engineering beyond the scoring pipeline. Techniques like SHAP values compute the contribution of each feature to a specific model decision, producing explanations that are accurate at the individual prediction level rather than approximations based on global model behaviour.
These explanations must be generated and stored at scoring time — when the transaction is evaluated — because regenerating them later from a model that may have been retrained is not reliable. Explanation infrastructure adds latency and storage requirements that must be accounted for in the system design from the beginning.
Conclusion:
Real-time fraud detection is an engineering problem that sits at the intersection of streaming data processing, low-latency feature serving, machine learning inference, rule-based logic, and feedback-driven model improvement. Each of these components is a significant engineering challenge in isolation. Making them work together within a latency budget measured in milliseconds is what makes fraud detection one of the most technically demanding domains in financial engineering.
The engineering decisions that make fraud detection systems work — precomputed features, combined rule and model approaches, streaming architectures, feedback loops with delayed labels — are not specific to fraud. They are the decisions that any system must get right when it needs to make consequential decisions quickly, at scale, and with enough transparency to be trusted by the people and regulators it is accountable to.
Enjoyed this post?
Stay in the loop
New posts + weekly digest, straight to your inbox.
Create a free account
- Save posts to your vault
- Like posts & build history
- New-post alerts
No comments yet. Be the first to comment!