# gmartinez1985/hexagonal_architecture architecture

> Architecture diagram of the GitHub repository gmartinez1985/hexagonal_architecture, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gmartinez1985/hexagonal_architecture
- Repository: https://github.com/gmartinez1985/hexagonal_architecture

## Overview

##### 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.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Deployment Orchestration
    subgraph "Deployment Orchestration"
        DC["docker-compose.yaml"]:::deploy
    end

    %% Container/Bootstrap Layer
    subgraph "Container/Bootstrap Layer"
        IA["IncidenceServiceApplication"]:::container
        AY["application.yaml"]:::container
    end

    %% REST/HTTP Adapter
    subgraph "REST/HTTP Adapter"
        IC["IncidenceController"]:::rest
        IE["IncidenceCreatedEventApplicationListener"]:::rest
        CH["CreateIncidenceHandler"]:::rest
    end

    %% Data Access Adapter
    subgraph "Data Access Adapter"
        IR["IncidenceRepositoryImpl"]:::data
    end

    %% Messaging Adapter
    subgraph "Messaging Adapter"
        RP["CreateIncidenceRabbitMessagePublisher"]:::messaging
    end

    %% Core Domain
    subgraph "Core Domain"
        DM["Domain Model"]:::core
        DU["Domain Use Cases"]:::core
        DA["Domain Application"]:::core
    end

    %% Connections
    DC --> IA
    IA --> IC
    IA --> IR
    IA --> RP

    IC -->|"calls"| DA
    CH -->|"calls"| DA
    IE -->|"calls"| DA

    DA -->|"delegates"| DU
    DU -->|"applies"| DM
    DU -->|"persists"| IR
    DA -->|"publishes"| RP

    %% Styles
    classDef core fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef rest fill:#90ee90,stroke:#000,stroke-width:2px;
    classDef data fill:#ffffcc,stroke:#000,stroke-width:2px;
    classDef messaging fill:#ffb6c1,stroke:#000,stroke-width:2px;
    classDef container fill:#d3d3d3,stroke:#000,stroke-width:2px;
    classDef deploy fill:#ffcccb,stroke:#000,stroke-width:2px;

    %% Click Events
    click DM "https://github.com/gmartinez1985/hexagonal_architecture/tree/main/service/domain/domain-model"
    click DU "https://github.com/gmartinez1985/hexagonal_architecture/tree/main/service/domain/domain-usecases"
    click DA "https://github.com/gmartinez1985/hexagonal_architecture/tree/main/service/domain/domain-application"
    click IC "https://github.com/gmartinez1985/hexagonal_architecture/blob/main/service/application/src/main/java/com/gfmartinez/hexagonalarchitecture/service/application/rest/IncidenceController.java"
    click IE "https://github.com/gmartinez1985/hexagonal_architecture/blob/main/service/servicio/src/main/java/com/gfmartinez/hexagonalarchitecture/IncidenceCreatedEventApplicationListener.java"
    click CH "https://github.com/gmartinez1985/hexagonal_architecture/blob/main/service/servicio/src/main/java/com/gfmartinez/hexagonalarchitecture/CreateIncidenceHandler.java"
    click IR "https://github.com/gmartinez1985/hexagonal_architecture/blob/main/service/dataaccess/src/main/java/com/gfmartinez/hexagonalarchitecture/service/dataaccess/incidence/adapter/IncidenceRepositoryImpl.java"
    click RP "https://github.com/gmartinez1985/hexagonal_architecture/blob/main/service/messaging/src/main/java/com/gfmartinez/hexagonalarchitecture/incidence/service/messaging/publisher/rabbit/CreateIncidenceRabbitMessagePublisher.java"
    click IA "https://github.com/gmartinez1985/hexagonal_architecture/blob/main/service/container/src/main/java/com/gfmartinez/hexagonalarchitecture/IncidenceServiceApplication.java"
    click AY "https://github.com/gmartinez1985/hexagonal_architecture/blob/main/service/container/src/main/resources/application.yaml"
    click DC "https://github.com/gmartinez1985/hexagonal_architecture/blob/main/docker-compose.yaml"
```
