Santekno
Projects/MVC Discount — Seller Discount Coupons
Tokopedia logoPart of Tokopedia · Senior Software Engineer, Promotion Team
Backend / APILive

MVC Discount — Seller Discount Coupons

Backend for seller-created discount coupons at shop and product level on the merchant voucher platform, reusing an existing multi-coupon-type database design and validated for compatibility in two sprints.

2023-mvc-discount · main
# E-Commerce / Promotions
$ go -X POST /2023-mvc-discount/v1/sync
→ 201 Created
{ "status": "ok" }
publish 2023-mvc-discount.synced
Role
Backend Engineer (Lead / POC)
Timeline
2023
Team
3
Domain
E-Commerce / Promotions
Stack
8 tech
Status
Live
01

Overview

The MVC Discount project — internally known as "Discount Coupon" — added seller-created discount coupons to the merchant voucher platform. As lead / POC, I designed and delivered the backend with junior engineers I led, letting sellers create discount coupons at both shop and product level, with percentage or nominal benefits, and released it in 2023.

A backend has no screens, so its "UI" is the operational surface: the coupon-creation API, the seller-dashboard flow, and release dashboards.

API contract — discount coupon creation at shop & product level
Ops view — seller dashboard integration and coupon management
Grafana — release health and adoption signals
03

Problem & Solution

Problem

The merchant voucher platform already offered several coupon types, but sellers had no first-class way to create their own discount coupons scoped to a whole shop or to specific products. Building a parallel system would have duplicated a lot of the existing model and validation logic, so the challenge was to extend the platform in place while proving that older coupon types kept working.

Solution

I wrote the technical design (TRD), the interaction flow, and the database storage plan for the seller-dashboard side, then reused the existing multi-coupon-type schema to avoid schema drift. On top of that I added new API contracts for shop- and product-level discount coupons, extended enums for benefit types (percentage and nominal), and integrated with the seller dashboard so sellers could manage the coupons end-to-end. Two sprints were spent on compatibility testing before release.

04

Workflow

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

flowchart diagram

create coupon

create discount coupon

persist

publish

list & manage

Seller

Seller Console

Merchant Voucher Service

Managed RDS

Redis Cache

Use case interaction
sequence diagram
Redis CacheManaged RDSMerchant Voucher ServiceSeller ConsoleRedis CacheManaged RDSMerchant Voucher ServiceSeller Consolecreate discount coupon (shop or product level)validate scope, benefit type, and amountsinsert into multi-coupon-type tablewarm coupon lookup cachecoupon created (id, status)
Discount coupon creation flow
05

Architecture

flowchart diagram

rpc

metrics

Seller Console

Merchant Voucher Service

Managed RDS

Redis Cache

Promotion Aggregator Service

Prometheus / Grafana

System architecture
Architecture notes

The merchant voucher service exposes RPC and HTTP endpoints for coupon creation, listing, and lifecycle changes, persists into a managed RDS with the shared multi-coupon-type schema, and warms a Redis cache for hot coupon lookups. A promotion aggregator service reads active coupons for consumer-facing surfaces, and Prometheus/Grafana provide release-health and adoption signals.

state diagram

seller publishes

seller pauses

seller resumes

end date reached

draft

active

paused

expired

Discount coupon lifecycle
06

Features

Seller
  • Create a discount coupon at shop level
  • Create a discount coupon at product level
  • Combine benefit types (percentage or nominal discount)
Operations
  • Seller dashboard integration for coupon management
  • Compatibility testing across existing coupon types
System
  • Reused an existing multi-coupon-type database design
  • New API contracts for shop- and product-level coupons
  • Backwards-compatible enum extensions for benefit types
07

Tech Stack

language
Go
framework
RPC framework
protocol
RPCHTTP
database
Managed RDS (relational database)
cache
Redis
observability
PrometheusGrafana
08

Engineering Challenges

01
Reusing a multi-coupon-type schema without regressions

The merchant voucher platform already supported several coupon types on a shared schema, so a naive extension could break existing flows. Fix: I mapped the new shop- and product-level discount coupons onto the existing model and spent two sprints on structured compatibility testing to keep older coupon types safe.

02
Leading junior engineers through end-to-end delivery

As lead / POC, I had to design the tech, then split the work among junior engineers I led while keeping the design coherent. Fix: I owned the TRD and interaction/DB design up front, then reviewed and paired on the trickier compatibility and dashboard-integration slices so the team could ship confidently.

03
Supporting two coupon scopes and multiple benefit shapes

Shop-level and product-level coupons had different validation and dashboard needs, and each had to work with both percentage and nominal benefits. Fix: I unified the create/validate path behind a single API contract with scope- and benefit-aware validation, so both levels shared one lifecycle and one operational surface.

09

Outcomes

2
sprints to release
2 levels
shop & product coupons
high
seller adoption & positive impact
10

Lessons Learned

Reusing an existing schema is cheap only if you invest in compatibility testing — the two sprints spent on it were the reason release day was uneventful. Leading junior engineers also worked best when I owned the design and the risky slices explicitly, and left well-scoped implementation slices for the team to grow on.

Interested in working together?

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