Map relationships between bounded contexts using DDD context mapping patterns. Use when defining upstream/downstream relationships, integration strategies (ACL, OHS, PL), or generating Context Mapper DSL output. Follows event storming for bounded context discovery.
This skill is limited to using the following tools:
references/cml-syntax.mdreferences/integration-strategies.mdreferences/pattern-catalog.mdreferences/pattern-selection.mdreferences/team-topologies.mdMap relationships between bounded contexts using Domain-Driven Design context mapping patterns. Produces Context Mapper DSL (CML) output and integration strategy recommendations.
Keywords: context mapping, bounded contexts, upstream, downstream, ACL, anti-corruption layer, shared kernel, customer supplier, open host service, published language, conformist, partnership, CML, integration patterns, domain relationships
Use this skill when:
Eight strategic DDD patterns for defining context relationships:
| Pattern | Abbrev | Description | Use When |
|---|---|---|---|
| Shared Kernel | SK | Shared code/model between contexts | Two contexts need identical domain logic |
| Partnership | P | Equal collaboration, mutual dependency | Teams co-evolve, no clear upstream/downstream |
| Pattern | Abbrev | Description | Use When |
|---|---|---|---|
| Customer/Supplier | C/S | Upstream supplies, downstream consumes | Clear provider/consumer relationship |
| Conformist | CF | Downstream adopts upstream model | Downstream team has no leverage to negotiate |
| Anti-Corruption Layer | ACL | Downstream translates upstream model | Upstream model doesn't fit downstream needs |
| Open Host Service | OHS | Upstream provides formal API | Multiple consumers need standardized access |
| Published Language | PL | Standardized API format (OpenAPI, etc.) | Cross-team communication requires contract |
| Pattern | Abbrev | Description | Use When |
|---|---|---|---|
| Separate Ways | SW | No integration, independent evolution | Contexts have no meaningful relationship |
For detailed pattern descriptions with examples: See references/pattern-catalog.md
Do the contexts share code or data model?
├── Yes → Shared Kernel [SK]
└── No → Is there a clear data/service flow?
├── No → Do teams collaborate equally?
│ ├── Yes → Partnership [P]
│ └── No → Separate Ways [SW]
└── Yes → Identify Upstream (provider) and Downstream (consumer)
└── Can downstream influence upstream's model?
├── No → Does upstream model fit downstream needs?
│ ├── Yes → Conformist [CF]
│ └── No → Anti-Corruption Layer [ACL]
└── Yes → Customer/Supplier [C/S]
└── Does upstream serve multiple consumers?
├── Yes → Add Open Host Service [OHS]
│ └── Needs contract? → Add Published Language [PL]
└── No → Basic C/S is sufficient
For detailed selection criteria: See references/pattern-selection.md
ContextMap <MapName> {
contains <Context1>
contains <Context2>
// Asymmetric: Downstream [D] <- Upstream [U]
<DownstreamContext> [D,<patterns>]<-[U,<patterns>] <UpstreamContext>
// Symmetric: Both sides equal
<Context1> [<patterns>]<->[<patterns>] <Context2>
}
| Symbol | Meaning |
|---|---|
[D] | Downstream context |
[U] | Upstream context |
<- | Asymmetric relationship (upstream to downstream) |
<-> | Symmetric relationship |
[D,C] | Downstream + Customer |
[U,S] | Upstream + Supplier |
[D,ACL] | Downstream with Anti-Corruption Layer |
[U,OHS,PL] | Upstream with Open Host Service + Published Language |
[SK] | Shared Kernel (symmetric) |
[P] | Partnership (symmetric) |
[CF] | Conformist |
For complete CML syntax: See references/cml-syntax.md
| Mode | Description | Use When |
|---|---|---|
full | Systematically analyze all bounded contexts | Comprehensive mapping, larger domains |
quick | Identify obvious relationships only | Quick overview, small domains |
guided | Interactive, confirm each relationship | Learning, validation, uncertain relationships |
/* Context Map: <DomainName>
* Generated: <date>
* Source: Event storming session
*/
ContextMap <DomainName>Map {
contains <Context1>
contains <Context2>
// ... relationships
}
graph LR
subgraph "Core Domain"
A[Context1]
end
subgraph "Supporting"
B[Context2]
end
A -->|pattern| B
## Integration Strategies
### <Context1> -> <Context2>
- **Pattern:** Customer/Supplier
- **Direction:** Context1 (upstream) supplies Context2 (downstream)
- **Rationale:** <why this pattern>
- **Implementation:** <technical approach>
- **Team Impact:** <organizational considerations>
Based on context relationships, suggest team boundaries following Team Topologies patterns (Stream-aligned, Platform, Enabling, Complicated Subsystem).
For team topology guidance: See references/team-topologies.md
Context mapping consumes:
Domain Storytelling
↓ (understand business flow)
Event Storming
↓ (discover bounded contexts)
Context Mapping ← YOU ARE HERE
↓ (define relationships)
Modular Architecture
↓ (implement structure)
Fitness Functions
(enforce boundaries)
When mapping contexts, identify:
For each pattern, there's a recommended technical implementation:
| Pattern | Implementation Strategy |
|---|---|
| Shared Kernel | Shared NuGet package, common project reference |
| Customer/Supplier | Internal API, MediatR notifications |
| Anti-Corruption Layer | Adapter pattern, translation service |
| Open Host Service | REST API, gRPC service |
| Published Language | OpenAPI spec, Protobuf definitions |
| Partnership | Shared event bus, bilateral contracts |
| Conformist | Direct model adoption, no translation |
| Separate Ways | No integration code needed |
For detailed implementation guidance: See references/integration-strategies.md
/* Context Map: E-Commerce Platform
* Generated: 2025-01-15
* Bounded Contexts from event storming session
*/
ContextMap ECommercePlatform {
contains OrderContext
contains InventoryContext
contains PaymentContext
contains ShippingContext
contains CustomerContext
/* Order consumes inventory availability
* Inventory owns stock truth, Order queries it
*/
OrderContext [D,C]<-[U,S] InventoryContext
/* Payment isolates external gateway
* Gateway has foreign model, needs translation
*/
PaymentContext [D,ACL]<-[U,OHS,PL] ExternalPaymentGateway
/* Order and Shipping co-evolve
* Both teams collaborate on fulfillment flow
*/
OrderContext [P]<->[P] ShippingContext
/* Customer data shared
* CustomerInfo value object used by multiple contexts
*/
OrderContext [SK]<->[SK] CustomerContext
ShippingContext [SK]<->[SK] CustomerContext
}
All outputs clearly distinguish recommendations from requirements and flag uncertain classifications for human review.
Last Updated: 2025-12-22 Model: claude-opus-4-5-20251101