Use Case Layer

Learn what the use case layer in hexagonal architecture is and how to implement it.

Continuing with the example regarding a restaurant, let us implement the use case layer on top of the domain.

Example definition

The business case that is being implemented is related to a restaurant that wants to allow a customer to order something by using its website. The idea is to expose an API to fulfill this business case. It is required to comply with these business rules:

  • If a customer has no created orders, it is possible to create a new one
  • If a customer has already created orders, it is not possible to create a new one

Model definition

The following diagram depicts the use case layer that defines two artifacts. Additionally, this layer makes use of the domain layer.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy