Design a Rolling Restaurant Analytics Dashboard
Design realtime order, revenue, and top-dish analytics over one-hour, one-day, and seven-day windows.
Problem statement
Design a restaurant analytics dashboard that shows order count, revenue, and top dishes over rolling one-hour, one-day, and seven-day windows. Ingest 100,000 orders per second and update results in real time. Define the primary-store schema and partition keys plus query-cache key patterns and TTLs.
Use minute, hour, and day rollups instead of scanning raw orders, scale heavy reads, and rebuild cache state by replaying the retained event log. Compute Top 3 dishes from complete frequency maps and handle late events with watermarks.
For this exercise, assume 500,000 restaurants, 50,000 dashboard reads per second, p95 freshness below ten seconds, two-minute allowed lateness, exact integer-currency aggregation, and seven-day raw-event retention.
What to build
- Accept each completed-order event once with restaurant, dishes, event time, and integer currency amount.
- Return order count, revenue, and exact top three dishes for rolling one-hour, one-day, and seven-day windows.
- Reconstruct rollups and query caches from the retained event log after loss or corruption.
At scale
- Source-backed load: ingest 100,000 orders per second and maintain minute, hour, and day rollups for realtime reads.
- Source-backed query: derive Top 3 dishes from complete frequency maps and apply watermarks to late events.
- Practice assumption: 500,000 restaurants serve 50,000 dashboard reads per second with p95 freshness below ten seconds.
- Practice assumption: accept events two minutes late, retain raw events for seven days, and aggregate money as exact integer minor units.