Context Mapping

Objectives: understand Context Mapping in Domain-Driven Design (DDD), learn how to identify Bounded Contexts, describe their strategic relationships, and choose the right integration pattern.


1. Benefits of Context Mapping

The benefits of Context Mapping are:

  1. Clarify boundaries between domains
  2. Make integration explicit (and safer)
  3. Align teams and communication
  4. Preserve model coherence
  5. Inform architectural decisions
  6. Reduce long-term complexity

It is a sociotechnical view: the code reflects the way teams talk, negotiate, and cooperate.


2. Scope: what we map, what we ignore

A Context Map is used to reason about semantic boundaries and power relationships between subsystems. It does not describe their internals or their infrastructure.

The elements taken into account are:

  • Bounded contexts
  • The direction of influence (Upstream / Downstream)
  • Strategic patterns (ACL, OHS, Partnership…)
  • Pivotal terms of the Ubiquitous Language
  • Organizational boundaries between teams

Golden rule: if a technical detail changes tomorrow, the map should not change. If the map changes when the business contract between two contexts changes, it is doing its job.


3. The central concept: the Bounded Context

A Bounded Context is an area of the system within which:

  1. A vocabulary (the Ubiquitous Language) has a coherent and unique meaning.
  2. A model is valid, applicable, and authoritative.
  3. A team (or a small group of teams) is responsible for it.

Operational definition: "the perimeter within which a word means what it means".

3.1 How boundaries emerge

The boundaries of a Bounded Context follow human language. Where a word changes meaning, the boundary lies.

🟧 Bounded Context: MarketingCustomer = Segment(scoring, behavior)🟩 Bounded Context: SupportCustomer = Account withincidents(SLA, ticket history)🟦 Bounded Context: SalesCustomer = Prospect(pipeline, contract value)

Three contexts, three different definitions of "Customer". None is wrong β€” each is true within its own context.

3.2 Unique concepts vs. shared concepts

  • Unique concept: exists in only one context. E.g.: a Support Ticket makes no sense in Marketing.
  • Shared concept: carried by multiple contexts, with a model specific to each. An explicit translation is necessary at the boundary. E.g.: Customer, Product, Order.

Rule: a shared concept is not a shared class. It is three different classes that correspond to each other at the boundary.


4. The Ubiquitous Language: the language that defines the boundary

The Ubiquitous Language (UL) is the vocabulary developed jointly by developers and business experts within a Bounded Context.

4.1 The fundamental principle

Same meaning ⟺ same context; different meaning ⟺ different context.

Language is the boundary indicator. When you hear two people use the same word with visibly incompatible meanings, you are looking at two different contexts β€” whether they are already separated in the code or not yet.

4.2 The UL is local, never global

Classic mistake: wanting a single "company-wide glossary". This ambition always fails, because it denies what DDD has observed: a language naturally emerges at the team scale. Trying to impose it higher up dilutes meaning and hampers autonomy.

4.3 Coherent application

The UL must appear everywhere within its context:

UbiquitousLanguageCode & class namesDocumentationTestsMeetings & ticketsFrontend componentsData schema

A term that appears only in the documentation but not in the code is a weak signal: either it is obsolete, or it lives in another context.


5. The Context Map: a map of boundaries

The Context Map is the diagram that answers three questions, and only three:

  1. Which Bounded Contexts exist?
  2. How are they connected (what pattern, what direction)?
  3. Where does the translation of shared concepts live?

It is a strategic map. It does not say how a context is implemented; it says where the boundaries are and how they are crossed.

5.1 Several maps are better than one

A large exhaustive map is almost always unreadable. Prefer several focused maps, each answering a precise question:

  • Map of the Payment team's dependencies.
  • Map of integrations with the legacy ERP.
  • Map of contexts affected by GDPR.

5.2 A map is alive

Patterns evolve with team structure, trust between groups, and ownership changes. A map that is not reviewed regularly lies.


6. Direction of influence: Upstream / Downstream / Free

