Case study · Node/TS · Google Cloud

Shopify loyalty & store credit

RoleSoftware engineer
Year2026
StackNode/TS, Google Cloud
PlatformShopify, Recharge

An idempotent store credit ledger: every reward is credited exactly once, even when the same webhook is delivered twice.

Balto customers earn store credit when they subscribe, refer a friend or review a product, then spend it at checkout or on their next subscription box. I built the backend behind all of it: small, single-purpose services on Google Cloud.

The hard part is that Shopify and Recharge deliver webhooks at least once, so the same event can arrive twice. Every event carries an idempotency key checked against the ones already processed, so a duplicate never pays out. The ledger is append-only, and a nightly reconciliation job compares every balance with Shopify and flags any drift.

What I built

Every way a customer earns or spends credit.

01

Cashback on subscription orders, credited only once the order ships, so cancelled orders never pay out.

02

Referral links: the friend gets a one-time discount code and the referrer earns credit. Unused codes are cleaned up automatically.

03

Credit for product reviews collected through Loox.

04

Spending credit at checkout, with refunds that return credit to the customer.

05

Redeem or auto-redeem from the customer portal, applied before the next subscription charge.

06

Credit that expires on schedule, admin tools for manual adjustments, and a sync for credit issued outside the system.

How it worksSimplified
Places an orderSubscription renewsRefers a friendLeaves a reviewGets a refundCredit expiresEvent busEvery momentbecomes a messageDoor checkSeen this one?Skip it.LedgerAdded once,never editedShopify balanceSpendable atcheckoutRepeat droppedNightly: do both sides agree?Customer moments
Built on Google CloudGoogle runs the infrastructure. My code handles the rewards.
Pub/SubWhen an order comes in, every reward that cares about it hears about it.
FirestoreKeeps a full history of every credit, so a balance is always the sum of what happened.
RedisSpots an event it has already handled and skips it before any credit is paid.
Scheduler & TasksRuns the nightly balance check, expires old credit, and handles work that has to wait.
What this shows
01IdempotentEvery credit is written exactly once, even when the same event is delivered twice.
02IndependentEach reward is its own service, so one slow step never holds up the rest.
03Self-reconcilingA nightly job compares every balance with Shopify and raises an alert on any drift.
04AuditableAn append-only ledger explains any balance line by line, back to the order that earned it.