Design a Three-Day Charity Donation Drive
Take donations for a fixed three-day charity drive through a third-party payment provider, acknowledge each donor right away, show a live total, and close the drive with a total that matches the money collected.
Problem statement
A charity runs one donation drive that is open for a fixed three-day window and is expected to process about $100 million. Payment is handled by an external third-party provider.
The system must handle the donation flow, payment through the provider, real-time acknowledgement, and correct money movement over the fixed window.
For this exercise, assume the following. Donors give online: they open the drive page, choose an amount, and enter their card in the provider's hosted payment form, so your system never sees or stores card numbers.
Each donor gets an acknowledgement as soon as the donation is accepted, and then one final result: confirmed with a thank-you receipt, or failed with a clear reason. The drive page shows a live running total and donor count.
The provider can answer late, report the same result more than once, or time out even though it charged the card, so the system must never lose a donation it has accepted and must never charge a donor twice for one donation.
At the published closing time, new donations are refused, donations accepted before then are finished, and the final total must match the money the provider actually collected.
Design the APIs, durable state, the donation and confirmation paths, the live total, and the end-of-drive close and reconciliation. Refunds, chargebacks, recurring or matched gifts, fraud screening, currency conversion, tax filing, and building the payment provider are outside scope.
What to build
- For this exercise, a donor submits an amount for the open drive with a request key and gets an immediate acknowledgement with a donation ID; sending the same key again returns the same donation instead of creating another.
- For this exercise, each accepted donation is charged through the provider at most once and reaches exactly one final state, confirmed or failed, even when provider results are late, repeated, or unknown after a timeout; the donor sees that final state, and a confirmed donor gets one receipt.
- For this exercise, anyone viewing the drive sees a running total and donor count that include only confirmed donations and update within seconds.
- For this exercise, at the published closing time the drive stops accepting new donations, finishes every donation it accepted before then, and produces a final total that matches the provider's settlement records, with every difference explained.
At scale
- The drive is expected to process about $100 million over its fixed three-day window. For this exercise, assume about 2 million donations (near $50 on average), with submissions peaking near 1,000 per second for up to 10 minutes during broadcast appeals.
- For this exercise, assume the provider accepts that peak payment rate and usually returns a result within 2 seconds, but it can time out after charging a card, sends signed result notifications that may be repeated or delayed by minutes, and lets you look up a payment by your idempotency key.
- For this exercise, target an acknowledgement within 1 second at p99, a final confirmed or failed result for 99.9% of donations within 2 minutes, and a public total that is at most 5 seconds behind confirmed donations while up to 300,000 viewers watch it.
- For this exercise, assume the drive refuses new donations at its published closing time, and the final total must match the provider's settlement report to the cent within 48 hours after the close, with every difference explained.