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-7: Merge Bounded Contexts

    Merges two bounded contexts together. The result is one bounded context containing all the aggregates of the two input bounded contexts.

    Known limitation: Unfortunately, this AR does not work in VS Code in case the removed Bounded Context is referenced in a Context Map. This is due to a bug in the Xtext framework.

    Context & Rationales

    By decomposing a system into multiple bounded contexts we aim for loose coupling between the bounded context and a high cohesion within them. However, sometimes a decomposition may be too fine-granular and merging bounded contexts with a high coupling together improves the cohesion within the corresponding resulting bounded context.

    Goal

    This Architectural Refactoring (AR) merges two bounded contexts together. The resulting bounded context contains all aggregates of the two input bounded contexts. It can be applied if two bounded context are tightly coupled and the aggregates somehow belong together. This may improve the cohesion within the resulting bounded context.

    Notes:

    • By applying this AR multiple times you may end with one single Bounded Context and an empty Context Map (no relationships).
    • The AR merges all Bounded Context attributes (such as exposed aggregates, implementation technology, etc.) which are possible to merge. However, there are still attributes which cannot be merged (such as the name or the domain vision statement).
      • All attributes which cannot be merged are taken from the first Bounded Context (by default) selected in the dialog (see screenshot below).
      • You have to use the corresponding checkbox on the input dialog, if you want to take the attributes from the second Bounded Context.

    Inverse AR’s:

    • AR-4: Extract Aggregates by Volatility
    • AR-5: Extract Aggregates by Cohesion
    • AR-2: Split Bounded Context by Use Cases (may need multiple merges to completely revert)
    • AR-3: Split Bounded Context by Owner (may need multiple merges to completely revert)

    Preconditions

    • Your model needs at least two bounded contexts to merge.

    Input

    • Two bounded contexts.

    Output

    • One bounded context containing all aggregates of the two input 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 two bounded contexts with one aggregate each. Therefore the AR is available on both bounded contexts:

    Merge Bounded Contexts Example Input

    Selection Dialog

    After triggering this refactoring, a dialog pops up on which you can choose with which other bounded context you want to merge:

    Merge Bounded Contexts Example Dialog

    Note: Use the checkbox "Take attributes which cannot be merged (incl. Bounded Context name) from second Bounded Context.", if you prefer that the attributes which cannot be merged (also see hint above) are taken from the second Bounded Context. By default, the attributes are taken from the first Bounded Context.

    Result

    The resulting model contains one bounded context with both aggregates of the selected bounded contexts:

    Merge Bounded Contexts Example Output

    Example Sources

    • You can find the CML sources for this AR example here.
    Improve this page on GitHub
    ← PreviousAR-6: Merge Aggregates Next →AR-8: Extract Shared Kernel
    © 2026 Context Mapper contributors
    • GitHub
    • Get Involved
    • Background & Publications
    • RSS