Subdomains & Bounded Contexts

Lesson 6 of the DDD course · Strategic design: where models are valid, and where your edge actually is · ~25 minutes

1 · Value objects 2 · Entities & identity 3 · Aggregates 4 · Lifecycle state machines 5 · Domain events 6 · Bounded contexts 7 · Context mapping 8 · Functional core 9 · Capstone
Why this matters for your mission Startups don't die from one bad aggregate — they die from one shared model stretched over a growing company. Today you learn where your model's boundaries are, so each part of Meridian can grow at its own pace without a coordination tax on every change.

Lessons 1–5 were tactical: patterns inside one model. The rest of DDD is strategic: how many models, where they start and stop, and who translates between them. This lesson gives you the two strategic nouns.

1 · Two different questions

SubdomainBounded context
QuestionWhere does the business problem live?Where does a specific model work?
Spaceproblem space — the businesssolution space — your code
Meridian examplesmerchandising, ordering, payment processingCatalog module, Ordering module, Billing module

A subdomain is a part of the business itself — it exists whether or not you write software. A bounded context is the region of your code where one particular model — with one ubiquitous language — is valid.[Evans] They rhyme but don't map 1:1: one subdomain might be served by two evolving contexts; one context might serve two.

2 · Subdomains come in three kinds

Khononov's classification tells you where to spend your scarcest resource — attention:[Khononov]

The investment rule Core domain: your best thinking. Supporting: deliberately simple. Generic: somebody else's product. Misclassifying is expensive in both directions — hand-rolling payments (generic as core) or outsourcing your differentiator (core as generic).

3 · Same word, different models

The deep reason contexts exist: “product” is not one concept. Listen to how each Meridian team uses the word:

Context“Product” means…Model cares about
Cataloga thing to browse and fall in love withtitle, photos, description, SEO
Orderinga purchasable snapshot on a linesku, unit price, availability flag
Shippinga box's contentsweight, dimensions, hazmat class

Forcing one Product type to serve all three gives you a type with thirteen optional fields where every consumer uses three — the illegal-state problem again, but organizational. The DDD answer: each context gets its own Product, speaking its own language. Translation happens where contexts meet (next lesson).

4 · Contexts in a codebase, concretely

src/
  catalog/        # its own model, its own language
    types.ts       # CatalogProduct: title, photos, …
  ordering/       # lessons 1–5 live here
    types.ts       # Order, OrderLine, OrderEvent…
    transitions.ts
  billing/
    types.ts       # PaymentCaptured, Invoice…
  shared/
    result.ts      # Result, err — infrastructure, not domain language
Gotchas (1) Contexts are discovered, not invented: start with one context; split when two teams' languages visibly diverge, not before. (2) A shared “common types” module that slowly accretes domain types is a distributed shared model wearing a disguise — keep it truly generic (Result, ids, clocks). (3) If a word needs a meeting to define, you've found a context boundary: the word means different things to different groups.

5 · Retrieval check

6 · Where this goes next

You can now draw Meridian's map: Catalog, Ordering, Billing, Shipping — each with its own language. But they must talk: orders need payment confirmations, shipping needs weights. Next lesson: context mapping — the translation patterns between contexts, including the anti-corruption layer for the payment provider you'll never control.

Your teacher is the agent The high-leverage question for your actual product: “what's my core domain?” Bring me your candidate answer and the reasoning — I'll push on it, because everything you choose to build vs. buy should hang off that classification.
Primary source for this lesson Read Khononov's *Learning Domain-Driven Design*, the strategic-design chapters (subdomains, bounded contexts) — it's the cleanest modern treatment. Evans' original context-mapping discussion is in the Blue Book if you want the source.
← Lesson 5: Domain events Glossary →