</> MAANG.io
system design · 301

Advanced

Master system design interviews with scalable architecture patterns, distributed systems, and real-world design challenges.

0/480 solved 0% complete

Section 12: Every Rule Becomes a Number - Follow-up Feature Evolution

Executive Summary: This section extends the shipped design with the features product asks for next: percent-drop alerts, "notify me again on further drops", back-in-stock alerts, email fallback, daily digests, more marketplaces, and smarter tiering. For each: what changes, what doesn't, and which door was left open. Most price rules compile to an absolute target; new event types get their own index; new channels reuse the notification id. The one key change, watch_type, goes in through expand-migrate-contract under live traffic.

The interviewer relaxes. "It shipped. Product has a list. Evolve it." Two answers fail: redesigning, or confessing you built the list already, which makes Section 2's scope cuts theater. The strong answer walks each feature through an extension point named earlier.

Key Insight: The crossing band works because of one invariant: every ARMED watch has a target below the current price. Any new rule that keeps that invariant costs nothing at evaluation time. So for each new rule, ask first: "can this compile to a number?"

Percent Drops and Drop Ladders: Compile, Don't Evaluate

Interviewer: "Users want 'tell me on any 15% drop'. Your index is keyed on an absolute target."

You: "Then we turn the percentage into an absolute target when the watch is armed. If Maya sets 15% on B0EXAMPLE4 at $399.99, we store target_minor = 33999. The evaluator never sees a percentage, so the band newPrice ≤ target < oldPrice stays exactly as it is."

The same trick gives us the ladder, which was D10's flip trigger. Today Maya's watch fires at $278.00, sits TRIGGERED, and re-arms only when the price climbs back above $299.00 × 1.02. With "notify me again on further drops", the watch re-arms as soon as D10's 24-hour window ends, through the same re-arm sweep (Section 8), with a target 5% below the lower of the last notified price and the current price: from $278.00 that's 27800 × 0.95 = 26410, or $264.10. Because the target is set below the current price at re-arm time, the invariant holds, and the 24-hour cap holds without any check in the band. arm_gen goes up by one, so the next crossing gets a new deterministic notification id.

Absolute, percent and ladder rules all compile to one absolute target_minor, indexed and scanned by the crossing band newPrice <= target < oldPrice; an arbitrary rule like below 30-day low cannot compile and needs a stream processor (D4 flip)

Rule Compiles to Rejected alternative Flip trigger
Percent drop current × (1 − p) at arm time evaluate percentages per event (scan every watcher of the ASIN) —
Ladder min(last_notified, current) × 0.95 when the 24 h window ends notify on every check below target (spam) —
"Below the 30-day low" doesn't compile: the threshold moves with history forcing it into the band such rules become common → stream processor holding watch state (D4)

Quick check before moving on:

Sign in to continue reading

The rest of this lesson is available with a free account. Signing in with Google or Microsoft is free.

Sign in to read the full lesson

Sign in to MAANG.io

Use your Google or Microsoft account — no password to remember.

Continue with Google Continue with Microsoft

Please accept the terms above to continue.