Recipe
Loyalty Tier System
A three-tier loyalty architecture with progressive rewards, streak mechanics, and anti-abuse guardrails.
Tier Definitions
| Tier | Threshold | Discount | Perks |
|---|---|---|---|
| Bronze | 0–4 purchases | 5% | Early access |
| Silver | 5–14 purchases | 12% | Priority support |
| Gold | 15+ purchases | 20% | Beta builds, custom branding |
Streak Multiplier
Consecutive monthly active days stack a multiplier. Day 1–6: 1.0×. Day 7: 1.5×. Day 30: 2.0× cap. One missed day resets the streak. Multiplier applies to discount depth and reward point accrual.
Anti-Abuse
- Hardware-bound session tokens prevent multi-account farming.
- Purchase velocity cap: 3 transactions per 24h per fingerprint.
- Streak credit requires a verified license check heartbeat.
- Tier downgrade has a 7-day grace window before discount reduction.
Storage Schema
Tier state lives in Upstash KV with a composite key: loyalty:{user_id}:tier. Streak counters use a sorted-set day index. All writes are idempotent with ETag-based optimistic concurrency. The loader queries tier on launch and caches the result for the session lifetime.