KatInterview

Loyalty Ledger: Building a Transaction-to-Points Rewards System

System DesignModel answer
HardModel answerSystem Designdistributed-systemsledgeridempotency

Last updated

Design a service that converts card transactions to loyalty points, ensuring exactly-once processing, precise arithmetic, and safe redemptions.

You're building a rewards platform that converts customer purchases into loyalty points. Every dollar spent earns 1.5 points. The system must ingest card transaction events (settlements, refunds, reversals), maintain accurate point balances, and allow customers to redeem points for rewards.

Your design should address:

  • API contracts for ingesting transactions, querying balances, and processing redemptions
  • Precision and rounding to avoid drift when converting fractional points across millions of transactions
  • Idempotency and deduplication so replayed or duplicate events never double-credit accounts
  • Consistency guarantees appropriate to each operation (earning, redeeming, querying)
  • Data model that supports auditability, corrections, and historical analysis
  • Fraud and abuse prevention including velocity limits and negative balance detection
  • Scaling strategy to handle peak transaction volumes and read traffic
  • Observability to detect discrepancies, lag, and system health issues
  • Backfill and correction flows for fixing historical data or rate changes

Assume 10 million accounts, 50 million transactions per day (average 600 TPS, peak 5k TPS), and redemptions roughly 100× less frequent than earns.

Walk through your architecture, explain trade-offs between consistency models, and describe how you'd test and roll out the system safely.

Hints

Hint 1

Think of this as a financial ledger problem, not just a multiplication task—immutability and auditability are key

Hint 2

Store points as milli-points (integer × 1000) to eliminate floating-point rounding errors entirely

Hint 3

Partition everything by account_id so transactions for a single account stay ordered and single-shard