Shared kernel (DDD)
A small part of the domain model that two teams own together and change only by agreement, such as shared types or a common library.
In a shared kernel two bounded contexts reuse the same code for one piece of the model, for example money, a patient identifier or a calendar slot. It saves translation, but every change now needs both teams, and the kernel tends to grow because adding to it is easier than agreeing on a border.
In a monorepo this happens by accident: a “common” or “shared” package that everyone imports and nobody owns. Treat it as a shared kernel on purpose, with named code owners from both sides and tests that both teams run, or split it. It is one of the patterns on a context map.
Related terms
- Context map (DDD): A diagram of the bounded contexts in a system and the kind of relationship between each pair: who depends on whom and how models are translated.
- Bounded context: A part of a system where each business term has one meaning and one model, with explicit translation at its edges.
- Monorepo: One repository that holds several apps and shared packages, versioned and changed together.
- Code ownership (CODEOWNERS): Every part of a codebase has a named team responsible for it, often enforced by a CODEOWNERS file that requests that team’s review on every change.
