Real-Time Fraud Detection: Architecture, Latency, and Regulatory Compliance
Learn how to build real-time fraud detection systems under a 50ms latency budget while ensuring DPDPA and RBI compliance.
In financial services, real-time fraud detection is the automated analysis of transaction data during the authorization phase to block or flag fraudulent activity before settlement occurs. When a customer taps a card or clicks pay, the system must run anomaly detection and evaluate risk instantly. Payment networks enforce hard limits on this round-trip authorization cycle. Your scoring engine must complete its work in milliseconds. Building a modern financial AI platform requires balancing these extreme latency budgets with complex data pipelines and strict regulatory mandates.
What is Real-Time Fraud Detection in Financial Services?#
Real-time fraud detection is the process of evaluating a transaction for risk and making a decision (approve, challenge, or decline) while the transaction is still in flight. Unlike post-transaction batch processing, which identifies fraud hours or days after the event, real-time systems must intervene before the merchant receives confirmation or funds are moved.
This intervention happens within a strict latency budget. Real-time transaction authorization networks, such as Visa and Mastercard, enforce a hard limit on the entire round-trip authorization cycle. This cycle includes network transit, core banking ledger updates, and risk evaluation. To fit within this window, the risk-scoring engine must complete its machine learning inference step in less than 20 milliseconds, leaving a total budget of 10 to 50 milliseconds for the entire fraud scoring loop.
[Customer Tap] -> [Payment Gateway] -> [Fraud Scoring Engine (<20ms)] -> [Core Ledger] -> [Approval]The core architectural challenge is not just running a model quickly. The difficulty lies in merging historical customer profiles with incoming streaming transaction data in real time. To determine if a $500 transfer is suspicious, the system needs immediate access to historical context:
- Has the user transacted from this IP address before?
- How many transfers have they made in the last 24 hours?
- Is this transaction velocity anomalous compared to their 30-day average?
Querying this historical context must happen in parallel with the incoming transaction payload without degrading system availability or adding latency.
Where Traditional Architectures Fail: The Offline-to-Online Feature Leakage Trap#
Many engineering teams build their first machine learning models using historical data warehouses. They train offline models on clean, structured tables where features are computed using historical database timestamps. This setup leads directly to the Offline-to-Online Feature Leakage Trap.
Feature leakage occurs when training datasets use transaction aggregations computed with lookahead bias. For example, an offline training dataset might calculate a customer's 24-hour transaction frequency using exact database write times. In production, however, the streaming database might experience a replication lag of several seconds. If the model relies on features that assume zero latency between transaction event times and database write times, the live model will receive incomplete or null data.
Similarly, training datasets often include features that depend on information resolved days after the event, such as chargeback status. If these future signals leak into the training features, the model will perform exceptionally well in offline tests but fail catastrophically in production.
Traditional database designs exacerbate this problem. Standard relational database queries using SQL joins fail under production loads when calculating rolling window metrics. Running a query to count a user's transactions over the last 24 hours requires scanning and aggregating rows:
SELECT COUNT(id)
FROM transactions
WHERE user_id = :user_id
AND created_at >= NOW() - INTERVAL '24 hours';At peak loads of thousands of transactions per second, executing this query against a transactional relational database causes CPU spikes, lock contention, and query timeouts. The database cannot return a result within the 50ms authorization window.
When systems fail to compute these features quickly, they resort to coarse, static rules. This fallback leads to high false positive rates. Legacy rules-based AML systems generate high volumes of false positives, with 95% to 99% of alerts requiring manual review.
This is not just an operational bottleneck; it is an expensive drain on capital. According to the LexisNexis Risk Solutions True Cost of Fraud Study 2023, the total economic multiplier of fraud losses is 4.00 to4.50 lost per $1 of direct fraud loss. This includes legal fees, investigation costs, and recovery efforts. Conversely, blocking legitimate users due to false positives destroys customer lifetime value.
Fraud systems work best when they combine behavior patterns, transaction signals, graph relationships, and human investigation feedback. Accuracy matters, but explainability and false-positive management matter just as much. Simply blocking every suspicious transaction is not a viable strategy.
The Hybrid System Pattern: Separating Real-Time Inference from Async Processing#
To meet the sub-50ms latency SLA while maintaining complex feature calculations, you must separate your architecture into a dual-path system: an online hot path and an offline cold path.
[Incoming Transaction]
|
+------------------+------------------+
| (Hot Path) | (Cold Path)
v v
[Feature Store (Redis)] [Message Queue (Kafka)]
| |
v v
[ML Model Inference] [Stream Processor (Spark)]
| |
v v
[Policy Engine] [Feature Store Update]
|
v
[Approve / Decline]The Online Hot Path (Low-Latency Scoring)#
The hot path handles live transactions. It does not perform heavy computations, table scans, or database joins. Instead, it pulls pre-computed historical features from a real-time feature store (such as Redis or Feast) and feeds them directly into the machine learning model.
The Offline Cold Path (Batch Aggregation and Retraining)#
The cold path runs asynchronously. When a transaction occurs, the hot path emits an event to a message queue like Apache Kafka. A stream processing engine, such as Apache Spark or Apache Flink, consumes these events to recalculate rolling window aggregates and update the real-time feature store.
This separation ensures that the database queries required to update features never block the transaction path. The model always has access to historical features that are at most a few seconds old, served in under 10 milliseconds.
import redis
import json
class RealTimeFeatureProvider:
def __init__(self, redis_host: str, redis_port: int):
self.client = redis.Redis(host=redis_host, port=redis_port, decode_responses=True)
def get_user_features(self, user_id: str) -> dict:
# Retrieve pre-computed features in under 5ms
feature_key = f"user_features:{user_id}"
features = self.client.get(feature_key)
if not features:
# Fallback to default baseline features if user is new
return {"tx_count_24h": 0, "avg_tx_amount_30d": 0.0, "is_new_user": 1}
return json.loads(features)
# Example usage during transaction scoring
provider = RealTimeFeatureProvider(redis_host="localhost", redis_port=6379)
user_features = provider.get_user_features("user_982341")Decoupling the policy engine from the machine learning inference service is another critical pattern. The machine learning model should only output a raw probability score (e.g., a risk score between 0.0 and 1.0).
The policy engine then evaluates this score alongside deterministic business rules (e.g., "decline if transaction is over $10,000 and risk score > 0.7"). This separation allows risk teams to update rules and thresholds instantly via a rules engine without redeploying or retraining the underlying models.

