HOME/BLOG/Case Study
Case Study

Case Study: High-Throughput D2C Architecture and Packaging QR Retention System

WRITTEN BYRetro Paradox Engineering
ID Also available in IndonesianBaca Versi Indonesia →

1. Business Context and Distribution Profile

This national direct-to-consumer (D2C) skincare and body care brand distributes over 450,000 physical units monthly across Indonesia. Daily sales volume ranges between 3,000 and 6,000 orders distributed across third-party marketplaces such as Shopee and TikTok Shop, as well as authorized offline distributor networks.

Despite high transaction volumes, the operating model suffered from a structural weakness. Nearly 100% of customer identity and order history remained locked inside third-party marketplace platforms. The brand lacked direct access to customer contact details or purchase cycles, preventing direct retention campaigns, educational follow-ups, and automated repeat order initiatives.

2. Core Problem Analysis

Three primary bottlenecks restricted brand profitability and operational efficiency:

  • Third-Party Customer Data Lock-in: Marketplace data masking policies prevented the brand from building an owned customer asset. Launching new product lines required spending on paid advertising from scratch to reach existing buyers.
  • Infrastructure Bottlenecks During Campaign Spikes: During promotional double-date campaigns and flash sales, traffic surged to over 30,000 checkouts per day. Conventional monolithic CMS platforms experienced database connection pool exhaustion and frequent downtime.
  • Physical Code Validation Complexity: The brand required placing unique, non-duplicable verification codes on hundreds of thousands of physical packages monthly. These codes needed instant mobile validation during customer unboxing while remaining immune to automated brute-force attacks.

3. Technical Architecture Design

To solve these constraints, the engineering team architected a decentralized stack decoupling the frontend presentation layer, cryptographic validation backend, and automated retention pipeline.

A. Headless Storefront on Edge Runtime

The consumer-facing web portal was built using Next.js deployed on Edge Runtime. Product catalog pages render incrementally with response latencies under 65 milliseconds. Dynamic traffic surges are handled via auto-scaling serverless functions capable of sustaining 10,000 requests per second.

B. 128-bit Cryptographic QR Engine

Each physical product is printed with a QR label containing a 128-bit randomized string generated via high-entropy Nanoid cryptography.

When a customer scans the QR code at home:

  1. The request hits an API Gateway protected by Cloudflare WAF and IP-based rate limiting to filter automated scanners.
  2. Token validity is verified through atomic PostgreSQL transaction locks.
  3. If valid, the database updates the token status to consumed in a single atomic query execution, issues the voucher credit, and permanently locks the token against replay attempts.

C. Automated Customer Retention Pipeline

When the customer enters their WhatsApp contact number to activate product warranty or claim discounts, a serverless webhook captures the record into an encrypted CRM database. This triggers automated, scheduled customer engagement sequences:

  • Day 3: Usage instructions and skincare tips.
  • Day 14: Mid-cycle product satisfaction check.
  • Day 30: Timed reorder notification before the product runs out.

4. Critical Edge Case Handling and Security

  • Race Condition Mitigation: To prevent concurrent duplicate scans of identical codes, the database applies Serializable transaction isolation levels on all token validation queries.
  • Brute-Force Defense: The validation endpoint enforces a threshold of 5 failed attempts per IP per minute. Systematic enumeration attacks are blocked at the Cloudflare edge layer before reaching database resources.
  • Webhook Delivery Reliability: Outbound messaging workflows utilize Redis message queues to buffer delivery spikes without data loss during peak promotional periods.

5. Financial Impact and Operational Results

  • System Throughput: The validation pipeline verified throughput handling up to 275,000 QR token validations per second in peak stress tests.
  • First-Party Data Acquisition: The brand converted an average of 38% of anonymous marketplace buyers into verified direct customer profiles.
  • Infrastructure Cost Optimization: Migrating from dedicated hosting instances to direct-billing serverless architecture significantly decreased ongoing hosting overhead by charging purely on active compute time.

6. Tech Stack Specifications

  • Frontend Layer: Next.js Edge Runtime, Tailwind CSS
  • Data and Storage Layer: Supabase PostgreSQL, Cloudflare R2
  • Security and Caching: Cloudflare WAF, Upstash Redis
  • Payment and Logistics APIs: Midtrans Gateway, Biteship Logistics API
  • Messaging Worker: Official Meta WhatsApp Cloud API Worker
GOOGLE SEARCH PREFERENCE

Jadikan retpara.com Sumber Pilihan di Google

Dapatkan prioritas konten di Google Search, Top Stories, dan AI Overviews.

RP

Retro Paradox Engineering

Verified Specialist

AI Automation, WhatsApp Cloud API & Healthcare Operations

Authored and reviewed by Retro Paradox engineering specialists based on empirical enterprise workflow deployments and PostgreSQL n8n orchestration.