
Hexagonal Architecture Layers Java
Builds Java services with strict hexagonal architecture boundaries: pure domain models with no framework annotations, application layer use cases that define ports, and infrastructure adapters that implement them. You'd reach for this when refactoring a Spring monolith to isolate business logic from JPA and REST concerns, or when you need to support multiple adapters like REST plus messaging. The examples are crisp and show the full flow from domain record to use case to JPA adapter. One caution: this level of indirection pays off on complex domains but can feel heavyweight for simple CRUD services. The port interfaces and mapping layers add ceremony that smaller teams sometimes regret.
- skills.sh installs
- 249
- GitHub stars
- 665
- last updated
- Aug 21, 2026
Install
$ npx -y skills add gentleman-programming/gentleman-skills --skill hexagonal-architecture-layers-java --agent claude-codeInstalls into .claude/skills of the current project.
Files
When to Use
Load this skill when:
- Designing a new Java service with clean, testable layers
- Refactoring Spring code to isolate the domain from frameworks
- Supporting multiple adapters (REST + messaging, JPA + Mongo)
- Enforcing dependency direction and clear module boundaries
Critical Patterns
Pattern 1: Domain is pure
Domain has no framework annotations, no persistence concerns, and no I/O.
Pattern 2: Application orchestrates
Application defines use cases and ports, calling domain logic and delegating I/O to ports.
Pattern 3: Infrastructure adapts
Infrastructure implements ports and wires adapters (controllers, repositories, clients).
Code Examples
Example 1: Domain model + output port
package com.acme.order.domain;
public record OrderId(String value) { }
public final class Order {
private final OrderId id;
private final Money total;
public Order(OrderId id, Money total) {
this.id = id;
this.total = total;
}
public OrderId id() { return id; }
public Money total() { return total; }
}
package com.acme.order.application.port;
Sponsors
Details
- Repository
- github.com/gentleman-programming/gentleman-skills
- Categories
- Code Review & Quality, Cloud & Infrastructure, Java & JVM
- First seen
- Jun 3, 2026