Case study 02 · Tokopedia
TokoPoints: architecture for Tokopedia’s loyalty program
Designed the architecture of TokoPoints, Tokopedia’s gamified loyalty points, and developed it in a team of five: a ledger that credits each order once and handles up to 20,000 requests per second during events.
The challenge
Points that behave like money, at Tokopedia’s scale
TokoPoints turned shopping on Tokopedia into a game, with the goal of growing the user base. Buyers earned points on every transaction and at special events, spent them on Tokopedia, and points expired after a while.
Loyalty points look simple from the outside, but they behave like a currency: buyers earn them, spend them and expect the balance to be right every time. They also had to work with the promo system that already existed.
A balance that is wrong once is enough for a buyer to stop trusting the program.
- 01Correctness. No double credits, no lost points, and a clear history for every change.
- 02Scale. Events drove traffic up to 20,000 requests per second.
- 03Integration. Points had to work alongside Tokopedia’s promo system.
My role
Designing it, then building it
As a Software Engineer in a team of five, I designed the architecture of TokoPoints and developed it.
- 01Architecture. Designed how points are earned, credited, recorded, spent and expired, around a ledger keyed by order ID.
- 02Development. Built it in Go on PostgreSQL, with NSQ as the message queue and Datadog for monitoring.
- 03Integration. Connected TokoPoints with the promo system.
Approach
How we built it
1. Earn, spend, expire
Buyers earned points on every transaction and from certain events. They could spend points on Tokopedia, and points expired.
2. Credit at the end
Points were always credited at the end of the flow, never up front.
3. A ledger, not just a balance
Every change went into a ledger history. Each entry carried a unique ID, the order ID, so the same order could never be credited twice.
4. Ready for event peaks
During events, traffic reached 20,000 requests per second. The service ran on Go and PostgreSQL, with NSQ as the message queue and Datadog for monitoring.
Outcome
What changed
Because points were credited at the end and every entry was keyed by order ID, an order could only be credited once, and every change to a balance could be traced in the ledger, including at event peaks.