KatInterview

Backend Architecture for a Live Fundraising Platform

System DesignModel answer
MediumModel answerSystem Designpaymentsidempotencyreal-time

Last updated

Design a scalable donation system handling 5k writes/sec with payment idempotency, real-time aggregation, and strict financial consistency.

Context

You're architecting the server-side infrastructure for a fundraising platform that supports charitable organizations and content creators running live donation events. The system must handle sudden spikes in donation volume, integrate safely with third-party payment processors, ensure donors are never charged twice, and display live progress updates to thousands of viewers.

Core Requirements

Must Support

  • Fundraiser Creation: Organizations launch fundraising drives with target amounts and deadlines. Supporters can browse active drives.
  • Payment Processing: Accept donations of any amount via credit card or saved payment methods. Send automated tax receipts by email after successful payment.
  • Live Updates: Show a running total and recent supporter list on each fundraiser page, updating within 1–2 seconds of payment confirmation.
  • Financial Records: Maintain an unchangeable audit trail of all payments, refunds, chargebacks, and transfers.

Quality Attributes

  • Payment Reliability: Prevent duplicate charges even when users retry, connections drop, or webhooks arrive out of order.
  • Uptime: Maintain 99.99% availability during peak live events.
  • Consistency Trade-offs: Financial ledgers require strict correctness; live counters can tolerate brief delays up to 2 seconds.
  • Security & Compliance: Meet PCI-DSS requirements (no storing raw card numbers), detect fraudulent patterns, encrypt sensitive data.

Traffic Profile

  • Active Fundraisers: Around 10,000 running concurrently.
  • Burst Load: A single popular live event can generate 5,000 donations per second.
  • Viewer Concurrency: Up to 100,000 people watching progress on a single fundraiser simultaneously.

What You Should Address

  1. API Design: Describe the key endpoints for submitting donations, receiving payment provider callbacks, and retrieving fundraiser statistics.
  2. Database Schema: Outline tables for fundraisers, supporters, payments, and immutable financial records.
  3. Payment Flow & Idempotency: Walk through the complete lifecycle of a donation from submission to confirmation, explaining how you guarantee exactly-once charging despite retries and network failures.
  4. Real-Time Aggregation: Explain how you update fundraiser totals and broadcast changes to many viewers without database lock contention.
  5. Resilience: Discuss how you handle payment gateway timeouts, delayed or duplicate webhooks, and system recovery.

Hints

Hint 1

Separate the money path (strict consistency) from the display path (eventual consistency with short lag)

Hint 2

Use idempotency keys generated client-side and stored server-side with unique constraints to prevent duplicate charges

Hint 3

Aggregate donation totals asynchronously using a message queue partitioned by fundraiser, avoiding hot-row updates