Please enable JavaScript.
Coggle requires JavaScript to display documents.
Hexagonal architecture in java - Coggle Diagram
Hexagonal architecture in java
Application parts
:one: The User-Side or the Driving Side
Can be:
A console or the command line
HTTP API layer and a set of controllers that handle the requests
A cron job
Here are the actors who invoke a business process
:two: The Business Logic
This part forms the core of the application
It serves the requests from the user interface
Main components
Entities
- the domain objects
Repositories
- a list of methods that communicates with the server-side and return a single entity or list of entities
Interactors
- domain-specific service classes that implement business logic, validation, etc.
:three: The Server-Side or the Driven Side
Consists of services that support the business logic
Each of them serves a specific purpose and provides resources/data to the business logic layer
Can be:
Data sources
Another service or microservice
Coupling
User-side -> Business Logic: via Interactor
The user-side drives business logic through an interface defined in the business logic - and implemented there
In hexagonal architecture, we call the interfaces
ports
.
These actors have to adapt their data format and logic to invoke methods from the ports or interfaces, that's why they are also called
adapters
in hexagonal architecture
Business Logic -> Server-side: via Repository
Repositories are nothing but interfaces - defined in the business logic and implemented in the server-side
Example in Java
Business Logic
Book Entity
IBookService
BookService implements IBookService
BookRepository
User-Side
BookConsoleUI
Server-Side
FileDataSource implements BookRepository