Learn TypeScript w/ Mike North

Bounded contexts

June 10, 2025

Table of Contents

What’s a bounded context

Bounded contexts encapsulate specific concepts, terminology, and rules relevant to a subset of the business domain, ensuring internal consistency. Different bounded contexts communicate through well-defined interfaces, minimizing confusion and ambiguity across the system.

We have a need for this in our workshop project! There’s a fancy UI for dragging and dropping plants into raised beds, just waiting for us to hook some data up to Drag and drop raised bed planning UI

We have an existing domain model that lives in our UI bounded context diagram

This has nothing to do with gardening! Our UI entirely deals in a world of

  • A Workspace which consists of multiple Zones
  • Zones have a grid where ItemPlacements are arranged
  • Each ItemPlacement relates to an Item

We’re about to create a gardening-related bounded context of our own, and there’s going to be some messy code we’ll have to write to adapt between the two

Anti-corruption layers

Anti-corruption layers in DDD are effectively well-contained adapters a bounded contexts and other models or external systems. We have the beginnings of one in our server’s routing layer. For example,

  • packages/server/src/application/plants-router.ts adapts between our Plant entity and the HTTP response then endpoint needs to return
  • packages/server/src/application/seed-packets-router.ts adapts between our SeedPacket entity and a different HTTP response.

Anti-corruption layers help keep our domain services (e.g. packages/server/src/services/plants-service.ts) clean and simple. They’ll be easy to unit test in isolation, and they deal exclusively in the entities that they’re associated with.



© 2025 All Rights Reserved