How to Design an AML Rules Engine for Transaction Monitoring

How to Design an AML Rules Engine for Transaction Monitoring

An AML rules engine scans a stream of transactions looking for those that need a human review. You might think the process is just like a filtering thing, but a compliance officer asking for a new limit on Friday and expecting it live on Monday is all you need to change your mind. Let’s say you do it; what if regulators ask your company why a specific alert fired two years ago? And how do you manage analysts asking for fewer alerts, and your team getting the blame when latency grows?

This article will show you how to deal with those challenges by building a configurable rules engine for rule-based transaction monitoring that can process events, manage thresholds and dependencies, version detection logic, and maintain an audit trail.

What the Engine Has to Do

Any AML transaction monitoring system receives events, attaches customer and account context to it, runs detection rules against the result above, and emits alerts with enough evidence for an analyst to decide. While event intake is something that teams have built many times for different services, evaluation and context are where projects get stuck. The diagram below shows a rough explanation of how the flow would be:

AML Rules Engine

In most of the cases the system needs to support two types of rules: those that look at a single transaction (such as a rule that is set to flag any transfer above any specific amount) and rules that check at behavior over time, like a rule that flags ten small deposits followed by one large wire within 48 hours. The first one is stateless, while the other needs a state to evaluate a combination of events during a certain period of time.

Structure of AML Detection Rules

A quick way to write transaction monitoring rules on day one is to hardcode them directly in the code. After three months, you need a new release for each threshold tweak the company has to make. What works better is to build a configurable rules engine with rules being stored as data. Each entry also includes some metadata such as an identifier, a version, a scope, a condition, parameters, and an action. For the condition, keep it narrow so it does not become harder to maintain. If you find yourself with the need to use an entire programming language to define a condition, you better start thinking of splitting that rule.

Here’s another tip: keep conditions and parameters separate. Let’s consider an example: a condition says that the sum of cash deposits in a window reaches a limit, while parameters define the threshold and time window. With this approach, a change of parameters stays inside the same condition, whereas a logic change requires a different review.

Chudovo’s team uses a rule definition like the one below for configurable engines:

{
"rule_id": "STRUCT-CASH-01",
"version": 7,
"scope": { "segment": ["retail"], "channel": ["cash_deposit"] },
"condition": {
  "aggregate": "sum",
  "field": "amount_usd",
  "window": "48h",
  "group_by": "account_id",
  "operator": ">=",
  "limit": "$limit",
  "min_count": "$min_count"
},
"parameters": { "limit": 9000, "currency": "USD", "min_count": 3 },
"action": { "type": "alert", "severity": "medium" },
"effective_from": "2026-07-01T00:00:00Z"
}

The rule groups cash deposits by account and sums them over 48 hours. A medium alert is raised whenever the limit is reached with at least three deposits contributing to it. This example targets retail customers, so we use the scope field to exclude a cash-heavy business account from firing an alert.

Event Flow

Some decisions need to be taken before the funds move. In other cases, the system does asynchronous monitoring to detect suspicious activity after execution. Depending on the case, teams might decide to use stream, batch, or both. Streaming is good for the first case because it provides low-latency evaluation; to analyze activity over long periods, batch fits better.

Another choice teams have to make is about sliding windows vs. tumbling windows. When the system needs to detect structuring patterns, sliding windows are the best choice. The only caveat is that they come with additional processing and state management costs, so keep that in mind when planning.

Accuracy also depends on how you deal with late or out-of-order transactions. A well-designed system uses the event time and deduplicates by transaction ID. Also, the alert itself needs to be deduplicated because when a window crosses the threshold, subsequent transactions might trigger the alert. In this case, what the system should do is attach the new information to the existing alert instead of creating a new one.

The enrichment phase is where the system attaches additional information about customers so rules can do a proper evaluation. What’s important here is to attach the actual values next to the decision. References are weak because customer data might change from time to time.

Thresholds are usually scoped to specific customer segments. To make it easy, store them as parameter sets keyed by segment and separated from logic. Every change should have maker-checker control so each step is recorded by the system. When a new threshold is created, it should be tested against history. Teams could perform below-the-line testing. For example, take one month of transactions and replay them with the new threshold. Record the output and compare it against the past outcome.

Dependencies

Rule dependencies might live in the data or in the system’s logic. An example of the first one is a behavioral rule that relies on a 90-day average that another job computes. For the second one, we could think of a rule that might fire only when another rule has already been fired.

Teams need to model those links as a directed acyclic graph. Also, dependencies have to be validated at publish time, and cycles should be rejected. After that, the engine will be able to sort those rules based on how they connect to each other, and run independent ones in parallel.

