Grokking Microservices for System Design Interviews

0% completed

Bounded Contexts in Plain Words

  1. The Problem: One Word, Many Meanings
  1. The Definition
  1. Why This Is the Microservices Lesson That Matters Most
  1. In the Interview
  1. TL;DR

1. The Problem: One Word, Many Meanings

Ask four teams at an e-commerce company what a "product" is. You will get four different answers.

  • To the catalog team, a product is a title, a description, images, and a price to display.
  • To the inventory team, a product is a stock count per warehouse and a reorder threshold.
  • To the shipping team, a product is a weight, dimensions, and a hazardous-materials flag.
  • To the reviews team, a product is an average rating and a list of customer comments.

Now watch what happens in a system designed without boundaries. Someone builds one Product class to serve everyone. It accumulates 40 fields.

Four teams edit it. Every change risks breaking someone else's feature. Soon no team can say what a valid product is anymore.

The same thing happens to User, Order, and Account. A class like this is called a god object, meaning one class that tries to model everything for everyone.

God objects are the deep reason large codebases become hard to change. The tangled code is the symptom. The shared model is the cause.

Four teams, one class. Every edit to the shared model is a risk for everyone else.
Four teams, one class. Every edit to the shared model is a risk for everyone else.

2. The Definition

A bounded context is a boundary inside which a given term has exactly one meaning, and the model built around that meaning stays consistent. Inside the inventory context, "product" means stock levels, full stop. The shipping context has its own "product" that means weight and dimensions. The two definitions never need to be merged into one class, because a boundary separates them.

The idea comes from domain-driven design (DDD), a way of designing software that shapes the code around the business's own concepts and words. The bounded context comes with a companion idea. Within one context, the team, the code, and the domain experts all use the same words for the same things, and DDD calls that shared vocabulary ubiquitous language.

You do not need deep DDD theory for interviews. You need the core move. Instead of forcing one shared model on the whole company, deliberately allow each context its own model, and be explicit about where the contexts meet.

Where they meet, contexts translate. When an order is placed, the checkout context might publish an event, a small message that says something happened, for other contexts to react to. The event carries a product ID and a quantity.

The shipping context receives it and looks up the weight and dimensions in its own data. Neither context imports the other's model. Each maintains its own view, keyed by a shared identifier (the product ID both sides agree on).

Think of a context boundary like a function's public signature. Callers see only the ID and the events. The model behind the boundary stays private, like the function body.

One word, three models, on purpose. Each context keeps the "product" it needs; the contexts meet only at the shared identifier.
One word, three models, on purpose. Each context keeps the "product" it needs; the contexts meet only at the shared identifier.

The handoff between contexts looks like this when an order actually moves through the system.

The translation at the seam. Shipping never imports the checkout model. It builds its own view from the ID.
The translation at the seam. Shipping never imports the checkout model. It builds its own view from the ID.

3. Why This Is the Microservices Lesson That Matters Most

Here is the connection to this course: a bounded context is the natural candidate for a service boundary. Each context has its own model, its own data, and its own reasons to change. That is exactly the list of things a microservice should own. Find the contexts and you have found your services. When people say "decompose along business capabilities" or "use DDD to find your services," this is the whole of what they mean.

The reverse direction is the practical test. If a proposed service does not line up with a bounded context, the misalignment shows up as symptoms you can predict:

  • A service that contains parts of two contexts changes for two unrelated sets of reasons. Two teams end up coordinating every release. The split bought nothing.
  • A single context spread across two services means one meaning of "product" now lives in two databases that must be kept in sync. Every write to one must be copied to the other. Simple changes now require two deployments in the right order. This is how distributed monoliths begin.

One caution for design rounds: context boundaries follow the business, not the data model. Entities like "user" appear in many contexts, and that is normal.

  • The account context owns credentials.
  • The profile context owns display names.
  • The billing context owns payment methods.

All three reference the same user ID. The wrong conclusion is "there should be one User service that owns everything about users." That trap has its own lesson.

4. In the Interview

The term arrives in two ways. The first is the direct definition question ("What is a bounded context?"). The second is silent. It hides inside every "how would you split this system?" question, where using the concept correctly is worth more than defining it.

The 30-second answer: "A bounded context is a boundary within which a term has one consistent meaning and one model. In an e-commerce system, 'product' means display data to the catalog, stock counts to inventory, and weight to shipping. Rather than one shared Product model serving everyone, each context keeps its own model, and contexts share only identifiers and events. It matters for microservices because a bounded context is the natural service boundary: its own model, its own data, its own reasons to change."

Likely follow-ups:

  1. "How do you find the bounded contexts in a domain?" Listen for where the language changes. When the same word means different things to different people, or different words mean the same thing, you have crossed a context boundary. Organizationally, contexts tend to follow business functions. The people who talk to each other daily share a context.
  2. "Two contexts both need product data. Do they share a database?" No. Each keeps its own representation, and they synchronize through events or lookups by ID. That answer opens the consistency topic, covered in depth by a later lesson on data ownership.

💡 In a design round, name the boundary out loud as you draw it: "I am splitting here because product means display data on one side and stock counts on the other." Justifying a boundary with the language test marks you as senior. Drawing boxes does not.

A red flag that fails candidates: proposing one official model for a core entity, shared by all services ("we'll have a central Product service every other service reads from"). This recreates the god object with a network around it. It also turns one team into the bottleneck for every other team's changes.

5. TL;DR

DefinitionA boundary inside which each term has exactly one meaning and one model.
The moveAllow each context its own model; share only IDs and events at the seams.
Why it matters hereBounded context = natural service boundary: own model, own data, own reasons to change.
Finding themFollow the language: where a word's meaning shifts, a boundary lives.
Red flagOne canonical shared model (or central entity service) for the whole company.
Flashcards Review

What is a bounded context?

1 / 20
General
Test Your Knowledge
Check your understanding and reinforce the key concepts covered in this section with a short, targeted assessment.
10 Questions
~15 mins
Your progress is saved automatically
Mark as Completed

On This Page

  1. The Problem: One Word, Many Meanings
  1. The Definition
  1. Why This Is the Microservices Lesson That Matters Most
  1. In the Interview
  1. TL;DR