Implementing Advanced Fraud Mitigation Patterns#
As payment methods evolve, fraud patterns shift. Two specific engineering challenges require advanced patterns: managing the cold-start problem during account creation and explaining machine learning decisions without breaking the latency budget.
Cold-Start Mitigation: Graph Neural Networks (GNNs) for Account Creation#
Traditional behavioral models rely on historical transaction data. When a user creates a new account, they have no transaction history. This is the cold-start problem, and it is highly vulnerable to synthetic identity fraud.
To detect fraud at the point of registration, you can use Graph Neural Networks (GNNs). GNNs do not look at a single user's history; they analyze the relationships between entities across your platform.
During registration, the system captures metadata:
- Device fingerprints
- IP subnets
- Behavioral biometrics (e.g., typing speed, form navigation patterns)
- Email domain structures
A GNN constructs a graph where nodes represent accounts, devices, and IP addresses, and edges represent shared attributes. If a new registration shares a device fingerprint or IP subnet with an account that was previously flagged for fraud, the GNN identifies this link.
By analyzing cluster density anomalies, the GNN can flag synthetic identity rings—where fraudsters register dozens of accounts using slight variations of the same personal details—before a single transaction is ever initiated.
Operationalizing Explainable AI (XAI) under Latency Budgets#
Regulators and operations teams require explanations for why a transaction was declined or flagged for manual review. In AML AI systems, this explanation is critical for filing Suspicious Transaction Reports (STRs).
However, computing local explanations using frameworks like SHAP (Shapley Additive exPlanations) or LIME is computationally heavy. Running these algorithms inside the 20ms real-time transaction loop is impossible, as they require hundreds of model evaluations to determine feature importance.
To solve this, use the asynchronous explanation pattern:
- Online Path: The real-time scoring engine runs a fast, lightweight inference model (like XGBoost) to approve or deny the transaction. If the transaction is flagged for manual review, the transaction completes its user-facing cycle immediately, keeping the SLA under 50ms.
- Asynchronous Path: The system pushes the transaction payload and the model's prediction score to an asynchronous worker queue (e.g., RabbitMQ or Celery).
- Async Worker: A background worker pulls the task and runs the SHAP explainer to calculate the explanation vector.
- Operations Portal: The worker writes the SHAP values directly to the manual review ticket. When the human analyst opens the ticket in the operations portal, the visual explanation of why the model flagged the transaction is already there.
Regulatory Compliance: Designing DPDPA and RBI Compliant Pipelines#
Operating a fraud detection system in highly regulated markets like India requires strict adherence to local laws. This includes the Digital Personal Data Protection Act (DPDPA), 2023, and the Reserve Bank of India (RBI) guidelines.
DPDPA Data Isolation Requirements#
Under Section 7 of the DPDPA 2023, personal data can be processed without explicit consent for "certain legitimate uses." Preventing, detecting, or mitigating fraud or systemic risk falls directly under this exemption.
However, this exemption comes with a major architectural constraint: strict data isolation.
[Customer Data Ingestion]
|
+---> [Fraud Prevention Pipeline] (Section 7 Consent-Exempt) ---> [Risk Engine]
|
+---> [Marketing & Personalization] (Explicit Consent Required) -> [Ad Server]If you commingle the data pipelines used for fraud prevention with those used for marketing, personalization, or product analytics, you risk losing the consent exemption. If a user withdraws consent for marketing, and your systems cannot prove that their data is isolated solely for fraud prevention, the entire dataset may become non-compliant. This exposes your firm to severe regulatory penalties under the DPDPA.
To mitigate this risk, you must build isolated data lineages. Use separate Kafka topics and distinct database schemas for fraud prevention pipelines. Ensure that data ingested under the Section 7 exemption cannot flow into marketing databases or product telemetry tools.
RBI and FIU-IND Compliance Timelines#
Your architecture must also support the reporting timelines mandated by Indian regulators:
- RBI Master Directions on Fraud Risk Management (updated July 2024): Commercial banks must implement an Early Warning Signals (EWS) framework. When fraud is detected, it must be reported to the Central Fraud Registry (CFR) within 14 days.
- FIU-IND Reporting Guidelines: Under the Prevention of Money Laundering Act (PMLA), financial institutions must report Suspicious Transaction Reports (STRs) within 7 days of forming a logical conclusion of suspicion.
Your system design must automatically move flagged transactions from the real-time scoring engine into an auditable review queue. This queue must track the exact timestamp when a suspicion was flagged, when the analyst began their review, and when the final decision was made. This log ensures you can prove compliance with the 7-day and 14-day reporting windows during regulatory audits.
Commingling fraud detection logs with marketing databases strips your system of the DPDPA Section 7 consent exemption. Keep these pipelines strictly isolated in your database infrastructure to avoid severe regulatory penalties.

Where to Start: Auditing Your Latency and Compliance Footprint#
High-performance fraud detection is not just about model accuracy. It is an engineering discipline of latency management, data isolation, and operational design. To upgrade your existing risk systems, focus on three practical steps.
First, map your end-to-end P99 latency budget. Identify where the bottlenecks live. If your database queries or feature extraction steps are taking longer than 15 milliseconds, migrate those metrics to an in-memory real-time feature store.
Second, audit your data pipelines. Verify that data ingested for fraud prevention under DPDPA Section 7 is physically and logically isolated from marketing and product personalization systems. Draw clear boundaries in your data lineage tools to prove this isolation to regulators.
Third, implement an asynchronous queue for manual review explanations. Stop trying to run complex explainability algorithms inside the critical transaction path. Offload SHAP or LIME calculations to background workers so your online transaction path remains fast and responsive.
By separating real-time scoring from background processing and isolating your data pipelines, you can build a system that blocks fraud instantly, satisfies regulators, and keeps transaction latency low. To begin, catalog your current feature-store latency metrics and identify which queries are blocking your authorization path.