Some dependencies could be hard to track. For instance, you could have a rule C that fires only after B has fired. And that rule B also depends on rule A. If someone asks why C stays silent, you need to reconstruct the path from the other two rules. Developers usually build a score aggregator to simplify this: each rule emits a signal with a weight; the aggregator adds them up, and a specific alert fires whenever the score crosses a line. It’s important to keep a breakdown of how each signal contributed to the alert in order to ensure explainability.

Suppression rules need the same care; otherwise they’ll become a blind spot. Every suppression should indicate the owner and the expiry date, if any.

Versioning

While the system may change its rules, each rule should be immutable. Rather than a contradiction, this is something that needs to be done by design.

How does this work? Each rule gets its own version and, once created, it cannot be edited. Any change implies a new version should be created, and the old one is kept for history. Each version also carries the effective-from date; once retired, an effective-to date is also recorded. Both dates give you the validity window for that rule, which is useful when someone asks which rule was live on a specific date.

Rollbacks work the same way: they activate the previous version, never edit the current one.

Because events might arrive late, the system needs to have a clear policy in order to decide which rule applies to each one of them. This information should be stored alongside the other information because it will be needed to reproduce the original result during a replay.

Teams could create a column to store the version state (such as draft, review, shadow, active, retired). The shadow mode is commonly used to test a proposed version before going live. The system will put that one beside the active one, but the recorded logs won’t be sent to analysts. Developers still could use them in order to compare the output against production’s current behavior.

Teams also debate where the source of truth should live. Some prefer Git as it provides diffs, reviews, and history. For others, a database is better because it provides fast runtime queries. A hybrid approach uses Git to keep the rules but publishes them to a database using a pipeline. This separates source control from runtime access.

The Audit Trail

When an alert is fired, a decision log is required to explain which is the rule involved, its version, parameters, input values, and who approved the change. A good place to store this information is a read-only store that holds the actual values used to make the decision. Avoid storing references because data changes over time.

It is also useful to record non-fired events. It helps explain why an alert is silent during a period of time. Because storing the full input snapshot might be expensive, record only that information that’s needed to reconstruct evaluations if someone asks. Skipped rules and failures need to be tracked separately because they differ in nature.  

In all cases, the evaluation has to be deterministic to ensure a replay works as expected.

Performance Considerations

The real bottleneck lies in data access, not in the number of rules. A hundred cheap rules cost less than five windowed aggregates over large accounts. To prevent that, one possible approach is to create an index on rules by their scope. This could be combined with some pre-filters for segment and channel before each evaluation takes place. If you have to compute aggregates, do it incrementally, keep the counters in time buckets, and let the old ones expire.

Teams could have to deal with a merchant that produces a big number of events that overloads the worker. In that case, they could move that account to a separate path and try to split its transactions into separate workers. If you do that, please keep in mind that some aggregation still is needed for stateful rules.

Common Implementation Challenges

Often, a rules system starts accumulating hundreds of rules that cover the same ground, built up over years. This makes the system hard to maintain, because nobody wants to touch something that was there in the code for a long time and nobody knows why. To keep the code clean, it’s better to do a periodic cleanup (two times each year usually is fine) in order to review each rule’s alert and retire the weak ones.

A rules engine is as good as the data it consumes. Bad parameters such as blank counterparty countries and inconsistent currencies might lead to silent rule failures if not considered. Teams should always validate inputs and fail explicitly if the data could not be sanitized. In case of currency conversion, take the exchange rate at the event time and record it with the decision to support the grounds.

Another common pitfall is testing. Developers usually write unit tests on conditions and trust them blindly. They’re not enough. To catch regressions before production, teams need to plan and write scenario fixtures for each typology, in particular for structuring or rapid movement of funds.

When the first dispute over alert volume comes in, it’s better to have clear ownership rules written down. A general agreement is that compliance owns thresholds while engineering owns the platform.

In a previous section, we discussed keeping condition language narrow. This could be challenging sometimes, in particular for some typologies that need graph analysis or statistical models. Criminals adapt and evolve quickly, so the rules have to do the same. A possible approach is to add anomaly models later and keep the rules engine as the explainable baseline.

Conclusion

To build a good AML rules engine, you need more than just a nice set of rules. Your system needs to process transactions reliably, support changes without breaking existing logic, and explain why each alert was generated. Even teams that adopt off-the-shelf AML compliance software still face most of these design choices when they customize it.

The key when dealing with AML software development is to start with a small set of configurable rules. Build the versioning, testing, and audit mechanisms around them; once you have those foundations in place, adding more detection scenarios becomes easier.

We use essential cookies to ensure our website works properly. With your consent, we also use optional cookies for analytics and other purposes. You can accept, reject, or customize your preferences. See our Cookie Policy.