Context Mapper provides a DSL to create context maps based on Domain-driven Design (DDD) and its strategic patterns. The model behind the language and its semantic rules aim to formalize our interpretation of the DDD patterns and how they can be combined in a concise manner. DDD and its bounded contexts further provide an approach for decomposing a domain into multiple bounded contexts. With our Service Cutter integration (proof-of-concept) we illustrate how the Context Mapper DSL (CML) can be used as a foundation for structured service decomposition approaches. Additionally, our context maps can be transformed into PlantUML models (proof-of-concept).

Getting started

To start with Context Mapper install our Eclipse plugin by using the following update site: https://dl.bintray.com/contextmapper/context-mapping-dsl/updates/.

System Requirements

To use the ContextMapper DSL you need the following tools:

CML Models

As soon as you have installed our Eclipse plugin, you can start creating context maps. Start with a new context map by creating a file with the file extension .cml in an Eclipse project which has the Xtext nature enabled. You can find a detailed manual how you create such a project and a CML file here.

Checkout our examples repository to find examples of complete context maps. One of the examples is the DDD Sample Application. The following CML code snippets give you a first impression how the DSL looks like.

The context map for the DDD Sample Application which is split into three bounded contexts:

 * The DDD Cargo sample application modeled in CML. Note that we split the application into 
 * multiple bounded contexts.
ContextMap {
  contains CargoBookingContext
  contains VoyagePlanningContext
  contains LocationContext
  CargoBookingContext [SK]<->[SK] VoyagePlanningContext
  CargoBookingContext [D]<-[U,OHS,PL] LocationContext

  VoyagePlanningContext [D]<-[U,OHS,PL] LocationContext

The bounded contexts have to be specified before you can use them within a context map. A simple example of a bounded context definition:

BoundedContext LocationContext {
  Module location {
    Aggregate Location {
      Entity Location {

        PortCode portcode
        - UnLocode unLocode
          String name

      ValueObject UnLocode {
        String unLocode

      ValueObject LocationShared {
        PortCode portCode
        - Location location

Checkout our Language Reference section to learn all details about the Context Mapper DSL.

Note that the DSL elements within the modules and aggregates (tactic DDD patterns) is based on the Sculptor DSL. You can find a short introduction into the syntax of the aggregates here. A short manual regarding the other tactic DDD patterns is provided on this page. A complete documentation regarding the syntax for the tactic DDD patterns can be found on the Sculptor website.

Domain-driven Design Patterns

Strategic Patterns

Find a list of all supported strategic DDD patterns and their syntax within our DSL here.

Tactic Patterns

The implementation of the tactic DDD patterns is based on Sculptor DSL. You can find their documentation and the supported patterns under the following link: http://sculptorgenerator.org/documentation/. Our short introduction into the syntax can be found here.

Architectural Refactorings (ARs)

The Context Mapper tool provides a series of architectural refactorings which allow you to improve and evolve your models iteratively. Find more information and the documentation of all available refactorings here.

Transformations / Generators

Context Mapper provides tools to transform CML models to MDSL (micro-)service contracts,
PlantUML diagrams and ServiceCutter input.

MDSL (Micro-)Service Contracts

With our MDSL generator you can generate (micro-)service contracts out of your Context Maps. The resulting contracts illustrate how you can derive (micro-)services from strategic DDD context maps and aim for providing assistance regarding how your system can be implemented in an (micro-)service-oriented architecture.

This is an example MDSL service contract for our insurance example:

API description CustomerManagementContextAPI

data type Address { "street":V<string>, "postalCode":V<int>, "city":V<string> }
data type AddressId P
data type changeCustomerParameter { "firstname":V<string>, "lastname":V<string> }

endpoint type CustomersAggregate
    operation createAddress
        payload Address
        payload AddressId
    operation changeCustomer
        payload changeCustomerParameter

API provider CustomerManagementContextProvider
  offers CustomersAggregate
  at endpoint location "http://localhost:8001"
    via protocol "RESTful HTTP"

API client PolicyManagementContextClient
  consumes CustomersAggregate
API client CustomerSelfServiceContextClient
  consumes CustomersAggregate


Learn more about the MDSL generator here.

plantUML Diagrams

You can generate plantUML component diagrams out of CML context maps. Additionally, the transformation generates class diagrams for all bounded contexts. Here you can find out how to generate them.

Example component diagram (DDD sample): DDD Sample Component Diagram

Example class diagram (Cargo booking context): Cargo Booking Context

Service Cutter Integration

Find out here how to produce Service Cutter input to calculate possible service cuts or new bounded contexts:

Service Cutter DDD Sample