Configurable Reward Points Service
Design a reward-points service that evaluates immutable transaction events against versioned rules, maintains an auditable ledger, and evolves rules without service deployments.
Problem statement
For this exercise, assume an authenticated transaction service submits immutable purchase, refund, and reversal events, each with a globally unique source event ID, member ID, amount, merchant attributes, and transaction time.
Operators publish validated immutable reward-rule versions with effective-time windows and explicit priority, so introducing a rule requires no service deployment. Each source event produces at most one authoritative accrual or reversal under the rule version effective at its transaction time.
Members read a current points balance and accrual ledger, and subscribed consumers receive at-least-once webhooks for committed ledger changes.
Design event ingestion, rule management and publication, deterministic evaluation, durable ledgering, balance reads, replay or correction after a rule issue, webhook delivery, and audit.
Card authorization, payment settlement, member enrollment, reward redemption, partner billing, and promotion-authoring UX are outside scope.
What to build
- Accept immutable purchase, refund, and reversal events idempotently and expose their processing state.
- Validate, publish, inspect, and retire immutable reward-rule versions with effective windows and deterministic priority without deploying service code.
- Evaluate each event under its transaction-time rule version and commit one authoritative, auditable accrual or reversal plus an up-to-date member balance.
- Deliver at-least-once webhooks for committed ledger changes and support bounded replay or compensating corrections after a bad rule publication.
At scale
- Support 50 million members and 20,000 transaction events per second at peak.
- Keep up to 500 active or future immutable rule versions and make a newly published version available for eligible events within 30 seconds.
- Move an accepted event to an auditable terminal result within five seconds at p95 while preserving one logical ledger effect per source event.
- Keep balances and ledger history available through a zone failure, retain financial audit history for seven years, and deliver webhooks at least once.