Layers

Learn about the layers in hexagonal architecture and how they interact with each other.

As with any other architectural pattern, hexagonal architecture defines some layers that should be followed. We will learn about these layers in this lesson.

The layers of hexagonal architecture

Hexagonal architecture defines four layers to structure a component. As was mentioned before, these layers are focused on all of the parts that an application consists of, such as frameworks, database connections, business flows, and so on. Let’s look at them one by one.

Domain objects layer

Located in the center of the hexagon, a domain contains all of the objects related to the business. In DDD terms, business objects are entities, value objects, and aggregates. Additionally, this layer contains all of the abstractions that are defined to carry out a business process. The abstractions are factories and the definition of repositories. Services can result in two possibilities. If the services interact with external dependencies, the domain layer will only have access to the services’ definition. If they do not interact with external dependencies, then the domain layer will have access to the full implementation.

Get hands-on with 1400+ tech skills courses.