Domain-Driven Design & Bounded Contexts
Discover how Strategic Domain-Driven Design (DDD) and Bounded Contexts define clean, autonomous microservice boundaries.
The single hardest challenge in microservices is deciding where to draw the boundaries.
If you cut your services too small, you end up with "nano-services" that flood the network with latency. If you cut them incorrectly, a simple feature update requires coordinated changes across five different microservices.
The industry-standard solution for finding natural, resilient service boundaries is Domain-Driven Design (DDD), pioneered by Eric Evans.
01The Fallacy of the "Universal Data Model"
In monolithic databases, architects often attempt to build one giant User table with 80 columns:
id,email,password_hash(Auth)first_name,last_name,tax_id(Billing)shipping_street,gate_code,delivery_notes(Logistics)tier,loyalty_points,vip_status(Marketing)satisfaction_score,open_tickets_count(Support)
Whenever the Marketing team changes how loyalty points expire, they risk locking the User table, causing database connection timeouts for users trying to log in.
The DDD Revelation: Context is King
In Domain-Driven Design, there is no such thing as a single universal "User" or "Product". A concept only has meaning within a specific Bounded Context.
Notice how the concept changes:
- In the Order Context: A customer is a Buyer with credit card tokens and invoice addresses.
- In the Shipping Context: The customer is a Recipient with GPS drop-off coordinates and gate access codes.
- In the Support Context: The customer is a Caller with support tickets and satisfaction ratings.
By splitting these concepts into separate Bounded Contexts, each microservice models only what it needs, eliminating cross-team schema conflicts.
Loading the rest of the lesson…