Before choosing a pattern, you need to qualify the nature of the relationship between two contexts. DDD distinguishes three cases.

6.1 Mutually Dependent

The two contexts need each other to succeed. A delivery of one without the other makes no sense.

β†’ Associated pattern: Partnership (or Shared Kernel in case of very strong coupling).

6.2 Upstream / Downstream

The Upstream (U) can succeed without the Downstream (D). Decisions of the upstream affect the downstream; the reverse is not true.

⬆ Upstream(imposes its model)⬇ Downstream(adapts)

β†’ Associated patterns: Customer-Supplier, Conformist, ACL, OHS / Published Language.

6.3 Free

No significant organizational or technical link. Changes in one do not affect the other.

β†’ Associated pattern: Separate Ways.

Diagnostic tip: ask "If team X disappeared tomorrow, could team Y continue?". The answer classifies the relationship.


7. The nine Context Map patterns

They are grouped into three families of response to the direction of influence: strong cooperation, asymmetric relationship, and avoidance.

7.1 Family A β€” Strong cooperation

Pattern 1 β€” Partnership

Two mutually dependent teams coordinate planning and releases. Interdependent features are delivered together.

  • Signal: a failure on one side leads to the failure of the other.
  • When: shared product objectives, low communication latency, joint planning sessions possible.
  • Risk: as soon as communication degrades, the pattern silently drifts toward Customer-Supplier without anyone adjusting the contracts β€” hence sudden integration failures.
coordinationContext AContext B

Pattern 2 β€” Shared Kernel

The two contexts designate an explicit subset of the model that is common to them (a module, a library, a schema). Any modification must be negotiated.

  • Signal: two contexts share code or a schema.
  • Survival rules: keep the kernel tiny, integration tests with each modification, teams at Partnership level.
  • Often: a temporary measure during modernization.
Context AShared KernelContext B

Warning: an undisciplined Shared Kernel becomes the most dangerous coupling in the system β€” each team pulls it toward itself.


7.2 Family B β€” Asymmetric relationship

This is the most common family: the majority of inter-team relationships are unbalanced.

Pattern 3 β€” Customer / Supplier

A formalized Upstream-Downstream relationship where the Customer has real negotiating power: their needs enter the Supplier's backlog.

  • Signal: the Downstream can negotiate, prioritize, refuse.
  • When: internal teams with SLA, or single customer of the supplier.
deliversnegotiates needsU β€” SupplierD β€” Customer

Pattern 4 β€” Conformist

The Downstream fully adopts the Upstream's model, without translation. No negotiation possible.

  • Signal: non-influenceable third-party API, imposed legacy.
  • When: reasonably suitable upstream model, non-core domain for you.
  • Major risk: if conformity extends to a core domain, the internal model becomes "the mirror of someone else's problems".
model adopted as-isU β€” Upstream(imposed model)D β€” Downstream(Conformist)

Pattern 5 β€” Anticorruption Layer / ACL

The Downstream installs a translation layer that isolates its model from the Upstream's model. It is the inverse of the Conformist: you say "no" diplomatically.

  • Signal: you are touching a legacy system, or a "polluted" Upstream, and you are protecting a core domain.
  • Cost: implement and maintain the translator.
  • Benefit: your Ubiquitous Language stays clean; only the ACL knows the external complexity.
external modelclean modelU β€” UpstreamACLtranslationD β€” Downstreamcore

Translation mechanics:

  • Stateless: each message or request is mapped independently.
  • Stateful: the translator aggregates, combines, or consolidates. It then becomes a mini Bounded Context dedicated to integration.

Pattern 6 β€” Open Host Service / OHS

The inverse of the ACL, seen from the Upstream side: the latter exposes a standardized protocol designed for the integration of multiple consumers.

  • Signal: public API or platform with multiple clients.
  • When: the Upstream has the maturity to design a stable public contract and to evolve it (versioning) without breaking the consumers.
