Welcome to the Jose Madrid Salsa developer docs — explore features, APIs, and deployment guides.
Jose Madrid SalsaJMS Docs

Loyalty Program

Points, tiers and the discounts they earn.

Loyalty Program

Customers accumulate points, points determine a tier, and a tier carries a standing discount. Implemented in lib/loyalty.ts, exposed through /api/loyalty.

Earning

ActionPoints
Purchase10 per dollar spent
Referral500
Writing a review50
Birthday250

Tiers

Tier is derived from lifetime points, so it never goes down when points are redeemed.

TierLifetime pointsStanding discount
BRONZE0
SILVER5005%
GOLD1,00010%
PLATINUM2,50015%

Data model

LoyaltyAccount is created lazily — getOrCreateLoyaltyAccount(userId) returns the existing account or makes one, with the ten most recent transactions attached. Every change goes through awardPoints(), which writes a transaction row, updates the balance and lifetime total, recalculates the tier, and reports whether the tier changed so the caller can congratulate the customer.

Points are awarded with a positive value and redeemed with a negative one — there is one code path, not two.

How is this guide?

Edit on GitHub

Last updated on

On this page