DEV Community

Cover image for Day 4: Subscription Box Service - AI System Design in Seconds
Matt Frank
Matt Frank

Posted on

Day 4: Subscription Box Service - AI System Design in Seconds

Subscription services are everywhere, but building one that reliably handles millions of monthly charges, skip requests, and payment failures is genuinely complex. Getting the architecture right upfront means fewer refunds, less manual intervention, and happier customers. Today we're exploring a subscription box service that demonstrates how distributed systems handle recurring billing at scale.

Architecture Overview

A subscription box service needs several core layers working in harmony. At the top, you have the customer-facing application where users manage their subscriptions, customize box contents, and skip upcoming months. This connects to a subscription management service that tracks active subscriptions, handles upgrades and downgrades, and maintains the state of each customer's plan. Behind the scenes, a billing engine orchestrates recurring charges on a schedule, while a payment processor integration communicates with external payment providers like Stripe or Square.

The data layer is equally important. A relational database stores subscription metadata, customer preferences, and billing history, while a separate ledger or event log captures every transaction for audit purposes. You'll also need a notification service to send confirmation emails, shipment updates, and payment failure alerts. A fulfillment service ties into your warehouse systems to ensure boxes are packed and shipped only for active, non-skipped months.

One critical design decision is separating concerns: the subscription service doesn't directly charge cards. Instead, it publishes events to a message queue whenever a billing date arrives. The billing engine consumes these events, retries failed charges intelligently, and publishes outcomes back to the system. This decoupling prevents cascading failures and makes the system resilient.

Design Insight: Handling Failed Recurring Payments

Failed payments are inevitable, and how you handle them separates good services from great ones. When a charge fails, the system doesn't just give up. Instead, it enters a retry strategy, typically attempting the charge again after 3-5 days, then once more a week later. During this window, the customer receives notifications explaining the issue and prompting them to update their payment method.

If all retries fail, the subscription moves into a suspended state rather than being cancelled outright. This preserves the customer relationship and allows them to recover without losing their entire account. A dunning workflow kicks in, sending escalating emails and potentially offering alternative payment methods or a grace period. Meanwhile, the fulfillment service is notified not to ship for this cycle. Only after 30 days of failed attempts and unanswered notifications does the system automatically cancel the subscription. This approach reduces involuntary churn and gives customers multiple chances to resolve issues.

Watch the Full Design Process

See how InfraSketch generates this architecture in real-time:

Try It Yourself

Ready to design your own subscription system? Head over to InfraSketch and describe your system in plain English. In seconds, you'll have a professional architecture diagram, complete with a design document.

Top comments (0)