Design a Scalable Loyalty Points Service (USD → Points at 1 USD = 1.5 Points)
You are designing a service that awards loyalty points for purchase transactions denominated in USD at a fixed conversion rate of 1 USD = 1.5 points. The service must support awarding, querying balances, and redeeming points at scale, with correctness and auditability.
Assume transactions arrive from a card/payments platform and that points should be awarded only for posted/settled transactions (not authorizations). Redemption must prevent double-spend.
Cover the following:
-
API Design
-
Ingest transactions for awarding points
-
Query balances
-
Redeem points
-
Idempotency and Deduplication
-
How to ensure exactly-once awarding and idempotent client retries
-
Precision and Rounding
-
Units to store money and points, conversion math, rounding policy
-
Consistency Model
-
What is strong vs. eventual, and where to apply each
-
Data Model and Schema
-
Tables, keys, indices, constraints, and how balances are computed
-
Prevention of Double Counting and Fraud
-
Controls for duplicate events, replay, redemptions, and abuse
-
Real-time and Batch Processing
-
Streaming path for new transactions and batch backfills
-
Backfill and Correction Flows
-
Handling refunds, chargebacks, retroactive fixes, and rate changes
-
Scaling and Partitioning Strategy
-
Per-account ordering, sharding, and throughput considerations
-
Observability
-
Metrics, logs, tracing, and audits to ensure correctness and SLAs
-
Rollout and Testing Plans
-
Validation, shadowing, canaries, and guardrails