Skip to content
CONTEXT MAPPER
  • Docs
  • Language Reference
  • Generators
  • News
  • Background
  • Get Involved
    Introduction
    • Welcome
    • Getting started
    • Create CML Project
    • Examples
    • Usage as Library
    • Frequently Asked Questions
    Language Reference (Core)
    • CML Reference - Introduction
    • Language Semantics
    • Context Map
    • Bounded Context
    • Domain and Subdomain
    • Domain Vision Statement
    • Partnership
    • Shared Kernel
    • Customer/Supplier
    • Conformist
    • Open Host Service
    • Anticorruption Layer
    • Published Language
    • Responsibility Layers
    • Knowledge Level
    • Aggregate
    • Tactic DDD Syntax
    • Application and Process Layer
    • User Requirements
    • Stakeholders
    • Value Registers
    • Imports
    Analysis and Design Transformations
    • Rapid Object-oriented Analysis and Design
    • Story Splitting (PoC)
    • Stakeholder and Value Modelling Transformations
    Architectural Refactorings (ARs)
    • Architectural Refactorings
    • AR-1: Split Aggregate by Entities
    • AR-2: Split Bounded Context by Features
    • AR-3: Split Bounded Context by Owner
    • AR-4: Extract Aggregates by Volatility
    • AR-5: Extract Aggregates by Cohesion
    • AR-6: Merge Aggregates
    • AR-7: Merge Bounded Contexts
    • AR-8: Extract Shared Kernel
    • AR-9: Suspend Partnership
    • AR-10: Change Shared Kernel to Partnership
    • AR-11: Change Partnership to Shared Kernel
    Value-Driven Analysis and Design
    • Value-Driven Analysis and Design (VDAD) Support
    Service Cutter
    • Context Map Suggestions with Service Cutter
    • Service Cutter Configuration File (.servicecutter.yml)
    Reverse Engineering
    • Context Map Discovery
    Generators
    • Generators Overview
    • Context Map Generator
    • PlantUML Generator
    • BPMN Sketch Miner Generator
    • MDSL (Micro-)Service Contracts Generator
    • Service Cutter Generators
    • Generic Generator (Templating)
    Tutorials
    • Model Event Storming Results in Context Mapper
    • Event Sourcing and CQRS Modeling in Context Mapper
    • Generate Microservices From Context Map Using JHipster
    • Systematic Service Decomposition with Context Mapper and Service Cutter
    • Validating the Implementation against the Model (with ArchUnit)
    IDE Plugins and Extensions
    • Visual Studio Code Extension
    • Online IDE (no longer supported)
    • Eclipse Plugin
    • Feature Support

    AR-8: Extract Shared Kernel

    Extracts a new Bounded Context from a Shared Kernel relationship. It further established two upstream-downstream relationships so that the existing Bounded Context can use the ‘shared’ functionality.

    Context & Rationales

    The Shared Kernel pattern describes a close relationship between two Bounded Contexts which share a certain part of their domain models. The pattern is typically implemented as a shared library which is maintained by both teams. However, both teams depend on that shared code and each team has to deal with changes of the other one. If such a shared library gets very big and difficult to maintain it may be better to create a separate Bounded Context for it. A dedicated team may maintain the model within this new Bounded Context.

    Goal

    This Architectural Refactoring (AR) extracts a Shared Kernel into a new Bounded Context. The resulting Context Map will no longer contain the Shared Kernel relationship, but two new upstream-downstream relationships between the new and the existing two Bounded Contexts. This AR can be applied if a Shared Kernel gets big, difficult to maintain, and it may be better to have a new team maintaining this shared part of the domain model in a separate Bounded Context. This may increase the autonomy of all involved teams.

    Extract Shared Kernel Illustration

    Preconditions

    • Your model needs at least two bounded contexts which are in a Shared Kernel relationship.

    Input

    • The Shared Kernel relationship.

    Output

    • A new Bounded Context for the shared domain model parts and two new upstream-downstream relationships between the new and the existing two Bounded Contexts.

    Example

    The following example illustrates how this AR can be applied. The corresponding sources can be found in our examples repository.

    Input

    The following model contains a Shared Kernel relationship. Therefore the AR is available with a right-click on the relationship (arrow):

    Extract Shared Kernel Example Input

    Result

    The resulting model contains an additional Bounded Context for the Shared Kernel (shared model parts) and two new upstream-downstream relationships between the new and the existing Bounded Contexts:

    Extract Shared Kernel Example Output

    Example Sources

    • You can find the CML sources for this AR example here.
    Improve this page on GitHub
    ← PreviousAR-7: Merge Bounded Contexts Next →AR-9: Suspend Partnership
    © 2026 Context Mapper contributors
    • GitHub
    • Get Involved
    • Background & Publications
    • RSS