Preparing your design workspace

Loading the problem and your latest saved attempt…

Design Monthly Stream Royalties and Artist Payouts

Turn duplicate-prone playback events into auditable monthly artist statements and one safe external payout per statement.

Problem statement

For this exercise, assume a music platform receives trusted eligible playback events and pays each artist once per UTC calendar month through an external payment provider. Each event supplies an immutable event ID, artist ID and occurrence time; delivery is at least once. Artist attribution is already resolved.

A supplied versioned rate gives an integer amount in one currency's minor units per eligible stream for that month. The amount owed is the unique eligible stream count multiplied by that rate, with exact integer arithmetic.

Accept a month's events until 48 hours after that month ends. After the cutoff, an event for that month is explicitly rejected and audited, not silently added to a finalized statement. A retry of an already accepted event remains a duplicate success.

Finalize one immutable statement per artist/month only after every event accepted before the cutoff has been accounted for. An artist with zero earnings has a zero statement and no provider transfer. An operator can start or retry the monthly close; artists can view their counts, rate version, amount and payout status.

There is no withdrawal-on-demand balance.

Each positive statement authorizes one logical payout. Provider requests have durable idempotency keys and a lookup operation for that same key; identical retries cannot create another transfer, and changed payloads conflict. Provider replies and callbacks may be lost, late or duplicated.

An unknown outcome must stay pending until provider evidence resolves it; never treat a timeout as proof that no money moved. A confirmed rejection ends that payout without a transfer and is surfaced for operator review. Do not silently change the finalized amount or destination to retry it.

Design durable ingestion, duplicate handling, month closure, exact statement calculation, external dispatch and reconciliation. Artist payment destinations are already verified and fixed for the statement; a user may read only their own records.

Licensing splits, fraud classification, taxes, foreign exchange, destination onboarding, retroactive eligibility changes and changing finalized statements are outside scope.

What to build

  1. Trusted producers submit eligible playback events with stable identities and receive accepted, duplicate, conflicting or cutoff-rejected outcomes.
  2. An operator starts or retries monthly close, producing one immutable artist statement from all unique events accepted before the cutoff and the pinned monthly rate.
  3. Each positive statement creates at most one external transfer, and artists can inspect statement details and truthful pending, paid or rejected payout status.
  4. Operators can reconcile lost responses and duplicated or delayed provider evidence without changing statements or creating a second transfer.

At scale

  • For this exercise, assume 100 million playback events per day, peaks of 10,000 events per second, and 500,000 artists, with highly skewed popular-artist counts.
  • For this exercise, complete a healthy monthly close and submit all positive payouts within 24 hours after the 48-hour late-arrival cutoff; the provider accepts at most 100 transfer requests per second.
  • For this exercise, target 500 ms p95 for healthy durable event acknowledgement and artist statement reads. Provider settlement is asynchronous and has no fixed completion-time guarantee.
  • For this exercise, retain replayable accepted events and rejected-event audits for 90 days, and immutable statements, payout identities and settlement evidence for seven years. A single-zone failure must not lose acknowledged events or finalized statements.