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
u/Quick-Resident9433 — 3 days ago