Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Hexagonal architecture with Spring Boot


Published on

Nowadays traditional layered monolithic architecture in Java world is not so popular as 5-10 years ago. I remember how we wrote tons of code for each layer repeating almost the same parts for every application. Add unit and integration testing to understand how much time and efforts has been spent on repeatable work. All cool ideas around DDD (domain driven design) and Hexagonal Architecture was just a nice theory because reality hasn’t allow us to implement it easily. Even Dependency Injection with Spring framework was completely focused on traditional layered approach, not even talking about JavaEE platform.

Today we have Spring Boot ecosystem covering most of our needs for integration with almost all possible technologies and microservices architectural trend, enabling completely new approach to build Java applications around domain model. It is so natural to build Java domain-oriented services and connect them with external world using ports and adapters, that Hexagonal Architecture is almost enabled by default. You just need to switch your way of thinking…

Published in: Technology
  • Be the first to comment

Hexagonal architecture with Spring Boot

  1. 1. Hexagonal architecture with Spring Boot Mikalai Alimenkou @xpinjection
  2. 2. aka LEV TOLSTOY
  4. 4. Telegram channel
  5. 5. Disclaimer This talk is based on personal experience
  6. 6. Domain Driven Design Expectations Reality
  7. 7. Everything is “simple”!
  8. 8. Layered architecture must have layers
  9. 9. Layered architecture for kids
  10. 10. More serious view
  11. 11. Help Dasha to find business logic
  12. 12. Business logic is easier to find and understand in single place
  13. 13. Let’s start from the basics
  14. 14. Everything should be Use Case driven
  15. 15. Domain Context is a king Taken from
  16. 16. Conference attendee example Taken from
  17. 17. Entities as the core of domain Taken from
  18. 18. Value Objects for simple concepts Taken from
  19. 19. Aggregates for complex relations Taken from
  20. 20. Some advices for aggregates Taken from
  21. 21. Now things are much clearer!
  22. 22. Taken from
  23. 23. Alternative hexagonal world
  24. 24. To connect to the port you need an adapter
  25. 25. Ports and adapters thinking
  26. 26. Fresh architectural paradigms
  27. 27. Spring Boot as game changer
  28. 28. Each service has similar structure SERVICE DB QUEUE UI API EXTERNAL SERVICES API CONTRACTS Spring MVC Spring MVC Spring Data Spring Messaging RestTemplate Feign Spring Cloud Contracts
  29. 29. You could work on business logic
  30. 30. Better focus helps to achieve better results
  31. 31. There are still some blockers #1. Transactions #2. Validation #3. Thick client #4. DB tuning #5. Thinking model
  32. 32. Summary • Change your point of view from layered approach • Start using ports and adapters approach • Make business logic use case driven • Learn how to use existing Spring Boot modules • Adopt Domain Driven Design ideas • Be happy unicorn in the rainbow world ;)
  33. 33. @xpinjection