Why this matters
- Ports and adapters keep domain logic testable without Spring context.
- Interviewers map hexagonal vocabulary to the controller–service–repository layers you already use.
- Knowing when strict hexagonal structure pays off prevents over-engineering small services.
Ports and adapters
L1 · FresherDomain core defines ports (interfaces); adapters implement REST, JPA, and Kafka at the edges.
Driving vs driven
L2 · IntermediateREST controllers drive the application; JPA repositories are driven adapters for persistence.
Testability win
L3 · AdvancedSwap adapters with fakes in unit tests without Spring — domain rules stay pure Java.
vs layered
L4 · ExpertHexagonal emphasizes dependency inversion; layered is fine for small BookStore until boundaries blur.
Hook
BookStore product owners want to swap PostgreSQL for a catalog API and add Kafka events without rewriting pricing rules buried in BookController. Hexagonal architecture keeps domain logic in the center with ports and adapters at the edges.
The rest of this guide is part of Pro
Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.
Still to come · 6 sections
- Domain core
- Ports and adapters
- BookStore in action
- Runnable BookStore lab
- Failure modes in production
- Package layout
Test yourself
Answer these before moving on — recall is what makes it stick.