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 external sources interact with the application using ports and adapters.
In Rails, we can use the following rails components to play the role of port, adapter, and external devices in hexagonal architecture:
The following core responsibilities make the controllers work like the adapters of the hexagonal architecture:
We can use different techniques to implement the hexagonal architecture in a Rails application.
The hexagon in the architecture contains all the business logic, which can be implemented and tested without worrying about the technology or loading the Rails or databases.
The hexagonal architecture helps Rails to separate the application and the business logic. In Rails, the application helps to notify the external sources about the results of any request that external source made. The application does not know anything about Rails or the external source, for example, the database. To interact with the database, the application uses repositories.
Free Resources