Domains & teams

5 min read

Shared Kernel: When Two Teams Are Better Off Sharing Part of the Model Than Duplicating It

Complete domain independence sounds attractive, but sometimes two teams genuinely need the same understanding of a small part of the model. A Shared Kernel makes that sharing deliberate — including the cost of joint ownership.

What problem are we solving?

Sometimes two bounded contexts need exactly the same definition or rule. If each creates its own copy, they can drift until the business has two versions of the same truth.

The opposite extreme is a giant shared library that every team must change together. At that point independence disappears.

How a Shared Kernel works

A Shared Kernel is a small, deliberately shared part of a model or codebase owned jointly by several contexts. Changes require agreement because every participant is affected.

The key word is small. A Shared Kernel should not become a container for everything that once looked similar.

What the business gets

The business gets consistency where divergence is genuinely expensive: fewer contradictions between products, fewer manual reconciliations, and less risk that the same rule behaves differently in different places.

The company also avoids building a separate service or complex integration only to share a small piece of truly common logic.

What the team gets

Teams get a consistent foundation and duplicate less work. Shared changes become visible before one implementation quietly diverges from another.

But teams give up some autonomy: the Shared Kernel cannot be changed as freely as code owned entirely inside one context.

What the customer gets

Customers get more consistent behavior across parts of the product where the business expects the same rules and terminology.

What do we pay for it?

The main price is coordination. Joint ownership means joint compatibility decisions, release discipline, and responsibility across teams.

If the Shared Kernel grows, it can become a hidden monolith inside a distributed architecture. Then every change starts requiring everyone again.

When not to add the complexity

If two models only look similar but have different business meaning, do not merge them. Duplication can be cheaper than permanent coupling.

A Shared Kernel is justified when the meaning is truly shared and the cost of divergence is higher than the cost of coordination.

What should we ask before deciding?

In the end

A Shared Kernel is not a way to eliminate duplication at any cost. It deliberately buys consistency by giving up part of team autonomy.

For the business, a Shared Kernel is useful only where a jointly owned model costs less than two independent versions of the same important truth.