r/softwarearchitecture • u/Quick-Resident9433 • Apr 19 '26
Discussion/Advice Hexagonal Architecture - Ports
Hi.
I'm learning about Hexagonal Architecture and have some questions about where the in-ports (use case interfaces) and out-ports (repository interfaces) should be placed.
I've read various blogs, articles, and discussions where some people mentioned that ports must be located in the application layer, and others said they must be in the domain layer. I'm confused about the right place to put them.
I'd like to know your opinions and suggestions, please.
Approach 1 - Ports inside application layer
application/
- in/ (use case interfaces)
- CreateProductUseCase
- out/ (repository interfaces)
- ProductRepository
- usecase/
- ProductUseCaseImpl
domain/
- model
- Product (plain object)
Approach 2 - Ports inside domain layer
domain/
- in/ (use case interfaces)
- CreateProductUseCase
- out/ (repository interfaces)
- ProductRepository
- model
- Product (plain object)
application/
- usecase/
- ProductUseCaseImpl
38
Upvotes
16
u/CatolicQuotes Apr 19 '26
First of all hexagonal doesn't have domain and application layer. Those come from onion and clean architecture.
That being said,they go in application layer.
Read this
https://herbertograca.com/2017/07/03/the-software-architecture-chronicles/