Bounded Contexts with LVD

Domain-driven design cuts a system into bounded contexts. LVD cuts it into layers by volatility. Combine them carelessly and you get one of two messes: layers that sprawl across every context, or contexts that each invent their own layering. The book's answer is short enough to sketch on a napkin. Every context gets the whole stack.

Slice vertically, then stack

The central structural idea is that a bounded context is a boundary for the layer stack as well as for the model. Just as a context draws a line around a vocabulary, it draws a line around a complete set of layers, from Schema to whatever the context exposes at the top. The contexts know nothing about each other's internals and talk through defined interfaces.

Imagine a conference platform with two contexts, Programme (sessions, speakers, rooms) and Registration (attendees, tickets, payments). Each owns a full stack of its own:

programme/
  schema/   utils/   resources/   tools/   api/
registration/
  schema/   utils/   resources/   tools/   api/

Why not keep a single schema/ folder for everything and organise by layer first? Because of what happens next. Session types and attendee types become neighbours, someone imports one from the other because it saves ten lines, and within a year the context boundary exists only in the design document. The folder layout is where a boundary either becomes real or quietly dissolves. Giving each context a full stack means the layer rules and the domain boundary reinforce each other instead of competing.

A side benefit I would expect is that review and checking become easier to scope. A dependency check can run inside each context's stack, with one extra rule that no context's folders import another's. The first check enforces the layers and the second enforces the boundary.

What may cross: the shared kernel

Sometimes two contexts genuinely need the same small piece of model. DDD calls this a shared kernel. In LVD terms the book implements it as a shared Schema package, and the choice of layer is the interesting part. Layer 1 has the lowest volatility of the nine, so a change there should be rare and carefully governed. That fits DDD's own advice that a shared kernel be small, stable and jointly maintained.

In the conference platform, both contexts need to agree on what a time slot is:

// packages/shared-schemas/src/time-slot.ts  (Layer 1 only)
export type TimeSlot = {
  startsAt: string; // ISO 8601, always in UTC
  endsAt: string;   // strictly after startsAt
};

Programme uses it to schedule talks and Registration uses it to detect clashing workshop bookings. Neither imports the other, and both import this package. Notice what the kernel does not hold: Programme's idea of a session and Registration's idea of a ticket stay in their own Schema folders. Only the agreed concept is shared, and anything one context adds to it stays at home.

Volatility as a membership test

Here is my own commentary rather than the book's. Layer placement gives you a practical test for what belongs in a kernel: how often does the type change? If a supposedly shared type is edited every sprint by one team and merely tolerated by the other, it is not a kernel. It is a coupling in disguise, and an explicit contract between the contexts, such as an API or an event schema, would serve better.

The test cuts the other way as well. Putting a type at Layer 1 makes it expensive to change, because every layer above in every context depends on it. That is a feature when the concept is truly stable and a trap when it is not. Before promoting a type into the kernel, ask whether you would be comfortable changing it only after a conversation with the other team.

The takeaway

Treat a bounded context as a vertical slice that carries a complete layer stack, and let only a small, stable Schema package cross the boundary. The book goes on to show how the remaining relationships between contexts, including translating a foreign model at the edge, land in particular layers. For the wider picture, see mapping DDD to LVD layers, and for guidance on when the combination is worth the effort, when to combine LVD with DDD. The vocabulary side of the same story is in ubiquitous language in the Schema layer.

What the book covers

  • Anti-corruption layers built as Resources that translate upstream models into downstream domain types
  • How Conformist, Customer-Supplier and Published Language relationships each map onto layers
  • A worked pair of contexts, each with a full stack from Schema up to the MCP layer
  • A concrete shared-kernel package built from validated schemas for a currency type