Santekno
Projects/MVC Simplify Revamp — Streamlined Coupon Creation
Tokopedia logoPart of Tokopedia · Software Engineer, Shop Team
Backend / APILive

MVC Simplify Revamp — Streamlined Coupon Creation

Revamped a merchant coupon-creation platform end-to-end — shop-tier feature capability, recurring coupon creation, and discount support — with a go-routine batch pipeline that creates up to 12 coupons in under one second, aligned with five cross-functional teams and released in October 2022.

2022-mvc-simplify-revamp · main
# E-Commerce / Promotion & Discounts
$ go -X POST /2022-mvc-simplify-revamp/v1/sync
→ 201 Created
{ "status": "ok" }
publish 2022-mvc-simplify-revamp.synced
Role
Senior Backend Engineer
Timeline
2022
Team
5
Domain
E-Commerce / Promotion & Discounts
Stack
9 tech
Status
Live
01

Overview

The MVC Simplify Revamp project rebuilt the merchant coupon-creation platform to make it faster to use and cheaper to extend. As Senior Backend Engineer with a team of about five — including junior engineers and an intern — I owned the end-to-end tech design, DB storage, batch pipeline, and cross-team coordination, and shipped new capabilities for shop-tier, recurring coupon creation, and discount support for a release in October 2022.

A backend has no screens, so its "UI" is the operational surface: the batch coupon-creation API contract, the shop-tier and recurring-coupon configuration flow, and coupon-throughput dashboards.

API contract — batch coupon creation & quota resolution
Ops view — shop-tier & recurring coupon configuration
Grafana — batch latency & coupon-creation throughput
03

Problem & Solution

Problem

The existing coupon-creation endpoint took roughly one second to create just one coupon, which made bulk workflows painful for sellers and blocked the roadmap for recurring coupons and tier-based quotas. On top of the latency ceiling, the revamp had to introduce a coherent shop-tier feature, a recurring-creation flow, and discount support — while aligning promotion, catalog, discount, seller-console, and a downstream platform team on interface contracts.

Solution

I designed and led the revamp end-to-end: the interaction flow, DB storage, and the data surfaced on the seller dashboard, plus a quota calculation model that combines shop tier, per-month allowance, and custom shop quotas. The core latency win came from go-routine parallelization — the batch handler fans out per-coupon inserts, shares a single tier/quota resolution from Redis, and returns the aggregated result — bringing 12-coupon batch latency below 1s versus ~1s for a single coupon on the old path. I coordinated with five cross-functional teams, kept the timeline, testing, and monitoring on track, and guided junior engineers and an intern through the build to the October 2022 release.

04

Workflow

Three actors interact with the service; the diagrams are written in English to stay consistent across both languages.

flowchart diagram

open coupon creation

batch create up to 12 coupons

resolve shop tier & quota

fan-out via go-routines

persist coupons

metrics

Seller

Seller Console

Merchant Promotion Service

Shop Tier & Quota Resolver

Go-routine Workers

Managed RDS

Prometheus / Grafana

Use case interaction
sequence diagram
Managed RDSShop Tier & Quota ResolverMerchant Promotion ServiceSeller ConsoleSellerManaged RDSShop Tier & Quota ResolverMerchant Promotion ServiceSeller ConsoleSellerpar[per-coupon persist]request batch of 12 couponscreate-batch-coupons (12 items)resolve shop tier & monthly quotatier + remaining quotafan-out 12 go-routinesinsert couponackbatch result (under 1s)12 coupons created
Sequence flow — batch coupon creation under 1s
05

Architecture

flowchart diagram

cache

rpc

rpc

metrics

Seller Console

Merchant Promotion Service · Go

Shop Tier & Quota Resolver · Go

Coupon & Quota Tables

Shop Tier Table

Redis · tier/quota

Catalog Service

Discount Service

Prometheus / Grafana

System architecture
Architecture notes

The merchant-promotion service owns coupon creation and delegates tier and quota resolution to a shop-tier & quota resolver backed by a Managed RDS, with Redis caching hot tier/quota reads. On a batch request, the service fans out go-routines — one per coupon — and each writes to the coupon tables independently; per-coupon failures do not block the rest of the batch. Recurring coupon schedules and discount metadata are modeled as first-class relations, so shop-tier changes and recurring jobs stay consistent with the seller console. Prometheus and Grafana track batch latency and coupon-creation throughput.

state diagram

quota & tier checked

persisted via go-routines

publish window opened

buyer redeems

validity ended

draft

validated

created

active

redeemed

expired

Coupon lifecycle
06

Features

Coupon Creation
  • Shop-tier feature capability (TRD)
  • Recurring coupon creation (TRD)
  • Discount support for coupon creation
Quota & Data
  • Coupon-creation quota by shop tier and per-month
  • Custom shop quota calculation
  • Seller-dashboard data surfacing
Delivery & Ops
  • End-to-end tech design (interaction flow & DB storage)
  • Cross-functional alignment with five teams
  • Guidance for junior engineers and an intern
07

Tech Stack

language
Go
framework
RPC framework
protocol
RPCHTTP
database
Managed RDS
cache
Redis
concurrency
Go routines
observability
PrometheusGrafana
08

Engineering Challenges

01
Sub-second latency for a batch of 12 coupons

The existing endpoint already took ~1s to create a single coupon, and the revamp had to support creating up to 12 coupons in one request under 1s. Fix: fan out the per-coupon work with go-routines behind a bounded batch handler, share tier/quota lookups from Redis to avoid redundant round-trips, and treat each insert as an idempotent unit — dropping batch latency below 1s.

02
Aligning five cross-functional teams

The revamp touched seller-console, catalog, promotion, discount, and a downstream platform team simultaneously, on top of new TRDs for shop-tier and recurring creation. Fix: periodic PRD/TRD sync, clear interface contracts per boundary, and a staged rollout — landing the release for October 2022 on schedule.

03
Quota model for shop-tier, monthly, and custom shop quotas

Coupon-creation quota had to reconcile three inputs — shop tier, per-month allowance, and a custom shop quota — without conflicting or blocking recurring creation. Fix: a single quota resolver as first-class logic in the merchant-promotion service, so tier upgrades and recurring schedules stayed consistent across the seller console and the coupon lifecycle.

09

Outcomes

<1s
batch coupon-creation latency
12x
coupons per request (was 1)
Oct 2022
release milestone
10

Lessons Learned

Parallelizing the right unit of work matters more than raw concurrency: fanning out per-coupon inserts with go-routines, while sharing a single tier/quota lookup, was what pushed 12-coupon batch latency under 1s. Modeling quota as a first-class resolver — instead of scattering shop-tier, monthly, and custom-quota checks across handlers — made the follow-up work (recurring creation, discount support) far cheaper to extend. And a revamp this broad is as much about aligning five cross-functional teams and mentoring newer engineers as it is about the code.

11

Related Santekno Tutorials

Interested in working together?

Order, payment, or high-traffic event pipelines — let's talk architecture and trade-offs.