@angexxl/hexamod
v2.0.3
Published
CLI to generate Java Hexagonal Architecture modules for Spring Boot in seconds.
Downloads
40
Maintainers
Readme
@angexxl/hexamod
A powerful CLI to generate Java Hexagonal Architecture modules for Spring Boot projects in seconds.
Designed to follow Domain-Driven Design (DDD) best practices, including separation of concerns, domain rules, factories, and immutable models.
Installation
Run directly with npx:
npx @angexxl/hexamodOr install globally:
npm install -g @angexxl/hexamodUsage
Navigate to your project folder and run:
hexamodThe CLI will ask for:
- Base Path - e.g.,
src/main/java/com/company/project(It saves this path for future use). - Module Name - e.g.,
user,order,payment.
Generated Structure
The tool creates a full "Vertical Slice" module following strict Hexagonal Architecture layers:
moduleName/
├── application/
│ ├── dto/
│ │ ├── input/
│ │ │ ├── CreateModuleDto.java
│ │ │ └── UpdateModuleDto.java
│ │ └── output/
│ │ └── ModuleResponseDto.java
│ ├── mappers/
│ │ ├── input/
│ │ │ └── ModuleInputMapper.java
│ │ └── output/
│ │ └── ModuleOutputMapper.java
│ └── useCases/
│ └── CreateModuleUseCase.java
├── domain/
│ ├── enums/
│ │ └── ModuleEnum.java
│ ├── factories/
│ │ └── ModuleFactory.java <-- For complex object creation
│ ├── model/
│ │ └── ModuleModel.java <-- Immutable Domain Model (@Builder toBuilder=true)
│ ├── ports/
│ │ ├── repository/
│ │ │ └── ModuleRepositoryPort.java
│ │ └── service/
│ ├── rules/
│ │ └── ModuleCompletionRules.java <-- Encapsulated Business Rules
│ └── services/
│ └── ModuleDomainService.java
└── infrastructure/
├── persistence/
│ ├── entities/
│ │ └── ModuleEntity.java
│ ├── mappers/
│ │ └── ModuleEntityMapper.java
│ ├── projections/
│ │ └── ModuleProjection.java
│ └── repositories/
│ ├── implementation/
│ │ └── ModuleRepositoryImpl.java
│ └── jpa/
│ └── JpaModuleRepository.java
└── web/
└── controllers/
└── ModuleController.javaKey Features
- DDD Ready: Includes folders for
Factories,Rules, andDomain Servicesout of the box. - Immutable Models: Generates Domain Models using Lombok's
@Builder(toBuilder = true). - Persistence Separation: Clean separation between
JpaRepository,RepositoryPort, andRepositoryImplementation. - Smart Configuration: Remembers your
src/main/java/...path so you don't have to type it every time.
Commands
| Command | Description |
|---------|-------------|
| npx @angexxl/hexamod | Run the generator |
| npx @angexxl/hexamod --reset-path | Clear the saved base path configuration |
License
MIT
