Port Layer

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

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

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 port layer that defines four artifacts. Additionally, this layer makes use of the use case layer.

Create a free account to access the full course.

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