A demo application to discover HexaGlue step by step.
- Java 17+
- Maven 3.8+
hexaglue-demo/
├── pom.xml # Maven + HexaGlue configuration
├── src/main/java/io/hexaglue/demo/
│ ├── DemoApplication.java # Spring Boot application
│ ├── domain/
│ │ ├── Task.java # Aggregate root (contains an intentional violation)
│ │ ├── TaskId.java # Value Object (record)
│ │ └── TaskStatus.java # Enum
│ ├── ports/
│ │ ├── in/TaskUseCases.java # Driving port
│ │ └── out/TaskRepository.java # Driven port
│ └── application/
│ └── TaskService.java # Application service
└── src/test/java/
└── TaskRepositoryIntegrationTest.java # Integration tests
git clone https://github.com/hexaglue/hexaglue-demo.git
cd hexaglue-demo- In
pom.xml, uncomment thehexaglue-plugin-living-docdependency in the HexaGlue plugin<dependencies>block - Run:
mvn clean compile
- Check the generated documentation in
target/hexaglue/reports/living-doc/
- In
pom.xml, uncomment thehexaglue-plugin-auditdependency - Run:
The
mvn clean verify -DskipTests
-DskipTestsoption is required because tests would fail: the JPA infrastructure has not been generated yet. - The build fails! The audit detects an architectural violation:
Task.javaimportsjakarta.persistence.Entity(domain dependency on infrastructure)
- Open
src/main/java/io/hexaglue/demo/domain/Task.java - Remove the
@Entityannotation from the class - Remove the
jakarta.persistence.Entityimport - Run again:
mvn clean verify -DskipTests
- The build passes! The audit is satisfied.
-
In
pom.xml, uncomment thehexaglue-plugin-jpaandhexaglue-plugin-restdependencies -
Run:
mvn clean verify
-
HexaGlue automatically generates the following in
target/generated-sources/hexaglue/:JPA (driven adapter from
TaskRepositoryport):TaskEntity.java: JPA entityTaskJpaRepository.java: Spring Data repositoryTaskMapper.java: Domain/entity mapperTaskRepositoryAdapter.java: Adapter implementing the driven port
REST (driving adapter from
TaskUseCasesport):TaskController.java: REST controller with 6 endpointsCreateTaskRequest.java: Request DTO with bean validationTaskResponse.java: Response DTO withfrom()factory methodGlobalExceptionHandler.java: Centralized exception handlingRestConfiguration.java: Spring@Configurationwith@BeanforTaskUseCases
The REST plugin derives HTTP verbs automatically from use case signatures:
createTask→POST /api/tasks(201)getTask→GET /api/tasks/{id}(200)listAllTasks→GET /api/tasks(200)startTask→POST /api/tasks/{id}/start-task(204)completeTask→POST /api/tasks/{id}/complete-task(204)deleteTask→DELETE /api/tasks/{id}(204)
Generated sources are automatically added to the classpath thanks to
<extensions>true</extensions>. -
Integration tests pass, the audit validates the final architecture, and OpenAPI documentation is available at
http://localhost:8080/swagger-ui.html.
| Step | Action | Result |
|---|---|---|
| 1 | Clone | Project ready |
| 2 | Living Doc | Documentation generated |
| 3 | Audit | Violation detected |
| 4 | Fix | Green build |
| 5 | JPA + REST | Infrastructure generated, tests OK |