Domain Layer

Learn more about the domain layer, through the implementation of an example.

To comprehend how software may be implemented, based on hexagonal architecture, let us review an example related to the processes that occur in a restaurant.

Example definition

This restaurant wants to allow a customer to order something through its website. The website consumes REST APIs to execute the business logic. Therefore, we have to implement a microservice that exposes the functionality to create an order. This use case displays the following restrictions:

  • If a customer has no previously created orders, it is possible to create a new order.
  • If a customer has already created an order, it is not possible to create a new order.

In the upcoming lessons, each layer of this microservice will be implemented in order to accomplish the business need.

Model definition

The following diagram depicts the domain layer and how the domain objects should be implemented to fulfill the business rules.

Get hands-on with 1200+ tech skills courses.