System Design: In‑Game Currency Transfers and Analytics
Context
You are designing the in‑game currency subsystem for an online game. Players can transfer currency between accounts. Product and ops need:
-
Near real‑time analytics for inflow/outflow totals over the past 24 hours for any account.
-
An hourly balance time series for the past 30 days for any account.
Assume a single in‑game currency, high read volume, and strict prevention of double‑spending. All timestamps are UTC.
Requirements
-
Enable transfers of in‑game currency between accounts.
-
Provide APIs and data models to:
a) Query any account’s total inflow and outflow over the past 24 hours.
b) Retrieve an hourly balance time series for the past 30 days for any account.
Deliver data models, APIs, and any supporting components necessary to meet these requirements with low latency and correctness.