What is Bounded Context in Microservices
In this tutorial, we are going to learn about Bounded Context, which is a very common question in the interview room.
- Bounded Context is a concept in Domain Driven Design(DDD).
- DDD is a framework of analyzing and modelling large problems, models, and teams.
- The entire issue is a Domain, for example Drone Delivery System.
- Domain model is the representation of a real thing in the world i.e., Drone, User, or a package which is similar to an object-oriented programming.
- A bounded context is simply the boundary within a domain where a particular domain model applies. Let’s say you have a domain called order or product. When we work with the product or with the order to receive the order, which is a different when compared to the shipping of a product. The way we deal with the model is called as bounded context.
- In microservice, one bounded context represents one microservice.
To understand this in more detailed. Let’s look at the below example.
- We have two bounded contexts i.e., Sales context and other one is support context.
- Customer and product models, Customer is a shared entity across the entire system between the two contexts.
- The way we deal with the customer and product in the sales and support is different.
- In sales context we want to receive the order and whereas in the support context customer has question or complaint. So they are dealt based on their contexts.