Recipe

Loyalty Tier System

A three-tier loyalty architecture with progressive rewards, streak mechanics, and anti-abuse guardrails.

Tier Definitions

TierThresholdDiscountPerks
Bronze0–4 purchases5%Early access
Silver5–14 purchases12%Priority support
Gold15+ purchases20%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.