Domain Driven Design Context Mapping Created: 10 Jan 2026 Updated: 10 Jan 2026

Shared Kernel

What is a Shared Kernel?

A Shared Kernel is a common core that two or more teams use. Because this "kernel" is shared, it cannot be changed without mutual agreement and synchronized testing between the involved teams.

  1. The Scope: It should be kept as small as possible. Usually, it contains only basic Value Objects, Common Entities, or Domain Events.
  2. The Coupling: It creates a very strong bond. If Team A changes a property in a shared class, Team B’s code might immediately break.


Cinema Example: Shared Kernel

In our Cinema system, the Booking Context and the Loyalty Context might decide that the concept of a "CustomerIdentity" is so fundamental and identical in both worlds that they don't want to map it back and forth.

They create a Shared Kernel containing:

  1. CustomerId (Value Object)
  2. Money (Value Object)
  3. UserAccountCreated (Domain Event)

.NET Core Implementation

Typically, this is implemented as a separate Class Library or a Private NuGet Package.

// Cinema.Shared.Kernel Project
namespace Cinema.Shared.Kernel.Domain;

// Value Object shared by Booking and Loyalty
public record Money(decimal Amount, string Currency)
{
public static Money Zero(string currency) => new(0, currency);
}

// Common Identity
public record CustomerId(Guid Value);


Share this lesson: