Design Group Purchase Contributions and Settlement
Design a group checkout that tracks participant contributions, deadlines, merchant settlement, and exact refunds.
Problem statement
For this exercise, assume an organizer creates a group purchase in one currency for a fixed merchant amount and invites at most twenty participants. Each participant receives an assigned contribution and may authorize it once before the deadline.
The system must show paid and unpaid participants, settle the merchant exactly once only when the full amount is funded, expire underfunded groups at the deadline, and refund every captured contribution to its original payment instrument if fulfillment later fails.
Payment providers are asynchronous and at-least-once; money is represented in minor units. Assume one million groups per day, a peak of 3,000 contribution updates per second, a seven-day funding window, and seven years of immutable financial audit history.
Cross-currency conversion, credit underwriting, and marketplace dispute arbitration are outside scope.
Design the APIs, durable state, services, routing, idempotency, reconciliation, deadline processing, settlement, refund distribution, and regional failure behavior.
What to build
- For this exercise, an organizer creates a fixed-allocation group and participants authorize their assigned contributions before its deadline.
- The system reports each participant as paid, unpaid, pending, or terminally failed without trusting client assertions.
- The merchant is settled exactly once only after full funding; an underfunded group expires under one authoritative deadline order.
- If fulfillment fails after funding, every captured contribution is refunded independently to its original instrument and aggregate progress remains observable.
At scale
- Source fact: track participant contributions, unpaid participants, settlement deadlines, refund distribution, high-level services, database, and routing.
- Practice assumption: support one million groups per day, at most twenty assigned participants per group, and a peak of 3,000 contribution updates per second.
- Practice assumption: funding remains open for at most seven days, provider operations are asynchronous and at least once, and all money uses integer minor units.
- Practice assumption: retain immutable financial audit entries for seven years and keep one fenced home-region writer for each group.