How jonathanm2ndoza/hexagonal-architecture-ddd works
Main Components
• Microservices: Represent each service (Customer, Order, Product) as separate containers or modules.
• Layers within each Microservice:
• Application Layer: Contains the REST and SOAP adapters (e.g., controllers, request/response mappings) in packages such as “application/rest” and “application/soap”. This layer is responsible for receiving external inputs.
• Domain Layer: Includes domain models, use-case interfaces (ports), and business logic implementations (services). Look at packages under “domain” or “domain/model”, “domain/ports”, and “domain/services”. This is the central, technology-agnostic part of each microservice.
• Infrastructure Layer: Contains the adapters that implement external interactions like databases (MongoDB and PostgreSQL), message brokers, and security aspects. Observe the “infrastructure/databases”, “infrastructure/messagebroker”, and “infrastructure/security” packages.
Component Relationships and Data Flow
• Each microservice’s Application layer receives requests, which are then forwarded to the Domain layer through inbound ports.
• The Domain layer, which encapsulates the core business logic, interacts with outbound ports that represent dependencies like data persistence or messaging.
• The Infrastructure layer implements these outbound ports as adapters. For example, Customer uses MongoDB adapters (such as CreateCustomerAdapter, DeleteCustomerAdapter) and PostgreSQL adapters can be seen in the Order context.
Architectural Patterns and Design Principles
• Hexagonal (Ports and Adapters) Architecture: Emphasize that the Domain is at the center, isolated by the ports (interfaces) through which the Application and Infrastructure layers interact.
• Domain-Driven Design (DDD): Each service’s domain layer models its business concepts explicitly. The bounded contexts are clear (Customer, Order, Product).
• Use cases are implemented as services in the Domain layer and exposed via REST/SOAP endpoints in the Application layer.
Relevant Technologies and Frameworks
• Spring Boot: Indicate that each microservice is built on Spring Boot as the backbone of application startup and dependency management.
• Databases: Note the usage of MongoDB (commonly for document storage in Customer and Product) and PostgreSQL (used in Order and in some Product infrastructures).
• Message Broker: Show the adapters for messagebroker integration, which help in asynchronous communication between services.
• Additional libraries: Components for security (e.g., PasswordEncodeAdapter) and cross-cutting concerns (e.g., custom exception handlers) should be included.