A software or application architecture is a high-level view of application components and how they interact with each other. When we follow a specific type of architecture to build an application, it helps us plan, operate, and build a complete application from scratch to a high-level form.
Here are the benefits of using the application architecture:
The hexagon in a hexagonal architecture represents the application, where each side of the hexagon represents the external source with which the application interacts.
The hexagonal architecture has three parts:
All three are explicitly separate from each other. The application plays the most vital role in the architecture, as it contains all the code that implements the business logic.
The user-side and the server-side are both external sources. They interact with the application (the business logic) using ports and adapters, where the user interface (user-side) works as a source that initiates the interaction with the application. The infrastructure (server-side) works as a source initiated by the application. Both external sources are dependent on the application.
As this architecture mostly works using ports and adapters, it is also called the ports and adapters architecture.
Ports determine the interface that facilitates external sources to interact with the application and facilitates the application to communicate with external sources and services. Examples of external sources and services include databases, brokers, and other applications.
Interactions between clients and the application occur with the help of adapters. Adapters initiate the interaction with the application via ports, and a single port can have as many adapters as needed for the interaction. An example of an adapter is a REST controller.
In hexagonal architecture, an application is the core of the system. It contains all the functionality and business logic and is represented by the hexagon in the middle. The application receives requests from external sources (for example, a user interface) via a port. It then sends the request to an external source (for example, a database) through a port to help fulfill the request.
The ports and adapter architecture allow us to:
Free Resources