An example implementation of the My Thai Star application in the hexagonal architecture.
Modules are grouped on multiple levels to facilitate working with a lot of code. The highest level consists of four groups: business, connector, orchestration, and util. They are called subsystems.
A business includes modules with business knowledge. They are divided into domains, which consist of two parts: the core and adapters.
A core implements pure business logic, independent of specific frameworks. It is divided into four parts: domain, logic, port, and dto
A domain contains entities and data types such as enumerations. Entities can be used as data transport object if the modules don't need more specialized data transport objects.
A dto is a specialized data transport object. They are located in the requesting use case subsystem
because they must be created for the specific needs of the use case.
Logic is a module that implements use cases.
Port contains only interfaces and optionally transport objects necessary for communication between modules, for example logic and adapters. Port belongs to the cora to make it easier to follow the rule that core modules do not depend on any other modules (except util). Port includes two kinds of interfaces: provided and required.
Provided interfaces are implemented by logic that provides access to logic for modules outside the core.
Required interfaces are implemented by adapter modules and are used by core modules.
A adapter modules implement technical aspects, and they are used to linking core modules to specific frameworks.
There are four main types of adapters, but this is not an exhaustive number: persistence, controller, service, connection.
This module allows to permanently store ata.
This module provides the functionality of the domain through various protocols such as REST, WebService, Messaging.
This module allows to call the functionality of other domain through various protocols such as REST, WebService, Messaging.
This module allows for direct communication between domains when both modules are included in the same service.
A connector subsystem has a similar structure as the business subsystem, with the difference that instead of business knowledge and division into domains, we have knowledge about external systems here. The rest remains the same.
A util subsystem includes modules not related to business knowledge. They can be imported from any other module, but of course no cycles are allowed.
An orchestration subsystem contains the objects necessary to create executable applications. It consists of two subsets, configurations and classes with main method.