How gmartinez1985/hexagonal_architecture works
Main Components
• Domain Core:
• Domain Model (service/domain/domain-model): Contains the business entities, value objects, domain events, exceptions, and other business rules.
• Domain Use Cases (service/domain/domain-usecases): Implements application logic and defines the ports (interfaces) used by various components.
• Domain Application Layer (service/domain/domain-application): Implements services and event listeners that translate external calls into domain operations.
• Adapters / Infrastructure:
• REST/HTTP adapter (service/application and service/servicio): Contains controllers (e.g., IncidenceController) and configuration for handling incoming HTTP requests.
• Data Access Layer (service/dataaccess): Implements persistence with repository adapters, mappers, and entity classes.
• Messaging layer (service/messaging): Contains message publishers, mappers, and listeners (e.g., those for RabbitMQ) to communicate with external systems.
• Container layer (service/container): Likely bootstraps the application using configuration files (application.yaml) and serves as the main entry point in a containerized environment.
• External Concerns:
• API and external integration points (e.g., messaging interfaces or external publisher modules).
• Docker Compose file (docker-compose.yaml) that shows deployment concerns—for example, services needed for integration.
Relationships and Interactions
• At the center, the Domain represents the business logic. It is invoked by application services and use cases.
• Adapters on the “inside” (e.g., service/application and service/servicio) expose REST endpoints. These controllers convert external requests into commands that flow to the domain.
• Data access adapters convert domain objects to persistence entities (via repositories, mappers, and adapters in service/dataaccess).
• Messaging components, such as those in service/messaging, translate domain events into messages, while message listeners (both inbound and outbound) handle asynchronous communication.
• The container and configuration files in the service/container layer assemble these components into a running application, coordinating dependency injection and configuration.
Architectural Patterns and Design Principles
• Hexagonal Architecture: Emphasize the separation between the core domain logic (the “inside”) and infrastructure concerns (the “outside”). The ports (interfaces) are defined in the domain layers, and the adapters implement these ports.
• Domain-Driven Design (DDD): Show how the domain model is the heart of the system, including its entities, value objects, domain events, and domain services.
• Clean Separation of Concerns: Notice how responsibilities are broken down among controllers, application services, domain logic, repository implementations, and messaging components.
Technologies, Frameworks, and Tools
• Java (JDK 17) and Maven: The primary development environment.
• Spring-like architecture (implied by package structures and naming conventions) for dependency injection and REST APIs.
• Docker Compose: For containerization and deployment orchestration.
• Graphviz (via the Maven depgraph plugin) for generating dependency graphs.
• Likely usage of standard libraries and frameworks associated with DDD and hexagonal patterns.
• Ports/interfaces that the core domain exposes (for inbound commands and outbound events).
• Application/REST layer: Indicate controllers (e.g., IncidenceController).
• Data Access Adapter: Include the repository implementations, mappers, and entities.
• Messaging Adapter: List message publishers, listeners, and mappers.