Archicise
Exercise

Design an E-Commerce Order System with DDD

Apply Domain-Driven Design principles to model an e-commerce order system, defining bounded contexts, aggregates, entities, value objects, and domain events.

Functional Requirements

  • Place orders with multiple line items
  • Apply discount rules (coupon, loyalty, bundle)
  • Process payments with multiple methods
  • Manage inventory reservation and release
  • Handle order cancellation and refunds
  • Emit events for downstream services

Design Challenges

  • Define bounded contexts and their interaction contracts
  • Prevent anemic domain model anti-pattern
  • Ensure aggregate consistency boundaries are correct

Questions to Consider

  • Which contexts own which data?
  • How does the Order context communicate with Inventory and Payment?
  • How do you prevent the Order aggregate from growing too large?
Your Solution

Bounded Context Mapping

Identify the core bounded contexts: Order, Catalog, Inventory, Payment, Notification. Draw the context map showing relationships (Customer-Supplier, Shared Kernel, Anti-Corruption Layer). Define what each context owns and what it exposes to others.