Compile your architecture, not just your code.
Hexagonal architecture promises clean separation, long-term maintainability, and freedom of choice.
In reality, teams pay a constant tax:
- Rewriting the same adapters again and again
- Manually keeping domain, ports, and infrastructure aligned
- Reviewing boilerplate instead of business logic
- Being afraid to change infrastructure because everything is wired by hand
This is not business complexity. It is architectural friction.
HexaGlue exists to remove that friction.
What if your architecture was not just documentation or conventions, but data?
Your source code already contains everything needed to understand:
- Your domain concepts
- Your architectural boundaries
- Your dependencies and invariants
What’s missing is a tool that can read architecture, not just syntax.
HexaGlue is an architecture compiler for Java applications.
At compile time, it turns your codebase into a semantic graph of architectural intent.
To do so, it parses your source code, builds an application graph, and classifies:
-
Domain concepts Aggregates, entities, value objects, identifiers
-
Architectural boundaries Ports, their direction (driving / driven), and their relationships
-
Structural relationships How domain types connect, reference, and depend on each other
From this architectural model, plugins — discovered via SPI — can audit, document, and generate, always respecting your architecture, never making blind assumptions.
flowchart LR
subgraph CORE["🧠 HexaGlue Core"]
direction TB
P["🧬 PARSE<br>Semantic model"]
G["🔬 ANALYZE<br>Application graph"]
C["🗂️ CLASSIFY<br>Ports · Actors · Domain"]
M["🔀 MODELIZE<br>Architectural model"]
end
subgraph PLUGINS["🔌 Plugins (via SPI)"]
O1["📘 Living Documentation"]
O2["🛡️ Architecture Audit"]
O3["🏛️ 🔬Infrastructure Code<br>(JPA / REST / Messaging…)"]
end
MVN["⚙️ Maven Plugin<br>compile · verify"] L_MVN_CORE_0@==> CORE
P L_P_G_0@--> G
G L_G_C_0@--> C
C L_C_M_0@--> M
CORE L_CORE_O1_0@==> O1 & O2 & O3
P:::step
G:::step
C:::step
M:::step
O1:::step
O2:::step
O3:::step
MVN:::maven
classDef step fill:#f8fafc,stroke:#64748b,stroke-width:1px,color:#0f172a
classDef maven fill:#eff6ff,stroke:#3b82f6,stroke-width:1px,color:#0f172a
L_MVN_CORE_0@{ animation: slow }
L_P_G_0@{ animation: slow }
L_G_C_0@{ animation: slow }
L_C_M_0@{ animation: slow }
L_CORE_O1_0@{ animation: slow }
L_CORE_O2_0@{ animation: slow }
L_CORE_O3_0@{ animation: slow }
HexaGlue runs as part of your build and executes a deterministic, architecture-aware pipeline:
-
Analyze - Turn source code into architectural intelligence
HexaGlue parses your Java code at compile time and builds a complete semantic graph of your application - types, relationships, and boundaries - capturing architectural intent, not just syntax. -
Classify - Understand your domain, automatically
Using robust structural heuristics, HexaGlue recognizes DDD and hexagonal concepts (aggregates, ports, adapters…) without forcing annotations. Your domain stays pure, expressive, and framework-agnostic. -
Validate - Make architecture explicit, not assumed
HexaGlue actively detects ambiguities, edge cases, and architectural conflicts. When something cannot be inferred safely, it asks for explicit clarification instead of guessing - ensuring trustable outputs. -
Generate - Produce infrastructure that respects your architecture
From this validated model, HexaGlue generates architecture-aware artifacts through dedicated plugins:- Audits to assess architectural consistency
- Living documentation that stays in sync with your code
- Infrastructure adapters generated exactly from your domain intent
HexaGlue does not transform source code. It transforms architecture into a programmable model.
HexaGlue analyzes the architectural core of the application, the domain and application layers, to reveal the actual architecture and generate trustable, up-to-date documentation for modernization initiatives.
HexaGlue continuously validates the architectural core of the application: boundaries, ports, and dependencies. Ambiguities and violations are detected at build time, with actionable architectural feedback.
Focus on business logic. Define your domain and application layers once. HexaGlue generates infrastructure adapters using enterprise standards that respect your architectural intent, without polluting the core.
HexaGlue follows a simple rule:
What is ambiguous must be clarified.
When a type cannot be classified with certainty, HexaGlue does not guess. It stops, surfaces the ambiguity, and asks for an explicit architectural decision. This guarantees that every generated artifact is grounded in intentional design, never assumptions.
HexaGlue relies primarily on structural analysis of the architectural core of the application. However, when classification is ambiguous, annotations can be used to make intent explicit rather than incorrect.
HexaGlue natively supports jMolecules annotations to express architectural intent:
import org.jmolecules.ddd.annotation.AggregateRoot;
import org.jmolecules.ddd.annotation.Identity;
@AggregateRoot
public class Order {
@Identity
private OrderId id;
// ...
}When present, these annotations do not change behavior. They simply state architectural intent clearly and unambiguously.
Annotations may express intent across three complementary dimensions.
From
jmolecules-dddartifact
| Annotation | Purpose |
|---|---|
@AggregateRoot |
Marks an aggregate root |
@Entity |
Marks a domain entity |
@ValueObject |
Marks a value object |
@Identity |
Marks an identity field |
@Repository |
Marks a repository port |
From
jmolecules-hexagonal-architectureartifact
| Annotation | Purpose |
|---|---|
@PrimaryPort |
Marks a driving (inbound) port |
@SecondaryPort |
Marks a driven (outbound) port |
From
jmolecules-eventsartifact
| Annotation | Purpose |
|---|---|
@DomainEvent |
Marks a domain event |
@Externalized |
Marks an event intended for external publication |
Annotations exist only to support compile-time analysis:
<dependency>
<groupId>org.jmolecules</groupId>
<artifactId>jmolecules-*</artifactId> <!-- ddd, hexagonal-architecture, events -->
<scope>provided</scope> <!-- Compile-time only, not included at runtime -->
</dependency>They are used to:
- Document architectural intent
- Guide classification when structure alone is ambiguous
- Feed validation, documentation, and generation
Nothing leaks into runtime. Nothing pollutes the domain.
HexaGlue naturally favors rich, expressive domain models over anemic ones:
| Anemic Model | Rich Model |
|---|---|
| Data holders | Behavior + data |
| Logic in services | Logic encapsulated |
| Weak invariants | Invariants protected |
| Technical noise | Intent-driven design |
Your domain remains readable, expressive, and architecture-first, free from infrastructure concerns.
When ambiguities remain, HexaGlue makes them explicit and visible:
[INFO] CLASSIFICATION SUMMARY
[INFO] --------------------------------------------------------------
[INFO] EXPLICIT: 8 ( 66,7%)
[INFO] INFERRED: 4 ( 33,3%)
[INFO] UNCLASSIFIED: 0 ( 0,0%)
[INFO] TOTAL: 12
[INFO]
[INFO] Status: PASSED
Each unclassified type becomes a deliberate architectural decision to address.
No hidden assumptions. No silent drift. No accidental architecture.
HexaGlue is pluggable by design. Use the official plugins or develop your own to fit your specific needs.
| Plugin | Description | Status |
|---|---|---|
| Audit | Architectural conformance reports and metrics | Available |
| Living Documentation | Generates documentation of your architecture | Available |
| JPA Repository | Spring Data JPA entities, repositories, mappers, adapters | Available |
| REST API | Spring MVC controllers from driving ports | Planned |
| OpenAPI | OpenAPI specification from ports | Planned |
| Kafka | Kafka producers and consumers | Planned |
| GraphQL | GraphQL schema and resolvers | Planned |
Explore the full documentation with tutorials organized by audience.
For Developers - Generate infrastructure code:
- Quick Start (10 min)
- JPA Generation (30 min)
- Living Documentation (15 min)
For Architects - Validate architecture:
- Classification (20 min)
- Validation (15 min)
- Architecture Audit (30 min)
- Configuration (20 min)
<plugin>
<groupId>io.hexaglue</groupId>
<artifactId>hexaglue-maven-plugin</artifactId>
<version>${hexaglue-maven-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<basePackage>com.example.myapp</basePackage>
</configuration>
</plugin>HexaGlue analyzes and classifies your domain automatically.
Add any combination of plugins as dependencies:
<plugin>
<groupId>io.hexaglue</groupId>
<artifactId>hexaglue-maven-plugin</artifactId>
<version>${hexaglue-maven-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<basePackage>com.example.myapp</basePackage>
</configuration>
<dependencies>
<!-- Living Doc: architecture documentation with Mermaid diagrams -->
<dependency>
<groupId>io.hexaglue.plugins</groupId>
<artifactId>hexaglue-plugin-living-doc</artifactId>
<version>${hexaglue-plugin-living-doc.version}</version>
</dependency>
<!-- Audit: DDD and hexagonal architecture compliance reports -->
<dependency>
<groupId>io.hexaglue.plugins</groupId>
<artifactId>hexaglue-plugin-audit</artifactId>
<version>${hexaglue-plugin-audit.version}</version>
</dependency>
<!-- JPA: entities, repositories, mappers for all repository ports -->
<dependency>
<groupId>io.hexaglue.plugins</groupId>
<artifactId>hexaglue-plugin-jpa</artifactId>
<version>${hexaglue-plugin-jpa.version}</version>
</dependency>
</dependencies>
</plugin>Each plugin generates its artifacts based on your classified domain.
When annotations are not possible:
classification:
explicit:
com.example.OrderDetails: ENTITY
validation:
failOnUnclassified: trueYour architecture remains explicit even without annotations.
Valid values:
AGGREGATE_ROOT,ENTITY,VALUE_OBJECT,IDENTIFIER,DOMAIN_EVENT,DOMAIN_SERVICE,APPLICATION_SERVICE. See Classification for details.
- Java 17+
- Maven 3.8+
HexaGlue is distributed under the Mozilla Public License 2.0 (MPL-2.0).
- ✅ May be used in commercial and proprietary products
- ✅ Your application code remains your own
- ✅ Generated code belongs to you without restriction
⚠️ Modifications to HexaGlue source files must be shared under MPL-2.0
Learn more about MPL-2.0 | Third-Party Licenses
HexaGlue - Compile your architecture, not just your code
Made with ❤️ by Scalastic
Copyright 2026 Scalastic - Released under MPL-2.0