Domain-Driven Design: Conformist—when to adapt your model to another Bounded Context's.
Learn when to adopt a provider's model without influence over its decisions. Explore an external catalog with TypeScript, validation, and errors, recognize semantic coupling, and decide when an ACL offers autonomy.
The indicator keeps the furthest percentage explored; marking the article complete is your choice.
Translation that adds no distinction
Sales queries an external catalog to display products before a purchase begins. The provider calls a publishable product ACTIVE and a withdrawn one RETIRED. Sales needs exactly that distinction for its commercial product page.
One developer proposes translating them to VISIBLE and HIDDEN, creating a local class, and maintaining an equivalence map. Another proposes directly using any JSON received.
There is a third decision: consciously adopt the provider's published model, validate incoming data, and document the dependency. That is the alternative we will explore.
It is not always appropriate. If Sales has its own publication rules, accepting external statuses may erase an important distinction. The task is recognizing when both meanings fit and what depending on the other model costs.
What Conformist means
In a Conformist relationship, the Downstream context adopts the Upstream model to simplify integration, accepting that it lacks sufficient influence to obtain a model designed around its own needs.
Evans presents the pattern for a relationship where the provider has no motivation to address the consumer's specific needs. The choice is to reduce translation by adopting its model, accepting the resulting limitation on autonomy. DDD Reference: Conformist, page 33 of the document.
In our hypothetical store:
External catalog [Upstream]
|
| published model: Product, ACTIVE, RETIRED
v
Sales [Downstream / Conformist for the queried offer]
The arrow expresses model dependency. It does not indicate who initiates HTTP.
Conformity concerns a specific scope. Sales can adopt catalog concepts for querying offers while retaining its own order rules. It does not have to turn its entire application into a provider copy.
Lacking influence does not require conformity
A consumer without influence can still maintain its own model and translate, seek another provider, or do without a capability. Conformist is a choice among alternatives, not an inevitable consequence of using an external API.
Nor does it depend on the provider being another company. Two internal teams can find themselves in that situation if their priorities and responsibilities do not allow negotiating changes.
A case where adopting the model may be reasonable
For this example, the catalog publishes this fictional representation:
ACTIVE allows presenting the offer in the commercial catalog.
RETIRED indicates that the offer has been withdrawn.
The price is expressed in EUR cents.
The information describes the current offer without guaranteeing stock or reserving a price for an order.
Sales cannot change those terms. For the queried product page, it considers them suitable.
The documented decision would be: use Product, ACTIVE, RETIRED, and the provider's price with their published meanings. We do not invent equivalent statuses that express no local difference.
That conformity does not authorize confirming orders with stale information. Accepting the price and purchase conditions belongs to Sales's commercial process, which is outside this query.
The difference between conscious conformity and accidental coupling
The caller receives any content, uses an unrestricted URL, and does not distinguish HTTP errors from valid products. If external codes then appear throughout the system, nobody knows whether they were chosen or simply propagated.
A conscious decision answers different questions:
Which provider meaning are we adopting?
In which part of Sales is it valid?
Who reviews catalog announcements and changes?
Which responses are valid and which must be rejected?
What future need would lead us to introduce our own model?
You can accept external vocabulary without losing those boundaries. You do not need to import Upstream's internal code or use its SDK as a universal model.
Representing the adopted contract in TypeScript
This type belongs to Sales and describes the subset of the external contract it uses. It is neither an entity imported from the provider nor a contract negotiated between them.
Although the interface is local, its concepts and rules follow the provider. Repeating a representation to verify it does not automatically create an ACL.
The difference is semantic: here, we do not translate into a different offer model. If the meaning of ACTIVE changed tomorrow, Sales would have to review its adoption.
Validating without inventing another model
A JSON response must be treated as unknown data. This parser checks what the chosen contract needs and returns only the fields used.
functionisRecord(value: unknown): value is Record<string, unknown> {
returntypeof value === "object" && value !== null &&
!Array.isArray(value);
}
exportfunctionparseCatalogProduct(raw: unknown,
expectedId: string,
): CatalogProduct {
if (!isRecord(raw) || raw.id !== expectedId) {
thrownewError("El catálogo respondió con otro producto");
}
if (
typeof raw.title !== "string" ||
raw.title.trim().length === 0 ||
raw.title.length > 200
) {
thrownewError("Título de catálogo inválido");
}
if (raw.status !== "ACTIVE" && raw.status !== "RETIRED") {
thrownewError("Estado de catálogo no soportado");
}
if (!isRecord(raw.price) || raw.price.currency !== "EUR") {
thrownewError("Moneda de catálogo no soportada");
}
const amount = raw.price.minorUnits;
if (
typeof amount !== "number" ||
!Number.isSafeInteger(amount) ||
amount < 0
) {
thrownewError("Importe de catálogo inválido");
}
return {
id: expectedId,
title: raw.title,
status: raw.status,
price: {
currency: "EUR",
minorUnits: amount,
},
};
}
We accept additional fields but do not retain them. We reject unknown statuses rather than treating them as active. The shown limits are explicit assumptions of the fictional catalog and the store's scope; they must be checked against a real provider.
Validating types and ranges does not check that the provider has maintained the price's meaning. That requires documentation, examples, and change review. A number can be structurally correct while representing another unit.
A constrained HTTP query
The three type, parser, and client snippets can be organized in a catalog-client.ts file. They are an instructional reading implementation; they do not implement orders, persistence, or payments.
The environment must provide fetch, URL, and AbortSignal.timeout, documented among Node.js's global APIs. Official Node.js documentation.
The origin comes from controlled administrative configuration and must correspond to the permitted provider. Checking HTTPS does not replace an authorized destination list if a user could choose the origin. That configuration must not be accepted from a public request.
The timeout is an example, not a universal recommendation. Network, timeout, and JSON failures must also be handled as errors at the boundary invoking the client; they do not become retired products or free offers.
The read does not follow redirects or reuse the HTTP client's cache. That does not promise absolute freshness: the provider may maintain its own caches, and the offer may change afterward.
Production also requires specifying authentication, response size limits, observability, and how to present a recoverable error. The received title is displayed as text, not trusted HTML. Conformist does not permit omitting security controls.
Using the adopted concept
Sales can decide whether to present the offer by directly using the external status:
The function does not translate ACTIVE into a different domain concept. It applies the published meaning within the scope where Sales chose to accept it.
Its name is deliberately narrow. canDisplayCatalogOffer does not mean “can be charged” or “units are available.” A catalog condition must not silently grow into authorization for every commercial operation.
Checks that protect the decision
These proposed tests use built-in Node.js APIs and assume TypeScript compilation to ESM JavaScript. They have not been run as part of this article.
import test from"node:test";
import assert from"node:assert/strict";
import {
parseCatalogProduct,
canDisplayCatalogOffer,
} from"./catalog-client.js";
functionproduct(status: unknown): unknown {
return {
id: "product-100",
title: "Mochila urbana",
status,
price: { currency: "EUR", minorUnits: 3500 },
};
}
test("adopta ACTIVE para presentar la oferta", () => {
const parsed = parseCatalogProduct(product("ACTIVE"), "product-100");
assert.equal(canDisplayCatalogOffer(parsed), true);
assert.equal(parsed.price.minorUnits, 3500);
});
test("una oferta RETIRED no se presenta", () => {
const parsed = parseCatalogProduct(product("RETIRED"), "product-100");
assert.equal(canDisplayCatalogOffer(parsed), false);
});
test("un estado nuevo no se interpreta automáticamente como activo", () => {
assert.throws(() =>parseCatalogProduct(product("PREVIEW"), "product-100"),
);
});
test("rechaza una respuesta que cambia la unidad por una cadena", () => {
assert.throws(() =>parseCatalogProduct({
id: "product-100",
title: "Mochila urbana",
status: "ACTIVE",
price: { currency: "EUR", minorUnits: "35.00" },
}, "product-100"));
});
These checks make Sales's interpretation visible. They do not guarantee provider compatibility or the continued validity of its rules. Nor do they replace HTTP client tests for 404, network errors, and invalid responses.
Their value for Conformist is making explicit a dependency that could otherwise remain hidden behind an interface.
How an external change propagates
Imagine the provider introduces PREVIEW: an offer visible only to certain buyers.
Our parser rejects it. That avoids displaying it with an invented interpretation, but also means the query cannot be used until that status is reviewed. Rejecting safely still has an availability and maintenance cost.
The team must determine:
What the status means and which operations it permits.
Whether Sales can continue adopting that distinction.
Which local consumers use the type and its statuses.
How to update examples, validation, and behavior.
Whether the new need justifies moving to its own translation.
A name change affects references. A semantic change can affect decisions even without changing the schema.
For example, the provider might retain minorUnits: 3500 but switch from a final price to a pre-tax price. The parser would not detect the difference. Sales would need to review the documented agreement it chose to adopt.
Historical prices must not depend on the current query
A current offer can change. If Sales stores an order, it must retain the accepted terms according to its own rules. Querying tomorrow's catalog to reconstruct the amount charged yesterday confuses two responsibilities.
Adopting the offer model does not require using it as the order's historical model. This distinction keeps Conformist constrained and prevents the provider's decisions from pulling in the whole business.
When an ACL starts adding value
Now suppose Sales has its own policy: an offer may be displayed but requires commercial review before purchasing is enabled. The provider offers only ACTIVE and RETIRED.
Renaming ACTIVE to APPROVED_FOR_SALE would be dangerous: the provider never made that promise.
An alternative is defining a more precise local representation:
This is only the beginning of a translation. Sales would decide commercial approval separately; the function neither invents it nor queries a system we have not shown.
A complete ACL should protect the local model and centralize how the interaction is interpreted. It does not appear by wrapping fetch in a class: our Conformist client already does that and still adopts the external model.
The decisive comparison is:
Conformist: we accept the provider's concepts because they fit this scope.
ACL: we preserve our own concepts and translate what collaboration requires.
A purely cosmetic translation may add work without real autonomy. A translation expressing a business difference can justify its cost.
Which benefits and costs you are accepting
Less initial translation. Reusing external language avoids equivalences that only change names. The provider's documentation is directly useful to the consumer team.
More semantic dependency. When the provider changes its concepts, the consumer must review the decisions that adopted them.
Less evolutionary autonomy. Sales may need adaptation work to keep using a capability whose schedule it does not control.
Potentially greater replacement cost. Switching catalogs requires reviewing where its identifiers, statuses, and rules were adopted. Localizing HTTP access helps but does not eliminate that semantic adoption.
Imperfect fit. The external model may be enough for a simple product page and unsuitable for richer commercial rules. Accepting it today does not mean accepting it indefinitely.
You do not need an ACL on principle. Nor should Conformist be presented as free integration: it removes part of the translation, not maintenance, validation, or dependency risk.
A record for remembering the decision
For the example store:
Relationship: external catalog Upstream; Sales Downstream. Influence: Sales cannot negotiate provider-specific changes. Adopted scope: querying and presenting current offers. Concepts: Product, ACTIVE, RETIRED, and price in EUR cents. Local responsibility: validation, errors, and terms accepted in orders. Excluded: interpreting the status as a stock guarantee or payment authorization. Review: new statuses, monetary changes, or the emergence of local commercial policies.
Assign a person or team to review provider announcements. If you do not know who handles changes, initial savings can end in failures nobody recognizes as their responsibility.
Do not confuse a pinned SDK version with remote model stability. The server can change even if the local package is not updated.
Differences from the previous patterns
Customer/Supplier incorporates Downstream needs into Upstream planning. Conformist does not assume that negotiating ability.
Shared Kernel involves part of a model shared with coordinated evolution. Unilaterally consuming a third party's published model is not equivalent to governing it jointly.
Anti-Corruption Layer maintains a local interpretation through translation. Conformist avoids that difference when the external model is acceptable.
Do not describe the whole company with a single label. Sales can adopt the catalog and protect itself through an ACL against another system with incompatible vocabulary.
Two decisions outside e-commerce
Logistics: displaying published tracking
An informational page reproduces a shipment's status according to the carrier. If its need is to display what the provider declares, adopting its statuses may be pragmatic.
If customer support starts deciding compensation, it must review that choice. A carrier's “incident” does not necessarily mean “confirmed loss” under the store's policy.
The same external source can serve two consumers with different architectural decisions.
Education: an external category is not accreditation
A portal aggregates courses from another platform. For catalog exploration, it can adopt its categories and levels.
An academic system granting course credit has other responsibilities. The provider's “advanced” level does not demonstrate curricular equivalence. Maintaining its own model and translating may be necessary.
Here, matching names does not replace the evidence the academic decision requires. A descriptive page and an institutional assessment need not share a model.
Preventing AI from extending conformity without permission
Cursor, Claude, or Codex can reproduce external DTOs throughout the code because they seem a convenient source of types. Provide the decision's scope, not just API documentation.
Three specific prompts:
To evaluate adoption:
Compare our presentation needs with this external catalog. Identify which meanings we can adopt and which require local rules. Do not assume influence over the provider. Provide costs, limits, and conditions for reviewing Conformist.
To implement the client:
Implement an HTTP read with an administratively managed origin, timeout, and validation of unknown data. Preserve ACTIVE and RETIRED according to the documentation. Reject unknown statuses and distinguish 404 from technical failure. Do not use those statuses to authorize orders, reservations, or payments.
To review a change:
The provider added PREVIEW and changed the price definition. Look for decisions affected by types and meaning, not only compilation errors. Propose the smallest adaptation or justify introducing a local translation. Distinguish documented facts from outstanding questions.
A person must confirm that the external meaning remains suitable. Compiling generated code does not demonstrate that the commercial decision is correct.
Exercises for deciding scope
1. The rename that promises too much
Sales translates ACTIVE to READY_TO_CHARGE. The provider promises only publication. Has the local model been protected?
2. The unknown status
The catalog adds RESTRICTED. A developer proposes accepting any string and displaying every product except RETIRED. What risk does that introduce?
3. The changing need
Sales starts approving offers through a local review independent of the catalog. Must it abandon the entire integration?
Reasoned solutions
1. No. The rename introduces a payment guarantee absent from the contract. Preserve the publication meaning and separately model the decisions required for charging.
2. A new status might mean the offer cannot be displayed to that user. The proposal turns lack of knowledge into authorization. Its semantics must be reviewed and the local response explicitly decided, without interpreting a failure as a valid product.
3. Not necessarily. It can retain catalog access and adopt a local approval model. A translation can separate external presentation from commercial decision without rewriting capabilities that remain useful.
Choosing conformity with a verifiable boundary
Conformist can be reasonable if the external model fits sufficiently, you cannot influence it, and maintaining another meaning offers no proportionate benefit.
Check that you can explain what you adopt, where adoption ends, and who will review its changes. If you need to continually reinterpret statuses or complete rules the provider does not know, reassess the decision.
Conscious conformity reduces unnecessary translation. Its value depends on accepting the dependency thoughtfully and recognizing when it stops being appropriate.
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.