Design a Donation App
Understanding the Problem
💝 What is a donation app? A donation app lets people give money to a charity or a fundraising campaign, usually by card or a wallet like Apple Pay. Platforms like GoFundMe, JustGiving or a TV telethon's giving page add campaigns with goals, a running total that climbs as people give, and payouts to the charities. The interesting version is a limited-time event: a 24-hour giving day or a live broadcast, where most of the money arrives in a few big bursts.
You may hear this as "design a donation system for a limited-time charity event," "show a running total of donations" or "design a charity platform." They're the same system. The event version stresses the spike and the live total; the platform version adds many charities, campaigns and payouts. We'll cover both.
Functional Requirements
Core Requirements
- Users should be able to browse charities and campaigns, including a campaign's goal, start and end time.
- Users should be able to donate an amount to a campaign while it's open, and get a receipt.
- Users should be able to see a campaign's running total, and its progress toward the goal, updating live.
- Charities should receive the money donated to them.
Below the line (out of scope)
- Recurring (monthly) donations.
- Tax receipts per country, gift aid and other compliance rules beyond "keep good records."
- Charity onboarding and verification (KYC), which is a manual review process.
Non-Functional Requirements
Ask your interviewer what the event looks like. For ours: a 24-hour giving event expects about 5 million donations. It runs alongside a live broadcast, and when the host says "give now," donations jump to roughly 5,000 per second for a few minutes. Up to 1 million people have the page open, watching the total.
Core Requirements
- The system must never charge a donor twice for one donation, and never lose a donation that was charged.
- The system should handle spikes of ~5k donations per second without errors or slow checkouts.
- The running total should be visible within a few seconds of a donation, and exact once the event ends.
- Donating should be highly available. A donation we fail to take is money the charity never gets back.
Below the line (out of scope)
- Multi-region active-active. One region with good failover is enough.
- Building our own card processing. We use a payment provider (Stripe, Adyen, Braintree).
The numbers are modest in total but spiky. 5M donations in 24 hours averages about 58 per second, but the broadcast spikes are ~100 times that. Every donation adds to the same campaign total, which makes it a hot counter. And 1M watchers polling a total every 2 seconds would be 500k reads per second for one number.
The trick in this problem is noticing that the two "real-time" parts have very different correctness needs. The charge must be exact and durable. The total on the screen can be a few seconds behind and approximate during the event, as long as it's exact at the end. Design them separately.