Engineering
Events, Delivered Fresh: Rebuilding the Licious Marketing Event Platform
How we replaced a pile of hand-written event handlers with a platform where a marketing event is a configuration — not a class, not a deploy, not a two-week wait.
Somebody is counting
Add a pack of chicken to your Licious cart and, somewhere behind the app, a handful of small messages leave our backend. They go to AppsFlyer, Firebase, GA4 and Meta — the tools our marketing team uses to measure campaigns, and the ones that answer questions like "did the ad we ran yesterday actually bring in new customers?"
These are marketing-technology events, or martech events. They are not glamorous. Nobody demos them. But almost every rupee of marketing spend is judged by them, which means when they are wrong, the decisions made on top of them are wrong too.
For a long time, adding one of these events at Licious meant writing a Java class and shipping a release. This is the story of why that stopped being acceptable, and what we built instead.
The old system, and why we picked this problem
The first version did work. It consumed business events from Kafka, and for each event-and-vendor pair there was a piece of code that filtered the message, mapped its fields, and called the vendor's API.
The problem was that every one of those pieces looked almost exactly like the others.
Six things pushed us to rebuild rather than keep patching:
1. Every new event needed engineering. The marketing team would ask for something small — "send us a purchase event, but only for seafood" — and the honest answer was next sprint. A business question had become a deploy.
2. We could not follow a single event. We had counters: N events sent to vendor X today. Useful for a dashboard, useless for a question like "what happened to this particular order?" When someone reported a missing event, we had no way to prove it had been sent, or to show where it had stopped.
3. So we could not settle arguments about drops. Periodically a vendor's numbers disagreed with ours. We suspected the loss was upstream — events never fired, web gaps, missing device identifiers — but suspicion is not evidence. Without per-event visibility, these discussions ran on vibes.
4. Failures were effectively lost. The dead-letter path wrote a log line. There was no bounded retry, no queue you could look at, and no way to replay. A vendor having a bad ten minutes meant a permanent hole in the data.
5. Vendors were coupled to each other. Vendor calls happened one after another, so one slow API added latency to everybody behind it in the queue.
6. Adding a vendor meant more of the same. We were about to onboard Firebase as a direct destination, and the only way to do it was to write another ten near-copies of the same three steps.
Put together, the real cost was not the duplicated code. It was that we had a system nobody fully trusted, which also happened to be the bottleneck for the growth team. That combination is what made this worth doing properly rather than incrementally.
The one idea: an event is a recipe
The whole rebuild rests on a single decision: no event name exists in code.
Instead, every event is described by a declarative configuration we call an event definition. It is easiest to think of it as a recipe. It says: when a message lands on this topic, pull out these fields, look up this extra information, keep it only if these rules pass, and deliver it to these tools with these field names.
{
"name": "charged_category",
"status": "ACTIVE",
"source": {
"topic": "order-events",
"match": { "all": [{ "path": "eventType", "op": "EQ", "value": "ORDER_PLACED" }] }
},
"attributes": [
{ "name": "orderId", "from": "order.id" },
{ "name": "orderValue", "from": "order.billTotal" }
],
"enrichments": [{ "type": "CATALOG", "config": { "fields": ["category"] } }],
"filters": { "all": [{ "type": "CATEGORY", "categories": ["chicken", "seafood"] }] },
"destinations": [
{ "vendor": "appsflyer", "outgoingEvent": "af_purchase",
"mapping": [{ "to": "af_revenue", "from": "orderValue" }] }
]
}
Everything the runtime needs is in that document. The code that reads it has no idea what a purchase is, what a category is, or which vendor is which — it only knows how to execute the stages a definition asks for.
The payoff is a clean split. A new event is configuration: no deploy. A genuinely new capability — a new kind of lookup, a new vendor — is a small, one-time code plug-in that is then reusable forever from configuration. We aimed at roughly one engineer-day to add a vendor, and in practice that has held.
How an event travels
Every message walks the same seven stages, in the same order.
Decode — raw Kafka bytes (Avro or JSON) become readable data.
Match — which recipes care about this message?
Extract — pull out the declared fields, correctly typed.
Enrich — look up what the message did not carry: the customer's order history, the product's category, which segments the customer belongs to.
Filter — keep only what passes the rules, which compose with AND / OR / NOT.
Dedup — drop repeats inside a time window, so a customer is not counted twice.
Route — fan out to each enabled destination, building that vendor's exact payload.
The important part is not the list. It is the dashed line in the diagram: every stage records its outcome. If an event was ignored, filtered, deduped, or failed at a vendor, we know which stage and we know why. Filtered is not the same as lost, and both are visible.
This single property changed the character of the system more than anything else we built. "The event is missing" used to start an investigation. Now it starts with a search, and usually ends in a sentence: it stopped at Filter, because the device identifier the vendor requires was never set.
Making it hard to lose things
Traceability tells you what happened. It does not, by itself, stop bad things happening. Four pieces do that.
At-least-once, properly. A source message's Kafka offset is committed only after every enabled destination has either succeeded or been durably handed to a dead-letter queue. A pod can die mid-flight and the work resumes.
Bounded retries and per-vendor isolation. Failures retry with exponential backoff and jitter, then stop and dead-letter. Each vendor sits behind its own circuit breaker and its own rate limiter, so a vendor having an outage slows down exactly one stream and nothing else.
A dead-letter queue you can actually use. Failed deliveries are searchable, with the reason, the stored payload and the event's journey in one place. From there you can replay them, abandon them, or sweep away a class of failure that no replay will ever fix.
Malformed messages are isolated, not fatal. A message that fails to decode is parked and traced. It never crashes a consumer and it is never silently dropped.
On top of this we added alerting that works in percentages rather than raw counts, with a minimum sample size and a cooldown, so a quiet hour does not page anyone and a genuine five-percent dip does.
Handing the keys to the people who need them
An engine that only engineers can configure has solved half the problem. The other half is a console.
The console mirrors the pipeline deliberately — its wizard steps line up with the engine's stages, so what you build is what runs. A few choices in it mattered more than the rest:
Everything new starts as a draft. A definition does nothing at all until someone activates it.
Editing publishes a new version. Old versions stay, with a one-line change note, and you can roll back.
You can dry-run against real traffic. Pick a topic, catch the very next real message, and watch it walk the seven stages — what matched, what got added, whether a rule kept it, which vendors it would reach. Nothing is actually sent.
Grouping is self-serve. Our catalogue has fine-grained categories; campaigns usually want coarser buckets. Folding several catalogue categories into one reporting name is now a few rows in a form, not a ticket.
Nothing is deleted. Definitions retire to an archived state and can come back.
The result is that most event changes no longer involve engineering at all — and the ones that do are genuinely new capabilities, which is where we would rather spend the time.
Moving house without dropping anything
The least glamorous part of this project took the most effort, and it is the part I would most want another team to copy.
We did not switch over. We ran the new platform alongside the old one in shadow mode — processing everything, delivering nothing — and then cut over one vendor at a time — AppsFlyer first — each behind its own flag, each reversible by flipping that flag back.
Then we compared the two systems — and comparing two systems that disagree turned out to be harder than building either of them. The old path double-called part of its processing, so its raw counts were inflated. The new platform deduplicates, so its counts were lower and more correct. Category names differed in capitalisation between the two. Rules for things like "new customer" were subtly different. Every one of those had to be understood before any number could be called a mismatch, and a few of them were the mismatch.
What made this survivable was that parity was a measurement, not an opinion: we had per-event traces on the new side and could reconcile against the company's own data warehouse — a system we do not control — rather than against ourselves.
What we would tell ourselves at the start
Configuration is code, so give it the same respect. The scariest incident of the build was not a bug in the pipeline. It was a configuration edit saved in an older shape, which silently emptied a list of topics and quietly unsubscribed a set of events. It was fixed with validation and guards — but the lesson is that a form which can cause an outage needs the same care as a deploy that can.
Traceability is a feature, not instrumentation. We justified it as debugging. It turned out to be the thing that let us negotiate with vendors, settle disputes with analytics, and prove a cutover was safe. Build it first, not last.
"No deploy" is a promise about events, not about everything. New vendors, new kinds of lookup and new filter operators are still code. Being honest about that line stopped the platform from drifting into a general-purpose rules engine nobody could reason about.
Every lookup costs latency. Enrichment is the easiest thing to over-order from a form. We cache it, and we encourage people to add only what a rule or a destination actually reads.
Observability data grows faster than you expect. Per-event, per-stage traces are wonderful until a disk fills. They need retention limits from day one.
Contributors
Pranshu Arora — Platform design and implementation, console, cutover
Aman Sinha, Kritika Bahia — Review and technical direction
Thanks to the Growth, Data and Web teams for the parity work and for patiently re-running comparisons.





