DDD Essentials: Ubiquitous Language, Bounded Context, Context Map
Align code and domain experts using Ubiquitous Language, isolate models inside Bounded Contexts, and document integration boundaries with a Context Map.
TL;DR
Strategic DDD prevents big-ball-of-mud models: Ubiquitous Language keeps code and business terms identical, Bounded Contexts give each subdomain its own clean model (so Order in Checkout ≠ Order in Shipping), and a Context Map makes integration contracts explicit.
Why it exists
When an e-commerce team puts one Order table and one Order class at the center of Checkout, Billing, and Warehouse Shipping, every team adds columns they need (trackingNumber, taxRate, refundReason). Soon, changing a shipping rule breaks invoicing, and nobody agrees on what "Order completed" means.
Mental model
Strategic DDD draws linguistic boundaries first, before choosing databases or microservices:
- Ubiquitous Language: if the warehouse team says "Pick Ticket" and "Shipment", the code uses
PickTicketandShipment—notOrderDtoV2. - Bounded Context: the explicit boundary within which a particular model and language apply.
- Context Map: shows how contexts interact—using an Anti-Corruption Layer (ACL) when protecting a clean domain from a messy legacy API, or a Published Language (shared event schema) between peers.
Do it
You don't need separate microservices to apply Bounded Contexts—start with separate folders/modules and explicit DTO translation at boundaries:
// Verified pattern in TypeScript 7.0.2
// --- Billing Context: translates Checkout's event into Billing's own language ---
export interface CheckoutOrderPlacedEvent {
orderId: string;
customerId: string;
totalCents: number;
}
export interface InvoiceDraft {
invoiceId: string;
accountId: string;
amountDueCents: number;
}
// Anti-Corruption / translation function at the Billing boundary
export function toInvoiceDraft(event: CheckoutOrderPlacedEvent): InvoiceDraft {
return {
invoiceId: `inv_${event.orderId}`,
accountId: event.customerId,
amountDueCents: event.totalCents,
};
}Gotchas
- 1 Bounded Context ≠ 1 Microservice: you can run three Bounded Contexts inside one modular monolith process and still get 90% of the design benefit without network latency.
- Shared Database across contexts: letting Shipping read Checkout's internal tables bypasses the context boundary and re-couples both teams.
- Vocabulary drift: if engineers say
Userin code while support saysSubscriberand billing saysAccount, bugs happen in requirements before a line of code is written.
Production checklist
- Define a glossary for each Bounded Context and rename ambiguous classes to match it
- Keep separate domain models per context—never share ORM entities across context boundaries
- Document upstream/downstream relationships in a lightweight Context Map
- Place an Anti-Corruption Layer in front of third-party or legacy APIs
Check yourself
Check Yourself
1. Why should the Shipping context and Billing context each have their own Order/Shipment model instead of sharing one Order class?
2. You are integrating a new TypeScript domain with a messy legacy ERP whose status codes are 'X1', 'Z9'. Which Context Map pattern protects your domain?
Sources
Related Notes
Monolith vs Modular Monolith vs Microservices
Weigh the honest costs of distributed systems, team topology (Conway's Law), and why starting with a modular monolith is the default choice.
DDD Tactical Patterns: Entities, Value Objects, Aggregates
Model rich domain rules using Entities, Value Objects, Aggregates, Repositories, and Domain Events on the shared Order service.