← All case studies

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.

Role
Software Engineer · architecture and development
Team
5 engineers
Timeline
As Software Engineer, 2017 – 2019
Domain
E-commerce · Loyalty
A phone showing the TokoPoints page in the Tokopedia app, with gold coin graphics and a list of TokoPoints benefits.
TokoPoints in the Tokopedia app, from Tokopedia’s 2021 relaunch of the program. Photo: Tokopedia.

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.

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.

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.

Simplified flow of how TokoPoints credits and records points.

Outcome

What changed

20k
Requests per second during events
1
Ledger entry per order, keyed by order ID
5
Engineers who designed and built it

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.