Domain-Driven Design: Partnership—how to collaborate across Bounded Contexts with shared objectives and responsibilities.
Learn to coordinate Sales and Payments when delivery depends on both succeeding. Define responsibilities and contracts, design joint tests, and plan compatible changes without merging models or assuming shared transactions.
The indicator keeps the furthest percentage explored; marking the article complete is your choice.
Two finished deliveries that still do not let you sell
Sales finishes the confirmation screen. Payments finishes the integration with the test gateway. Each team demonstrates its part, but the purchase does not work end to end: Sales interprets “authorized” as “paid,” and Payments does not know which reference it must return to identify the order.
Both can have correct code under their own assumptions and still fail at the joint delivery.
The Partnership pattern organizes a relationship in which teams need to collaborate to achieve an outcome neither can deliver alone. It does not define how to send HTTP requests or which broker to install. It defines how to coordinate decisions, commitments, and integration without merging the models.
We will work with a hypothetical store: Sales and Payments want to enable a purchase whose order is confirmed after payment collection has been verified. The examples are limited to contracts and reading results; they do not process real payments.
What makes a Partnership exist
Evans describes Partnership when development failure in either context jeopardizes both teams' delivery. The teams coordinate planning, interface evolution, and integration to achieve the shared outcome. DDD Reference: Partnership, page 30 of the document.
The dependency concerns success, not just traffic:
Payments needs Sales to provide a stable reference and correct payment terms for the agreed capability.
Sales needs Payments to make the result available and associate it with the correct order.
The business feature is not finished if only one of those parts works.
Making two calls in opposite directions does not demonstrate Partnership. An integration can have bidirectional requests and notifications while maintaining an asymmetric organizational relationship.
Nor does it imply absolute equality in budget or authority. It requires the responsible people to be able to commit, resolve obstacles together, and address both sides' needs within the chosen scope.
Representing the relationship without drawing infrastructure
[ Sales ] <========== Partnership ==========> [ Payments ]
Objective: purchase with verified payment
Joint planning and acceptance
Sales retains the order model.
Payments retains the payment model.
The double line represents mutual collaboration and dependency on success. It does not mean shared memory, a synchronous call, or a distributed transaction.
We can accompany it with one contract for requesting a payment and another for querying its result. Each technical interaction will have a provider and a consumer, even though the strategic agreement between the teams is a Partnership.
Defining a shared outcome and separate responsibilities
“Integrate payments” is too broad. For this first capability, we propose:
A purchase can display a confirmed order when Sales verifies a captured payment result matching the expected order, amount, and currency. Pending or unknown results are not presented as confirmation.
This is the example's policy. Other stores may confirm orders with an authorization and capture later. The choice must be explicit; it cannot be inferred from a gateway status named SUCCESS.
Sales decides the commercial terms, expected amount, and what confirming its order means.
Payments decides how to represent and interpret the financial results obtained from its provider. It does not delegate gateway adaptation to Sales.
Both agree on references, public statuses, errors, and acceptance examples. They also decide what happens when a response arrives late, is missing, or contradicts the expected data.
Sharing an objective does not mean anyone can update the other context's tables. Keeping ownership clear helps resolve problems without creating undefined collective responsibility.
Planning a capability that can integrate early
Instead of finishing all of Payments and connecting Sales at the end, the teams can agree on an initial sequence:
Write examples of the order, amount, and accepted result.
Define the minimum public representation and its errors.
Test reading in Sales with controlled responses.
Connect to Payments in an isolated test environment.
Walk through a captured case, a pending case, and a failed case together.
Enable the capability when both sides meet the criteria.
This is a proposed plan, not a statement about a real team's deliveries. Owners and dates must be assigned according to their capacity.
If a blocker appears, its effect on the joint feature is assessed. Payments cannot declare an unusable interface finished; Sales cannot impose a solution the provider cannot sustain either.
A short meeting to resolve an ambiguity may be enough. Partnership does not require turning every internal adjustment into a committee.
Explicit contracts without shared entities
To identify a payment intention, the teams could agree on this input DTO:
This is a contract snippet, not an executable operation. amountMinor expresses EUR cents; attemptId identifies the logical attempt according to the agreed rules. The provider must define how it handles repetitions and discrepancies. Including an identifier does not automatically implement that protection.
PENDING: there is not yet a final result that allows confirmation.
CAPTURED: Payments declares the amount captured for that attempt.
DECLINED: the attempt has been declined.
We do not add an AUTHORIZED status to interpret intuitively. If it is needed, its meaning and its effect on the process must be discussed.
The contract is a public representation, not a serialization of the Payments aggregate. Sales does not need to know credentials, internal gateway identifiers, or its complete transaction model.
A TypeScript interface does not validate network data either. Both sides must check their inputs, and the consumer must treat the external response as unknown before translating it.
A decision snippet in Sales
Sales defines a local query port. Its HTTP adapter validates the contract and translates it into this consumer result; it does not import internal Payments entities.
This block is self-contained as an instructional decision and requires no framework. It assumes that the adapter implements runtime validation of PaymentEvidence, including types, identifiers, and numeric ranges.
ready-to-confirm does not change an order or record a payment. A real Sales use case would need to apply and persist the transition allowed by its model, accounting for concurrency, repetitions, and previously processed results. Those pieces are omitted to focus on the collaboration agreement.
The function does not reserve an amount or stock either. Testing the shared outcome requires walking through more than this snippet.
Why collaboration does not create a common transaction
Payments may have recorded a payment and Sales may fail before persisting the confirmation. A response can be lost even though the financial operation occurred.
Therefore:
A timeout does not automatically mean no payment was collected.
A local failure does not undo remote state.
Repeating a payment request without knowing its contract may produce an unwanted effect.
Rolling back a code version does not reverse financial operations.
The teams must agree on how to identify the attempt and how to query and resolve pending situations. Here we do not implement that process or introduce a distributed coordination architecture.
Shared responsibility means recognizing and assigning those situations, not claiming that working together makes them disappear.
This caution also applies to a modular monolith when integration uses HTTP with separate contracts. A shared transaction must not be assumed simply because both contexts are on the same server.
Joint tests with identifiable responsibilities
A focused strategy can have three levels.
Local tests: Sales verifies how it interprets results; Payments verifies its rules and its translation of the financial provider.
Contract tests: check that public requests and responses satisfy both sides' expectations.
Workflow integration tests: connect real implementations in a controlled environment and verify the agreed outcome. They can use a test gateway, never real charges for this exercise.
It is not enough for both sides to maintain different mocks that resemble the contract. Expectations must be checked against verifiable implementations.
A local test identifying a Sales rule
This example complements the previous file, assumed to be confirmation.ts, and uses built-in Node.js APIs. It assumes TypeScript compilation to ESM JavaScript. It is a proposed test; it has not been run as part of this article.
These tests show two local expectations. They do not test Sales persistence or that Payments publishes the same contract.
A shared integration specification
To test the workflow without incidental infrastructure, we can express a test harness. Its functions must connect to real HTTP adapters and isolated scenario setup.
This is an executable specification once the harness is implemented, not a complete integration test ready to run. That harness is not provided, and no claim is made that it has been executed.
prepareScenario must prepare Sales and Payments with consistent identifiers, amount, and currency in a test database or isolated environment. runSalesConfirmation must invoke the real Sales workflow, which uses the Payments integration and persists its result. It must not directly simulate the expected confirmation.
The harness belongs to the testing scope. It is not a production administrative back door or permission to access another context's tables from business code.
The teams must add scenarios for declines, incorrect references, invalid responses, and lost communication. Responsibility for each failure may be local, but its effect on delivery is assessed jointly.
Evolving together without deploying everything at once
Suppose a new payment method appears: some operations require additional action from the buyer. The initial contract does not distinguish that situation from a simple pending result.
Publishing ACTION_REQUIRED without coordination would break a consumer that rejects unknown statuses. Automatically treating it as captured would be worse.
The teams can design a compatible evolution:
Agree on the new status, expected action, and its presentation in Sales.
Prepare a contract version that distinguishes it.
Have Payments support the previous version while the new one has not been enabled for migrated consumers.
Update the adapter and the Sales experience.
Test both workflows.
Activate the capability for the new version when the parties are ready.
Retire the previous version only after verifying its consumers' migration.
If the previous contract defines PENDING simply as “there is no final result,” Payments can keep using it in that version while Sales does not yet offer the interactive experience. If that semantics does not fit, the new payment method must remain disabled for that consumer; a false equivalence must not be forced.
This requires planning compatibility and activation. Completing a feature in coordination does not require deploying the binaries at the same instant. The specific order depends on how versions coexist and when the new behavior is enabled.
Adding an “optional” field is not enough either: if the new process works only when the consumer uses it, there is a capability dependency even if the JSON remains valid.
Documenting what both sides can sustain
A Partnership description can record:
Shared objective: enable sales confirmation with valid payment evidence. Sales: order terms, commercial decision, and persistence of its state. Payments: financial interpretation and attempt lookup. Integration: contracts, consumer HTTP translations, and agreed scenarios. Delivery: owners, acceptance criteria, and enablement sequence. Failures: who investigates payments without confirmation and how they are tracked. Review: changes to statuses, amounts, references, or guarantees.
Dates and commitments are filled in through real agreements. They cannot be inferred from the diagram.
A brief decision note can explain why Partnership was chosen, what its scope is, and which conditions would change it. Every contract does not need to become a lengthy document.
If every Sales change requires reviewing Payments, ask whether coordination has expanded too far. The shared objective is specific; it should not absorb all independent work.
When Partnership is not the right description
Customer/Supplier: there is usually a dominant direction of dependency and a supplier that incorporates consumer needs into its planning. Excellent collaboration can exist without the mutual dependency on success that justifies Partnership.
Shared Kernel: part of the model and its evolution is shared. Sales and Payments can be partners without sharing classes or an entity library.
Conformist: the consumer adopts the external model without sufficient influence over its evolution. It does not describe joint planning between owners who can make commitments.
A commercial gateway does not become a development partner because Payments consumes its API. Partnership can exist between Sales and Payments while Payments maintains another relationship with its external provider.
Two situations that help evaluate the pattern
Education: enrollment and place allocation
Enrollment and academic planning jointly launch a new enrollment method with places per group. Each side needs new capabilities from the other for the feature to be delivered.
If both teams can plan and verify the workflow together, Partnership may be appropriate. If one merely provides a stable query used by many consumers and does not depend on that delivery, an asymmetric relationship may describe the situation better.
The lesson is to examine the capability's dependency on success, not the number of calls.
Reservations: avoiding unnecessary coordination
A reservation application uses an external tool to send informational emails. If the provider does not participate in its planning, labeling the integration Partnership hides the lack of influence.
For a first version, even displaying an on-screen confirmation and adding notifications later may be enough, if the business accepts that scope. The simpler option reduces a dependency that is unnecessary for the initial delivery.
A communication failure between teams is not automatically resolved by adding meetings. Sometimes the shared scope must be reduced or the boundaries revisited.
Giving AI agreements, not just diagrams
For Cursor, Claude, or Codex, combine the Context Map with responsibilities, examples, and delivery limits.
To analyze the relationship:
Analyze these Sales and Payments dependencies for this feature. Distinguish technical dependency from dependency on success. Justify Partnership or an asymmetric relationship. Identify missing commitments without inventing agreements or dates.
To implement one part:
Work only in Sales. Consume payment evidence through a local port and an HTTP ACL with a consumer contract. Do not import Payments aggregates or repositories. CAPTURED must match the attempt, order, amount, and currency. A timeout does not prove that no payment was collected.
To review evolution:
With this current contract and this new capability, propose a compatible order for delivery, deployment, and activation. Identify version combinations that fail, joint scenarios, and responsibilities. Do not assume a common transaction or automatic reversal of the payment.
A person must verify that every commitment is possible and accepted. AI can point out contradictions; it cannot decide on another team's behalf that a delivery has been committed.
Exercises
1. Two calls, one dominant dependency
Sales queries a stable Payments API and receives notifications. Payments does not need any new Sales capability for its own delivery. Is bidirectional communication enough to claim Partnership?
2. The new status
Payments wants to return ACTION_REQUIRED to the old consumer without changing its parser because “it is similar to pending.” What would you review?
3. The rollback deployment
Payments records the payment, Sales fails, and the team proposes rolling back the deployment to undo the operation. Which assumption is incorrect?
Reasoned solutions
1. No. Transport in both directions does not demonstrate a mutual dependency on success. I would review objectives, commitments, and the real ability to plan together; an asymmetric relationship may be more accurate.
2. I would review semantics, compatibility, and the experience needed in Sales. The old consumer may reject the new value or fail to offer the required action. Versions, enablement, and scenarios must be agreed before activating it.
3. Rolling back code does not reverse remote financial state. The responsible people must query the evidence and resolve the case according to explicit agreements. Partnership requires assigning that problem; it does not provide an automatic transaction.
Collaborating without erasing boundaries
Partnership adds value when a capability requires two teams to achieve an outcome together and both can commit to that collaboration.
Check that the objective is verifiable, that every responsibility has an owner, and that versions can integrate without hidden assumptions. If coordination spills into every local change, reduce the scope or revisit the relationship.
The agreement makes a common delivery possible. The models retain their boundaries, and technical guarantees still require explicit design.
Integrate the collection by building an order API with TypeScript, Express, Zod, and SQLite. Includes project files, domain rules, events, version control, Vitest tests, and commands to run and verify it locally.
Learn to guide AI agents with business rules, context boundaries, and verifiable criteria. A TypeScript case shows how to prepare instructions, protect Order, design tests, and review changes without delegating architectural judgment.
Compare a modular monolith with separating Sales, Payments, and Inventory. Design contracts in TypeScript and Express and understand partial failures, eventual consistency, idempotency, Outbox, and Sagas without introducing complex infrastructure.