Microservice - Project folder structure for hexagonal architecture

发布时间 2023-11-16 08:35:47作者: ZhangZhihuiAAA

 

While there are no written rules for a hexagonal architecture folder, the following folders are common in typical Go projects:
Application folder—This folder contains microservice business logic, which is a combination of the domain model that refers to a business entity and an API that exposes core functionalities to other modules.
Port folder—This folder contains contract information for integration between the core application and third parties. This can be a contract about accessing core application features or about specifying available features for a database system, if one is used for the persistence layer.
Adapter folder—This folder contains concrete implementation for using contracts that are defined in ports. For example, gRPC can be an adapter with a concrete implementation that handles requests and uses an API port to access core functionalities, such as if you have an application with some functionalities and will expose it to customers. The functionalities can be CreateProduct, GetProduct, and so on, and you can expose them to the customer via REST, gRPC, and other adaptors, which will use the contracts of those functionalities, as defined in the port layer.