Architecturally Expressive Package Structure
Explore how to structure a Hexagonal Architecture project with packages for domain, application, and adapters. Understand how this expressive structure bridges architecture and code, improves modularity, and supports domain-driven design concepts.
We'll cover the following...
We'll cover the following...
Project structure
In a Hexagonal Architecture, we have entities, use cases, incoming and outgoing ports, and incoming and outgoing (or “driving” and “driven”) adapters as our main architectural elements. Let’s fit them into a package structure that expresses this architecture:
buckpal
└── account
├── adapter
| ├── in
| | └── web
| | └── AccountController
| ├── out
| | └── persistence
| | ├── AccountPersistenceAdapter
| | └── SpringDataAccountRepository
├── domain
| ├── Account
| └── Activity
└── application
├── service
| └── SendMoneyService
└── port
├── in
| └── SendMoneyUseCase
└── out
├── LoadAccountPort
└── UpdateAccountStatePort
Explanation
Each element of the architecture can directly be mapped to one of the packages. On the highest level, we again have a package named account, indicating that this is the module implementing the use cases around an Account. ...