Multi-tenant loyalty SaaS
PerkPass
Loyalty programs that live in Apple Wallet and Google Wallet, with a business admin platform and native staff apps for iOS and Android.
- Role
- Architecture, full-stack engineering, product ownership
- Team
- Wasabi engineering, with a small development and QA team
- Platforms
- Web admin, iOS, Android, Apple Wallet, Google Wallet
- Status
- In production with its first business customer



The problem
Many small businesses in Honduras run their loyalty program on paper punch cards, if they have one at all. Dedicated loyalty apps rarely work for them: customers won't install one app per coffee shop, and the business has no way to reach them after they leave.
PerkPass puts the loyalty card where the customer already has one: Apple Wallet or Google Wallet. A customer scans a QR code at the counter, types a name, and has a card on their phone in seconds. Staff record purchases and redemptions from a mobile app. The business configures programs, rewards, and pass designs from a web admin.
I designed the architecture, built much of the platform myself, and led the Wasabi engineers and QA work that took it to production.
System overview
PerkPass is one product with four audiences, and each gets a surface built for them. The Next.js admin application also hosts the backend: API routes for the staff app, background jobs, the Apple Wallet web service, and the public enrollment and card pages. One deployable unit with a single data access layer let a small team move quickly without splitting tenant rules across services.
Who uses it
- Business adminsWeb admin
- Supervisors & staffiOS and Android app
- CustomersWallet pass, web card, QR enrollment
- Wasabi operatorsPlatform console
Application
- Next.js platformAdmin UI, REST API, public pages
- Tenant scopeRequest-scoped tenant context
- Loyalty enginePoints, stamps, cashback, rewards
- Wallet issuancePass signing, updates, Google objects
- JobsQueues and scheduled work
Infrastructure
- PostgreSQLSeparate schemas per environment
- Supabase AuthSessions and JWTs
- RedisRate limiting
- APNs · Google Wallet APIPass delivery and updates
- Wasabi AdminSubscription billing and fiscal invoices
Multi-tenancy
Every business is a tenant, and every row of business data carries a tenant id. The important decision was where to enforce that boundary.
The server talks to PostgreSQL through a privileged connection pool, so row-level security would not protect anything at runtime. I made the application layer the explicit tenant boundary and designed it so it is hard to bypass:
- Each request runs inside a tenant scope held in
AsyncLocalStorage, set once after authentication. - Repositories apply the tenant filter themselves; route handlers never build tenant conditions by hand.
- Loyalty tables use composite foreign keys that include the tenant id, so a transaction can't reference another business's customer or program, even by mistake.
- A record that belongs to another tenant returns the same response as one that doesn't exist. The API never confirms that another business's data is there.
Authority comes from the membership record that links a user to a business, never from anything the client sends. Roles are admin, supervisor (limited to assigned locations), and staff, plus separate platform roles for Wasabi operators and app review.
The loyalty engine
A business can run points, stamps, and cashback programs at the same time, plus memberships, coupons, customer levels, and referrals. That makes a single purchase a multi-program operation.
- One purchase, one transaction. Recording a purchase evaluates every eligible program and awards all of them atomically, with row locks on the affected balances.
- Idempotent by design. The staff app sends a client operation id with every write. A retried request after a dropped connection can't award points twice.
- Money as integers. Amounts are stored in cents and rates in basis points. Points expire by lot, with accumulation caps per program.
- Every redemption is traceable. Each one gets a short reference code that staff and customers can quote.
Apple Wallet and Google Wallet
Wallet passes are the customer-facing product, so this integration had to be dependable.
Apple Wallet. The platform builds .pkpass bundles and signs them with PKCS#7. It implements Apple's PassKit web service so devices register for updates. When a balance changes, the server sends an APNs push over HTTP/2, reusing connections, and the device fetches the new pass. The customer sees the updated card and a lock-screen notification within moments of the purchase.
Google Wallet. Loyalty and generic objects are created through the Google Wallet API with a service account. Customers add them through signed save links, and object ids are versioned so a layout change can roll out without breaking existing cards.
Wallet Designer. Businesses design their own passes in the admin, with a live preview for both platforms. Designs are saved as drafts and published as versions, so a half-finished change never reaches customers' phones.




Enrollment and staff workflows
Each business and branch has a QR code that opens a short enrollment page. A name is enough to get a card. Every extra field slows down the line at the counter, and the business can collect the rest later.
The staff app is built with Expo and React Native for iOS and Android. Its main jobs are finding a customer by scanning their pass or searching by phone, recording purchases, redeeming rewards, verifying memberships, and registering new customers.
Connectivity at a counter isn't guaranteed, so purchases and registrations are queued offline in an encrypted SQLCipher database whose key never leaves the device, then synced with the same idempotency keys. Operations that must be checked against the current balance, like redemptions and coupons, stay online-only on purpose.



Security and authorization
Loyalty data looks harmless until you consider that it's a list of a business's customers with their phone numbers and purchase history. The security work was planned as part of the architecture from the start:
- Opaque tokens everywhere. Pass barcodes carry random scan tokens. Card and install links use random tokens that are looked up by SHA-256 hash and stored encrypted with AES-GCM.
- Per-pass credentials. Each Apple pass has its own authentication token for the PassKit web service, compared in constant time.
- API keys for external integrations are hashed with HMAC and bound to a single tenant.
- Shared-counter PIN sessions for staff use scrypt-hashed PINs, lockout, and short lifetimes.
- Rate limiting on sensitive endpoints, with identifiers hashed before they reach Redis.
- Evidence you can't edit. Consent and program-terms records are append-only, enforced by database triggers, and business actions are written to an audit log.
- Privacy in monitoring. Error reports pass through a scrubber that removes personal data before they leave the server.
The platform also went through a structured internal security audit. Every critical finding was fixed, and the remaining items are tracked with owners.

Delivery
PerkPass runs on Vercel with PostgreSQL. Sandbox and production are separate environments with their own schemas. Subscription billing goes through Wasabi Admin's fiscal API, so every paid plan produces a valid Honduran invoice without PerkPass implementing invoicing itself.
The staff app is published on the App Store and Google Play, and the platform is in production with its first business customer.
Stack
Next.js · React · TypeScript · PostgreSQL · Supabase Auth · Expo / React Native · PassKit & APNs · Google Wallet API · Upstash Redis · Vercel