Preparing your design workspace

Loading the problem and your latest saved attempt…

Design a Top-Selling Items and Categories Dashboard

Design a fresh top-ten sales dashboard using partition-local item and category aggregation, durable state, and bounded global merges.

Problem statement

Design a dashboard that shows the top 10 items and top 10 categories ranked by quantity sold.

Explain the item-quantity and category aggregators, how each obtains its current count, how often high-volume updates are written to state, how final aggregates are retrieved from partition-local RocksDB instances, when partition results are merged, and how to avoid publishing one intermediate event for every one of one million input events.

For this exercise, assume each accepted sale event has a unique event ID, item ID, category ID, positive quantity, and event time; corrections, returns, and arbitrary historical filters are outside scope.

For this exercise, assume each ranking is cumulative from service inception through the exact per-partition offsets named by its published watermark, with no rolling-window reset; equal quantities are ordered by stable item or category ID ascending.

For this exercise, assume one peak processing interval may ingest one million accepted events, dashboard reads should complete within 300 milliseconds p95, published top-ten results may lag accepted events by up to one minute, and a replayable source log plus RocksDB changelog or checkpoints can recover processor state.

What to build

  1. The platform accepts deduplicated sale events containing item, category, and positive sold quantity.
  2. Stream processors maintain durable current item and category counts in partition-local state.
  3. The system periodically merges partition results into cumulative top-ten lists through a declared source watermark, ranking by quantity descending and stable item or category ID ascending for ties.
  4. Dashboard readers receive a fast result with ranking version, event watermark, and freshness metadata.

At scale

  • Source fact: the discussion considers one million input events and asks how to avoid one intermediate publication per event.
  • For this exercise, assume cumulative rankings cover all accepted events from service inception through the declared per-partition offsets, with no rolling-window reset.
  • For this exercise, assume one peak processing interval can contain one million accepted sale events.
  • For this exercise, target 300 milliseconds p95 dashboard reads and allow published rankings to lag accepted events by at most one minute.
  • For this exercise, accepted events are replayable and partition-local RocksDB state is recoverable from changelogs or checkpoints.