Backend Development 10 min read

Technical Architecture of an E‑commerce Coupon System

This article explains the complete technical design of an e‑commerce coupon system, covering data models, product‑page exposure, coupon claiming rules, high‑concurrency caching, MQ‑driven expiration handling, order‑time coupon calculation, redemption flow, and search‑based coupon indexing.

Full-Stack Internet Architecture
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Technical Architecture of an E‑commerce Coupon System

Many websites offer coupons, but few discuss the underlying technical architecture. Although coupons appear simple, they involve users, products, platforms, and stores, leading to complex marketing scenarios. This article explores how to design a robust coupon system.

Coupon Information Overview – A mind map (image) outlines the essential fields of a coupon, such as validity period, applicable products, and user restrictions.

Product Detail Page Display – Coupons are shown on product pages alongside images, titles, SKU, price, etc. The system retrieves coupons by reverse‑looking up the product ID, ignoring user login status, and validates eligibility when the user clicks “Claim”. High traffic is handled by pre‑warming a dedicated coupon cache (the “Coupon Sync Center”) so that page loads hit the cache instead of the database.

When a coupon expires, a stream‑filter checks its validity and an MQ message triggers cache cleanup to keep data consistent.

Coupon Claiming Process – Claiming involves template validation (time window, stock, daily limits), user‑record checks, and user‑tag verification (new users, level, blacklist, custom tags). The flowchart (image) illustrates these steps.

Technical Challenges

Integrating high‑throughput risk control.

Designing a two‑layer cache for coupon templates and volatile stock, while ensuring consistency with the database.

Caching claim records.

Applying strategy‑pattern user‑tag checks via external services.

Order‑Page Coupon Calculation – When an order is placed, the backend filters the user’s coupons by channel, product scope, and order amount. Various product scopes (single SKU, category, brand, tag, region, etc.) and order‑level conditions are considered. The filtering logic is illustrated with diagrams.

Coupon Redemption – The redemption flow (image) shows how a coupon is marked as used after successful payment.

Additional Features – Coupons can have dedicated detail pages with recommendation, hot‑sale, and price sorting. After creating a coupon template, data is synchronized to Elasticsearch for fast search. The Elasticsearch mapping is shown below:

{
  "properties" : {
    "couponId" : { "type" : "long" },
    "itemId" : { "type" : "long" },
    "sort" : { "type" : "long" },
    "salesCount" : { "type" : "long" },
    "salePrice" : { "type" : "long" },
    "gmtCreated" : { "type" : "date", "format" : "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis" },
    "gmtModified" : { "type" : "date", "format" : "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis" }
  }
}

User coupon wallets are retrieved with simple pagination and filtered by unused status; region‑based e‑commerce may gray‑out unavailable coupons.

BackendE-commerceMicroservicesElasticsearchcachingMessage Queuecoupon
Full-Stack Internet Architecture
Written by

Full-Stack Internet Architecture

Introducing full-stack Internet architecture technologies centered on Java

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.