Adapter Layer

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

Finishing the example regarding a restaurant, let us implement the Adapter layer on top of the port.

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 Adapter layer that defines six artifacts. Additionally, this layer makes use of the port layer. Due to being very big, this model has been divided into two parts. Part one shows the domain, use case and port layers, part two shows the interaction between the port and abstract layer.

Create a free account to access the full course.

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