CASE STUDY

Coupon Distribution System

310 words·Advanced

How to use this case study

SDE-2 / Mid

Study the full Coupon Distribution System case study. Focus on understanding the core components and how they interact. Focus on sections 1-3: requirements, API design, and high-level architecture. Understand how unique code generation works and how redemption validation works in real-time.

SDE-3 / Senior

Study the full Coupon Distribution System case study. Focus on understanding the core components and how they interact. Be ready to discuss the campaign engine design, how to prevent coupon fraud, and the trade-offs between SQL vs NoSQL for coupon storage. Know how to scale redemption to 5K req/sec.

Staff / Principal

Study the full Coupon Distribution System case study. Focus on understanding the core components and how they interact. Be prepared to discuss the event-driven architecture for coupon lifecycle tracking, CRM integration patterns, and how to design the analytics pipeline for ROI measurement. Discuss consistency guarantees for distributed coupon issuance.

# Coupon Distribution System


0) Problem Restatement

Design a highly scalable system that can generate and distribute unique, trackable coupons to millions of users. The solution must support personalization, real-time redemption validation, lifecycle tracking, and seamless integration with a CRM for targeted campaigns and analytics.


1) Requirements

1.1 Functional

  • Generate coupons: Unique codes per user, tied to specific campaigns.
  • Track metadata: Expiry, discount type/value, usage limits.
  • Support types: One-time and multi-use coupons.
  • Real-time validation: Validate and apply coupons at checkout in under 100ms.
  • CRM Integration: Targeted audience segmentation and campaign triggers.
  • Event tracking: Emit events for issued, delivered, redeemed, and expired coupons.

1.2 Non-Functional

  • High Scalability: Support millions of users and thousands of redemptions per second.
  • High Availability: ≥ 99.9% uptime.
  • Security: Prevent tampering, brute-force, and replay attacks.
  • Auditability: Complete audit trails for ROI and fraud detection.

1.3 Scale Estimates

  • Users: 100 million.
  • Campaigns: 10,000 active campaigns.
  • Redemptions: 5,000 requests/sec peak.
  • Storage: Highly compressed coupon records for historical tracking (billions of rows).

1.4 API Design

The core APIs required for the service:

  • Get Coupons: GET /v1/coupons - Fetch active coupons for a user.
  • Generate Coupon: POST /v1/campaigns/:id/issue - Issue a new coupon for a user.
  • Redeem Coupon: POST /v1/coupons/redeem - Validate and apply a coupon.
  • Track Event: POST /v1/events - Log coupon usage events.


2) High-Level Architecture

2.1 Overview

  • Campaign Engine: Orchestrates user selection and issuance rules.
  • Coupon Generator: Creates unique codes and persists metadata.
  • Redemption API: Validates and tracks coupon state in real-time.
  • Analytics: Aggregates usage events for ROI and fraud detection.

2.2 Architecture Diagram

```mermaid


config:

layout: elk


flowchart LR

U[\

More Case Studies

Practice with a Mock Interview

Apply what you learned in a live system design mock interview with our AI interviewer.

Start System Design Interview →