public contractpublic contractpublic contractU β€” UpstreamOHSD₁Dβ‚‚D₃

Pattern 7 β€” Published Language / PL

A documented and shared domain language, which expresses what must flow between contexts. Often coupled with OHS.

  • Standard examples: iCalendar, vCard, HL7, OpenBanking.
  • Signal: formal exchange format, versioned contract.

OHS + PL is "the cleanest way to scale integrations around a central service".


7.3 Family C β€” Avoidance

Pattern 8 β€” Separate Ways

Two contexts explicitly choose not to integrate. Duplication is less costly than integration.

  • Signal: integration cost > benefit.
  • When: peripheral or generic domains, misaligned teams.
  • Rare for core domains.

Pattern 9 β€” Big Ball of Mud

A system (or subsystem) with blurred boundaries, mixed models, and massive technical debt. This is not a pattern to adopt: it is an anti-pattern to contain.

  • Action: surround the ball with an ACL to prevent its spread to neighboring contexts.
πŸ’© Big Ball of MudACLClean context

8. Choosing a pattern: decision tree

Four decision axes are enough for 90% of cases.

AxisQuestion
Strength of collaborationDo the teams communicate frequently? Shared objectives?
Power balanceWho controls the contract? Who has to adapt?
Domain criticalityIs it a core or peripheral domain?
Quality of the upstream modelIs the Upstream model clean or legacy / polluted?

8.1 Simplified decision tree

YesYesNoNoNoYesYesNoYesNoYesNoDo the two contextsrelease together?Do they sharecode / a model?Shared KernelPartnershipIs there asignificant link?Separate WaysCan the Downstreamnegotiate?Customer / SupplierIs the domaincore for the Downstream?Anti-Corruption LayerAre theremultiple consumers?Open Host Service+ Published LanguageConformist

8.2 Summary table

PatternRelationshipWho controlsTranslationTypical use
PartnershipMutually dep.SharedNegotiatedCo-located teams, same goals
Shared KernelStrong couplingSharedCommon codeModernization, mono-repo
Customer-SupplierNegotiated U / DUpstream (influenceable)At the boundaryInternal teams with SLA
ConformistNon-negotiated U / DUpstream (intransigent)NoneThird-party API, external legacy
ACLU / D, downstream defenseDownstreamDedicated layerCore domain facing legacy
OHS + PLU / D, exposureUpstreamPublished contractMulti-consumer platform
Separate WaysNoneN/ANonePeripheral domains
Big Ball of MudAnti-patternβ€”Contain via ACLChaotic legacy to isolate

9. Evolution of patterns over time

A pattern is a snapshot. Relationships drift according to human and organizational changes.

Observed transitionTypical trigger
Partnership β†’ Customer-SupplierTeams separated by time zone or organizational line
Customer-Supplier β†’ ConformistThe Downstream is no longer consulted
Conformist β†’ ACLThe Downstream becomes a core domain and wants to protect itself
Shared Kernel β†’ Customer-SupplierThe kernel grows, becomes unmanageable, and is split
Anything β†’ Separate WaysCollaboration cost > benefits

Good reflex: review the Context Map with each team reorganization or major change of ownership. Integration frictions are almost always the symptom of an obsolete pattern.


10. Visual notation of a Context Map

There is no rigid standard. A common convention, sufficient for 99% of cases:

  • Each Bounded Context is a rounded box.
  • A solid arrow indicates the flow of the model (from Upstream to Downstream).
  • The labels U, D, OHS, ACL, PL, SK, PT, CF, C, S annotate the roles.
  • A special /ACL/ or OHS box is placed at the boundary where the translation lives.

With Mermaid:

ConformistU β†’ DCustomer-SupplierU β†’ DOHS + PLLegacy ERPπŸ’© BBoMSalesBillingSupportACL

Reading: Sales undergoes the ERP's model (Conformist), exposes a public API to Support (OHS), and negotiates with Billing. Support protects its model from the ERP via an ACL.