Skip to content

DDD Context Map: Bounded Contexts and Integration Patterns, with a Diagram

What a DDD context map shows: bounded contexts, upstream and downstream teams, the nine patterns from partnership to anticorruption layer, and an online store example.

· Founder & developer

Published

Context map of eight bounded contexts as ellipses: Catalog, a payment provider and a legacy ERP on top; Inventory, Ordering and Invoicing in the middle; Shipping and an unconnected support desk below. Red ACL boxes sit above Ordering and Invoicing; a purple shared kernel links them.

Ask three teams in an online store what a "product" is and you get three answers. To the catalog team it is a description with photos and variants, to ordering it is a line item with a price frozen at checkout, and to shipping it is a parcel with a weight. Force all three into one shared Product class and nobody can change it without a meeting.

Domain-driven design (DDD) splits such a system into bounded contexts, each with its own consistent model, and the context map shows how those contexts relate. This post covers the vocabulary from Eric Evans's DDD Reference, the nine relationship patterns, a text notation you can keep in a repository, and a context map for an online store you can copy.

What a context map shows

The DDD Reference (2015, a Creative Commons summary of Evans's 2004 book) gives the context map a clear job: name each model in play and its bounded context, then describe the points of contact between them, including any translation, any sharing and who has influence over whom. Map the existing terrain first; plan changes later.

A context map answers questions that component and deployment diagrams leave open:

  • Which team owns which model, and where does each model stop applying?
  • Who is upstream: whose changes can break whom?
  • How does data cross each boundary: shared code, a published API, a translation layer, or not at all?

It is not a runtime view. One context can run as several services, and a modular monolith can hold several contexts as modules. For that view, use a C4 diagram or a microservices diagram.

Bounded contexts: one model, one language

The Reference defines a bounded context as a boundary, typically a subsystem or the work of one team, within which a particular model is defined and applies. Inside it, a term means the same thing in code, conversation and diagrams. Martin Fowler's Bounded Context article describes a utility where "meter" meant different things in different departments.

Term Catalog Ordering Shipping
Product Title, photos, attributes, variants SKU and price captured at checkout Weight, dimensions, hazmat flag
Customer Not modeled Buyer with a billing address Recipient with a delivery address
Price List price and promotions Amount charged, with tax Not modeled

Evans says to set boundaries explicitly: by team organization, by usage within the application, and in code bases and database schemas. He also warns that a model worked on by many people tends to fragment, and prescribes continuous integration inside each context; in practice, each context usually belongs to one team.

Upstream, downstream and team relationships

Most connections on a context map have a direction of influence. The Reference uses a river: when two cities share one, the upstream city's pollution affects the downstream city, not the reverse. Upstream changes affect the downstream team's success; downstream changes barely affect the upstream.

The Reference names three team relationships behind the patterns:

Relationship Meaning Patterns that usually go with it
Mutually dependent Both contexts must be delivered for either to succeed Partnership, shared kernel
Upstream/downstream Upstream can succeed whatever happens downstream Customer/supplier, conformist, anticorruption layer, open-host service
Free Other contexts have little effect on delivery Separate ways

Arrows usually point downstream, as in Context Mapper's [U]->[D] notation: the direction in which the model and its changes flow. Code dependencies run the other way, because downstream code calls or consumes the upstream.

The nine context mapping patterns

Pattern Side What it means In Context Mapper
Partnership Both The teams plan and integrate together, and succeed or fail together [P]<->[P]
Shared kernel Both A small, explicitly bounded part of the model and code that both teams own [SK]<->[SK]
Customer/supplier Both Downstream priorities factor into upstream planning [S]->[C]
Conformist Downstream The downstream adopts the upstream model as it is CF
Anticorruption layer Downstream The downstream translates the upstream model into its own ACL
Open-host service Upstream One protocol, open to every client OHS
Published language Upstream A documented format for exchanging data PL
Separate ways Neither No integration at all No relationship
Big ball of mud Either An area with mixed models and no clear boundaries No keyword; note it in a comment

The Reference marks partnership and big ball of mud as added since the 2004 book. The DDD Crew context mapping cheat sheet lists the same nine.

Cooperative patterns: partnership, shared kernel, customer/supplier

These patterns need two teams that talk to each other.

  • Partnership. Where failure in either context means failure for both, plan together, evolve interfaces jointly and ship interdependent features in the same release. In the example, Ordering and Inventory ship stock reservation together: checkout without a reservation oversells, and a reservation API nobody calls is worthless.
  • Shared kernel. Both teams share a subset of the model with its code or database design, and neither changes it without the other. The Reference says to keep it small. In the example, value objects such as Money and TaxRate fit; an Order entity does not.
  • Customer/supplier. The downstream team plays customer, and its needs are budgeted into upstream planning. The Reference suggests joint automated acceptance tests in the upstream team's continuous integration, so the upstream can change without breaking the downstream; consumer-driven contract tests are one way to build them.

When upstream will not change: conformist or anticorruption layer

When the upstream has no reason to accommodate you, as with a vendor, a busy platform team or a legacy system, the downstream team picks one of two patterns.

Conformist Anticorruption layer
What you do Use the upstream model as your own Translate it into your model at the boundary
Cost Almost nothing up front A layer to build, test, run and monitor
Risk Upstream concepts and changes leak into your code Translation bugs, and latency if it runs as a separate service
Fits when The upstream model is good enough, or your context is not core The upstream is a legacy or foreign model and your context is core

The Reference admits that conforming cramps the downstream design, but it greatly simplifies integration. An anticorruption layer is an isolating layer that talks to the other system through its existing interface and translates in one or both directions. Microsoft's Anti-Corruption Layer pattern lists the costs: added latency, another component to scale and monitor, and deciding whether to retire it after a migration. In code, an ACL is usually an adapter behind a port, the driven side of hexagonal architecture; in a migration, it lets new code run beside the old system, as in the strangler fig pattern.

Open-host service and published language

A translator per client stops scaling once many contexts integrate with yours. The Reference's open-host service defines one protocol that gives access to your subsystem as a set of services, open to everyone and extended for new needs; a team with unusual needs gets a one-off translator, so the shared protocol stays simple. The provider is upstream; some clients conform to it and some build anticorruption layers.

A published language is a well-documented format for exchanging data, often the one on that protocol, so that neither side's internal model becomes the shared format and freezes. Industries publish data interchange standards; teams publish OpenAPI descriptions, JSON Schemas or Avro schemas. In the example, Catalog publishes a versioned product schema. Ordering, although core, conforms to it: it adopts the published product schema, not Catalog's internal model. Ordering in turn publishes an OrderPlaced event that Shipping consumes, as in an event-driven architecture; the transactional outbox pattern publishes such events reliably.

Separate ways and the big ball of mud

Separate ways is a decision not to integrate: integration is always expensive, says the Reference, and sometimes the benefit is small. In the example, the support desk runs on an off-the-shelf help desk product with no link to orders; agents look orders up in the admin app. Draw it anyway, because an unconnected context is a decision too.

Big ball of mud, from Brian Foote and Joseph Yoder's paper, marks a part of the system where models are mixed and boundaries are inconsistent. The Reference says to draw a boundary around the mess, skip sophisticated modeling inside it, and watch for it spreading. Conforming to such a model is rarely practical, so connections to it usually go through an anticorruption layer.

Writing the map down as code

Context Mapper describes context maps in a text language, CML, so the map can live in the repository and be reviewed like code. This is the map from the diagram below:

ContextMap OnlineStore {
  type = SYSTEM_LANDSCAPE
  state = AS_IS
  contains Catalog, Ordering, Inventory, Shipping, Invoicing
  contains PaymentProvider, LegacyERP, SupportDesk

  Catalog [U,OHS,PL]->[D,CF] Ordering
  PaymentProvider [U,OHS]->[D,ACL] Ordering
  Ordering [P]<->[P] Inventory
  Ordering [SK]<->[SK] Invoicing
  Ordering [U,S,PL]->[D,C] Shipping
  LegacyERP [U]->[D,ACL] Invoicing
}

BoundedContext Catalog
BoundedContext Ordering
BoundedContext Inventory
BoundedContext Shipping
BoundedContext Invoicing
BoundedContext PaymentProvider
BoundedContext LegacyERP // big ball of mud (CML has no keyword for it)
BoundedContext SupportDesk

Upstream roles are OHS and PL, downstream roles CF and ACL, and customer/supplier adds S and C. The support desk has no relationship, which is how separate ways looks in text. A second .cml file with state = TO_BE describes the target (CML allows one context map per file).

The DDD context map diagram

Context map of eight bounded contexts as ellipses: Catalog, a payment provider and a legacy ERP on top; Inventory, Ordering and Invoicing in the middle; Shipping and an unconnected support desk below. Red ACL boxes sit above Ordering and Invoicing; a purple shared kernel links them.

14 components · 9 connections

Open in Archboard
Diagram contents
  • Catalog
  • Payment provider external
  • Legacy ERP big ball of mud
  • Payment ACL
  • ERP ACL
  • Inventory
  • Ordering core domain
  • Shared kernel Money, TaxRate
  • Invoicing
  • Shipping
  • Support desk separate ways
  • [U,OHS,PL] → [D,CF]
  • [U,OHS] → [D,ACL]
  • [U] → [D,ACL]
  • [P] ↔ [P]
  • [SK]
  • [U,S,PL] → [D,C]
A context map for an online store. Ordering, the core domain, conforms to Catalog's open-host service, reaches the payment provider through an anticorruption layer, works in partnership with Inventory, shares a kernel with Invoicing and supplies Shipping.

How to read it:

  • Top row, upstream: Catalog, an external payment provider (dashed) and the legacy ERP, a big ball of mud. Every arrow points downstream.
  • Middle row: Ordering, the core domain in amber, in a partnership with Inventory and sharing a kernel (Money, TaxRate) with Invoicing.
  • Red boxes: anticorruption layers owned by the downstream side, one for the payment API and one for ERP records.
  • Bottom row: Shipping, a customer of Ordering that consumes the OrderPlaced event, and the support desk, with no connection at all.
  • Edge labels and legend: Context Mapper roles, as in the CML above, explained in the Markdown block on the right.

Drawing DDD context maps clearly

  • Upstream on top. The river then reads from top to bottom, with every arrow pointing downstream.
  • Label every relationship. A bare line only says two contexts talk; write U, D and the pattern on each side.
  • Draw translation where it lives. An ACL belongs to the downstream context, so put it on that side.
  • Mark the core domain in its own color, and give systems you do not control a dashed outline.
  • Map today first. Draw the as-is map, mud included, before the to-be map.
  • Stay at context level. Services, queues and databases belong in other diagrams, such as C4 container and component views.

Common mistakes are one ellipse per microservice instead of one per model, a shared kernel that grows into a shared database, a conformist relationship nobody chose, and a "partnership" with no joint planning. For the runtime view of a similar store, see the e-commerce architecture diagram.

Build it in Archboard

  1. Sign in with Google or GitHub and create a diagram.
  2. From the Core pack, add eight Ellipse shapes: Catalog, Payment provider and Legacy ERP on top; Inventory, Ordering and Invoicing in the middle; Shipping and Support desk below.
  3. Color Ordering amber and Catalog, Inventory, Invoicing and Shipping blue. Give the payment provider a dashed gray border, the ERP a brown fill with a dashed border and the support desk a light gray fill with a dotted border.
  4. Add three Rounded Rectangle shapes: two red anticorruption layers above Ordering and Invoicing, and a purple shared kernel between them.
  5. Draw arrows downstream and label them with roles, such as [U,OHS,PL] → [D,CF] from Catalog to Ordering. Use a plain line for the partnership and dashed purple lines for the shared kernel; leave the support desk unconnected.
  6. Add a Markdown block from the Core pack for the legend, and two Text notes for the arrow direction and the separate ways decision.

If your contexts already live in a Mermaid flowchart, the Mermaid converter turns it into a first draft. The example uses 12 diagram nodes, within the Free plan's limit of 15 per diagram.

FAQ

What is a context map in DDD? A diagram or document that names every bounded context and describes how connected contexts relate: which side is upstream, and which pattern governs the integration.

What is the difference between a bounded context and a subdomain? A subdomain is part of the business problem, such as payments. A bounded context is part of the solution: the boundary within which one model applies. They often line up, but they do not have to.

Is a bounded context the same as a microservice? No. A bounded context is a model boundary; a microservice is a unit of deployment. One context can run as several services, and a modular monolith can hold several contexts.

When should I use an anticorruption layer instead of conforming? When the upstream model is weak, legacy or foreign to your domain and your context matters to the business. Conform when the upstream model is good enough and translating would cost more than it saves.

What do U and D mean on a context map? Upstream and downstream. Upstream changes affect the downstream team, not the other way round. Roles such as OHS, PL, CF and ACL say how each side handles the integration.

Start free — one seat, no credit card.

Related posts

← Back to blog

Open a canvas in a minute

Sign in with Google or GitHub. Free for a single seat. Upgrade when the team joins.