KatInterview

Fast Dashboards and Auditable Finance Tables from One Event Stream

System DesignModel answer
MediumModel answerSystem Designdata-pipelinestream-processingbatch-processing

Last updated

Design a marketplace order-event pipeline that serves five-minute operational metrics and a reproducible next-morning finance table, weighing batch, streaming, and hybrid approaches.

Scenario

You are the data architect for an online marketplace. Order lifecycle events (placed, paid, shipped, cancelled, refunded, and so on) flow in continuously. The feed is messy: events can be duplicated, arrive late, or arrive out of order. Two groups depend on the data:

  • Product teams want operational metrics (orders, revenue, cancellations) that are no more than five minutes behind.
  • Finance wants a daily table, available the next morning, that can be regenerated exactly for a stated input version.

Historical corrections and event-schema changes are both expected over time.

Given facts

  • Every event has a stable event ID, an event-time timestamp, and an order ID.
  • The source can replay retained events, but consumers must not assume exactly-once delivery over the network.
  • The operational view may be eventually consistent. The finance table must be reproducible.
  • Pick technologies by capability, not by vendor.
  • Privacy, access control, and deletion requests are part of the design.

What to cover

1. Choose the processing model. Compare batch, streaming, and hybrid designs on latency, correctness, operational complexity, replay, and cost. Make a recommendation and say what evidence would change it.

2. Design the data flow. Walk through ingestion, durable storage, validation, deduplication, event-time handling, stateful computation, batch finalization, metadata, and serving. Explain how data contracts and schema evolution are handled.

3. Operate and validate. Explain how you would roll out changes, detect wrong-but-healthy output, recover from failures, and check that the fast view and the finalized view agree within their documented semantics.

Before designing, list the clarifying questions you would ask (volume and peak rate, what "five minutes" actually measures, how late events can be, joins against mutable reference data, and whether consumers need updates and retractions or only appended versions) and state the assumptions you adopt.

Hints

Hint 1

Begin with the two service levels rather than defaulting to streaming: one is about how quickly an answer appears, the other about how much that answer can be trusted and reproduced.

Hint 2

Keep an immutable raw copy of every event so corrected logic can be rerun later, and decide for every write boundary what makes a retry harmless (deterministic keys, upserts, atomic swaps).

Hint 3

Healthy infrastructure does not imply correct numbers. Think about monitoring freshness, volume, duplicate rates, late-event rates and reconciliation between the fast and final outputs.