Skip to content

context-mapping

Relationship between two Bounded Contexts, or between a Bounded Context and an External System. See Concepts: Context Mapping.

Schema

oneOf:
    - properties:
        type:
            const: customer-supplier
        customer:
            oneOf:
                - type: object
                  properties:
                    domain:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                    boundedContext:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                  required: [domain, boundedContext]
                  additionalProperties: false
                - type: object
                  properties:
                    domain:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                    externalSystem:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                  required: [domain, externalSystem]
                  additionalProperties: false
        supplier:
            oneOf:
                - type: object
                  properties:
                    domain:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                    boundedContext:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                  required: [domain, boundedContext]
                  additionalProperties: false
                - type: object
                  properties:
                    domain:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                    externalSystem:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                  required: [domain, externalSystem]
                  additionalProperties: false
      required: [type, customer, supplier]
    - properties:
        type:
            const: conformist
        conformist:
            oneOf:
                - type: object
                  properties:
                    domain:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                    boundedContext:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                  required: [domain, boundedContext]
                  additionalProperties: false
                - type: object
                  properties:
                    domain:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                    externalSystem:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                  required: [domain, externalSystem]
                  additionalProperties: false
        upstream:
            oneOf:
                - type: object
                  properties:
                    domain:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                    boundedContext:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                  required: [domain, boundedContext]
                  additionalProperties: false
                - type: object
                  properties:
                    domain:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                    externalSystem:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                  required: [domain, externalSystem]
                  additionalProperties: false
      required: [type, conformist, upstream]
    - properties:
        type:
            const: anti-corruption-layer
        downstream:
            oneOf:
                - type: object
                  properties:
                    domain:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                    boundedContext:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                  required: [domain, boundedContext]
                  additionalProperties: false
                - type: object
                  properties:
                    domain:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                    externalSystem:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                  required: [domain, externalSystem]
                  additionalProperties: false
        upstream:
            oneOf:
                - type: object
                  properties:
                    domain:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                    boundedContext:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                  required: [domain, boundedContext]
                  additionalProperties: false
                - type: object
                  properties:
                    domain:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                    externalSystem:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                  required: [domain, externalSystem]
                  additionalProperties: false
      required: [type, downstream, upstream]
    - properties:
        type:
            const: open-host-service
        host:
            oneOf:
                - type: object
                  properties:
                    domain:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                    boundedContext:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                  required: [domain, boundedContext]
                  additionalProperties: false
                - type: object
                  properties:
                    domain:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                    externalSystem:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                  required: [domain, externalSystem]
                  additionalProperties: false
        consumer:
            oneOf:
                - type: object
                  properties:
                    domain:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                    boundedContext:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                  required: [domain, boundedContext]
                  additionalProperties: false
                - type: object
                  properties:
                    domain:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                    externalSystem:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                  required: [domain, externalSystem]
                  additionalProperties: false
      required: [type, host, consumer]
    - properties:
        type:
            const: published-language
        publisher:
            oneOf:
                - type: object
                  properties:
                    domain:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                    boundedContext:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                  required: [domain, boundedContext]
                  additionalProperties: false
                - type: object
                  properties:
                    domain:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                    externalSystem:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                  required: [domain, externalSystem]
                  additionalProperties: false
        consumer:
            oneOf:
                - type: object
                  properties:
                    domain:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                    boundedContext:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                  required: [domain, boundedContext]
                  additionalProperties: false
                - type: object
                  properties:
                    domain:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                    externalSystem:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                  required: [domain, externalSystem]
                  additionalProperties: false
      required: [type, publisher, consumer]
    - properties:
        type:
            const: shared-kernel
        participants:
            type: array
            minItems: 2
            maxItems: 2
            items:
                type: object
                properties:
                    domain:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                    boundedContext:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                required: [domain, boundedContext]
                additionalProperties: false
      required: [type, participants]
    - properties:
        type:
            const: partnership
        participants:
            type: array
            minItems: 2
            maxItems: 2
            items:
                type: object
                properties:
                    domain:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                    boundedContext:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                required: [domain, boundedContext]
                additionalProperties: false
      required: [type, participants]
    - properties:
        type:
            const: separate-ways
        participants:
            type: array
            minItems: 2
            maxItems: 2
            items:
                type: object
                properties:
                    domain:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                    boundedContext:
                        type: string
                        pattern: "^[a-z][a-z0-9-]*$"
                required: [domain, boundedContext]
                additionalProperties: false
      required: [type, participants]

Anatomy

A Context Mapping carries no scope – its endpoints may straddle Domains. The natural identifier of a mapping is its type plus its endpoints; name is a human-readable handle, not a referenced identifier from elsewhere in the model.

The type field selects the mapping pattern from a closed set: customer-supplier, conformist, anti-corruption-layer, open-host-service, published-language, shared-kernel, partnership, or separate-ways. The chosen value determines which sibling fields are required, because each pattern has its own role vocabulary.

The asymmetric patterns name two distinct sides. customer-supplier requires customer and supplier. conformist requires conformist and upstream. anti-corruption-layer requires downstream and upstream. open-host-service requires host and consumer. published-language requires publisher and consumer. Each role accepts either a Bounded Context reference ({ domain, boundedContext }) or an External System reference ({ domain, externalSystem }), so a mapping can describe an internal collaboration or a relationship with the outside world equally well.

The symmetric patterns – shared-kernel, partnership, separate-ways – use a single participants field that takes exactly two Bounded Contexts. External Systems are not allowed here on purpose: sharing a kernel or forming a partnership with a third-party system does not fit the model. If the relationship needs to acknowledge an outside system, use one of the asymmetric patterns instead.

description and metadata carry the usual free-form prose and non-semantic attachments. apiVersion is schema.esdm.io/core/v1, kind is context-mapping, and name is the mapping's handle in the kebab-case name pattern.