Course contentsShow
← Cloud and Infrastructure
Lesson 2559 of 2,98955. Microservices on CloudFree lesson

Domain-Driven Design Basics

Bounded contexts, ubiquitous language, and aggregates for defining service boundaries.

Domain-Driven Design Basics

What you'll learn: How Domain-Driven Design principles help you draw clear, logical boundaries between microservices.

When building microservices, one of the hardest questions is: "Where does one service end and another begin?" Domain-Driven Design (DDD) provides a strategic approach to answer this by organizing services around business domains rather than technical layers.

Bounded Contexts

A bounded context is a clear boundary within which a particular domain model is valid. Think of it like departments in a company—"Customer" means something different in Sales (lead, contact info) versus Shipping (delivery address, preferences). Each bounded context becomes a natural candidate for a separate microservice.

In practice, a bounded context defines what data and logic belong together. If two teams can work independently on different contexts without constant coordination, you've drawn good boundaries.

Ubiquitous Language

Within each bounded context, the team uses a ubiquitous language—a shared vocabulary that developers, domain experts, and stakeholders all speak. If the business calls it an "Order," your code should too, not "Transaction" or "Purchase." This consistency eliminates translation errors and keeps your service models aligned with business reality.

Aggregates

An aggregate is a cluster of domain objects treated as a single unit for data changes. For example, an Order aggregate might include OrderLines and a ShippingAddress. The Order is the aggregate root—all changes go through it, ensuring consistency. Aggregates help define transaction boundaries: what must stay consistent together should be in one aggregate, and typically one microservice.

When you map aggregates to services, you naturally achieve loose coupling. Services own their aggregates and communicate through well-defined interfaces (events, APIs), not by sharing databases.

Key Takeaway:
DDD's bounded contexts, ubiquitous language, and aggregates provide a business-aligned framework for defining microservice boundaries—ensuring each service has clear ownership, consistent terminology, and minimal coupling.