What Is a Bounded Context?

The smallest unit inside which a model is consistent.

0/3 done

Theory

A bounded context is the boundary inside which a particular model is consistent and unambiguous. "Customer" in Sales is not the same shape as "Customer" in Support — and pretending otherwise is where Big Ball of Mud is born.

Inside a bounded context the ubiquitous language is sovereign. Across contexts you translate (anti-corruption layer, published language, etc.).

Visualization

Sales context Customer = buyer Order = checkout cart Support context Customer = account Order = service incident ACL

Two contexts, two definitions of Customer. The dashed line is the anti-corruption layer that translates between them.

Worked example — drawing the diagram in Mermaid

Worked example — Mermaid flowchart with subgraph blocks.

To draw bounded contexts in Mermaid you wrap each context's nodes inside a subgraph NAME ... end block, and you connect nodes across subgraphs with arrows:

flowchart LR
  subgraph Sales
    S_Customer[Customer]
    S_Order[Order]
  end
  subgraph Support
    Sp_Customer[Customer]
    Sp_Ticket[Ticket]
  end
  S_Customer -. ACL .-> Sp_Customer

Reading it:

  • Two subgraph ... end blocks — one per bounded context.
  • Inside, each node has a unique id (S_Customer) and a display label in [...].
  • The -. label .-> dashed arrow is the anti-corruption layer translating between the two definitions of Customer.

In the playground below, start from this skeleton and add a third subgraph (e.g. Billing) with at least one node, then connect it to Sales.

Reading in progress · 0 of 3 activities done