Skip to main content

DDD: Bounded Contexts — Where Models Apply

A bounded context is the explicit boundary within which a domain model is consistent — the same word means different things across boundaries.

When to use

  • Large domain with multiple teams or subdomains
  • Preventing model pollution across services
  • Defining microservice or module boundaries

Tradeoffs

  • Context mapping adds coordination overhead at boundaries
  • Misaligned context and team boundaries cause friction
// package sales
type Customer struct {
ID string
Name string
CreditLimit float64
SalesRepID string
}

// package shipping
type Customer struct {
ID string
Name string
ShippingAddress Address
DeliveryPrefs string
}

Gotcha: A microservice boundary should align with a bounded context boundary — not the other way around.