SlideShare a Scribd company logo
Java Development
HEXAGONAL
ARCHITECTURE
for Java Applications
01 Concepts
Software Architecture
01 What drives the software architecture?
• High Maintainability
• Low Technical Debt: The cost payed by bad decisions
• Lack of understanding
• Lack of tests
• Lack of documentation
• Lack of collaboration
• Lack of process
01 Common multi-layer architecture
!
"
#
"
! UI Layer
" Application Layer
# Data
" Crosscutting
Dependency
01 Multi-tier architecture
Web Application Tier
! !
" "
"
# # #
" "
"
!
"
Client Tier
Browsers, Frontend App
Mobile devices, PC$Q
%
!
+
Data / Integration Tier
Database, File Storage,
External Systems, Cloud
&

ERP
CRM
DOCs
Dependency
01 Dependency inversion principle
Reference: http://blog.ploeh.dk/2013/12/03/layers-onions-ports-adapters-its-all-the-same
Dependency
DANGER -
Possible business
logic leaks
02 Hexagonal
Architecture
The Pattern
02 Intent
• Alternative names
• Ports & Adapters
• Onion Architecture / Onion Layers
“Allow an application to equally be driven by users,
programs, automated test or batch scripts, and to be
developed and tested in isolation from its eventual run-
time devices and databases.”
Alistair Cockburn
02 Key Concepts
Ports are interfaces
Adapters are implementations
The big picture: Ports & Adapters02
"Application
Port Port
Port
Mock
DB
DB
Integration
Test
Agent
UI
Adapter
Adapter
Adapter
Adapter
Use Case
Boundary
‘’driven’’ adapters
‘’driver’’ adapters
Overview02

In-Memory
"Application
# Database
( Web Services
)
) Enterprise Integration
*

SQL Server
REST
Adapter
* Configuration
+
Test Agent
!
HTML5 App
Environment
Adapter
File Source
Adapter
,
SQL
Adapter
#
NoSQL
Adapter
- MQ Service
MQ
Adapter
.
. Messaging Queue
&ERP
CRM
DOCs
EI
Adapter
(SOAP
Adapter
TEST
Adapter
03 Application
Keeping it simple
03
• Organizing Concerns and Code with Domains
• Well defined boundaries between domains
• Simple event-driven components
• Life Preserver diagram
Life preserver approach by Russ Miles
Life Preserver diagram03
Integration
Core
Domain Event
Service
Domain
Boundary
Notes03
• Core
• Single purpose
• Focus on unit testing
• No side-effects
• Integration
• Side effects
04 Practice
Ticket System
Kick-off04
github.com/fabricioepa/lab-
springboot-rest-sample
Lets start from the sample project and
then create the ports and adapters
05 Core
Use Case as service
Implementing the Use Case as Service05
• Domain model
• Entities
• Repositories
• Well defined interface
• Input/Output Events
• Event Handlers & Translators
• Service composition
• Unit Testing
Life Preserver
Services
Domain
Event
Repository
D
atabase
Test
UnitTest
Framework
0405
06 Controllers
Implementing passive controllers
• Dummy service invokers
• Do not perform multiple service calls
• It does not make any workflow decision
• REST Domain translator
0305
• UC
• Service
• Services
• Domain
• Controller
REST
Domain
06
Life Preserver
Services
Domain
Event
Repository
D
atabase
Test
UnitTest
Framework
Domain
Controller
R
EST
030506
07
Configuration
Externalized configuration
• External files
• Environment variables
• Configuration profiles
• Services
030507
MySQL
Life Preserver
Services
Domain
Event
Repository
D
atabase
Test
UnitTest
Framework
Domain
Controller
R
EST
C
onfiguration
App
Settings
Test
Client
H2
in-memory
Environment
030507
Comments
• How many ports?
• The hexagon is a metaphor
• Abstractions
• Use Case as port
• Module as port: Notification, Administration,
Public API, Database
0303
• Services
See more…
• RESTful API with Spring Boot
• Securing REST APIs
• References:
[1] alistair.cockburn.us/Hexagonal+architecture
[2] www.infoq.com/news/2013/08/hexagonal-lifepreserver-spring
[3] github.com/russmiles/life-preserver-introductory-article-developer-magazine/
blob/master/README.md
[4] github.com/spring-guides/deprecate-tut-rest
[5] blog.ploeh.dk/2013/12/03/layers-onions-ports-adapters-its-all-the-same
/ fabricioepa.wordpress.com
Contact
FABRICIO EPAMINONDAS
0 linkedin.com/in/fabricioepa
/ fabricioepa.wordpress.com
1 @fabricioepa

More Related Content

PPTX
Domain Driven Design(DDD) Presentation
PDF
Domain Driven Design (Ultra) Distilled
PDF
Kata: Hexagonal Architecture / Ports and Adapters
PPTX
Domain Driven Design
PPTX
Domain Driven Design 101
PDF
Domain Driven Design
PDF
Clean Architecture
PDF
Hexagonal architecture
Domain Driven Design(DDD) Presentation
Domain Driven Design (Ultra) Distilled
Kata: Hexagonal Architecture / Ports and Adapters
Domain Driven Design
Domain Driven Design 101
Domain Driven Design
Clean Architecture
Hexagonal architecture

What's hot (20)

PDF
Design patterns for microservice architecture
PPTX
Domain-Driven Design
PPTX
Domain Driven Design
PDF
Real Life Clean Architecture
PPTX
A Practical Guide to Domain Driven Design: Presentation Slides
PPTX
Domain Driven Design: Zero to Hero
PPTX
React Hooks
PPSX
SOLID Principles and The Clean Architecture
PDF
Hexagonal architecture - message-oriented software design
PDF
Asynchronous JavaScript Programming
PDF
Solid NodeJS with TypeScript, Jest & NestJS
PPTX
Domain Driven Design Introduction
PDF
Refactoring for Domain Driven Design
PPTX
Introduction to DDD
PDF
React
PDF
The Secrets of Hexagonal Architecture
PDF
Introduction to docker
PDF
Basics of React Hooks.pptx.pdf
PDF
Clean Architecture
PPTX
React js programming concept
Design patterns for microservice architecture
Domain-Driven Design
Domain Driven Design
Real Life Clean Architecture
A Practical Guide to Domain Driven Design: Presentation Slides
Domain Driven Design: Zero to Hero
React Hooks
SOLID Principles and The Clean Architecture
Hexagonal architecture - message-oriented software design
Asynchronous JavaScript Programming
Solid NodeJS with TypeScript, Jest & NestJS
Domain Driven Design Introduction
Refactoring for Domain Driven Design
Introduction to DDD
React
The Secrets of Hexagonal Architecture
Introduction to docker
Basics of React Hooks.pptx.pdf
Clean Architecture
React js programming concept
Ad

Similar to Hexagonal architecture for java applications (20)

PDF
Hexagonal Architecture using Grails
PDF
Dependency inversion using ports and adapters
PDF
Hexagonal Architecture.pdf
PDF
PDF
DDD - 4 - Domain Driven Design_ Architectural patterns.pdf
PDF
Ports & Adapters Architecture - XP Days 2017
PDF
Explicit architecture
PDF
Hexagonal
PDF
Hexagonal architecture: how, why and when
PDF
Hexagonal architecture for the web
PDF
ljug-meetup-2023-03-hexagonal-architecture.pdf
PDF
Layers, ports and adapters
PDF
A very simple hexagonal architecture.pdf
PPTX
Microservices - why's and how's
PDF
Hexagonal Symfony - SymfonyCon Amsterdam 2019
PDF
Hexagonal Architecture - message-oriented software design (PHPCon Poland 2015)
PDF
Hexagonal architecture message-oriented software design
PPTX
Hexagonal_Architecture_DDD_Presentation.pptx
PDF
Composable Software Architecture with Spring
PPTX
Onion Architecture / Clean Architecture
Hexagonal Architecture using Grails
Dependency inversion using ports and adapters
Hexagonal Architecture.pdf
DDD - 4 - Domain Driven Design_ Architectural patterns.pdf
Ports & Adapters Architecture - XP Days 2017
Explicit architecture
Hexagonal
Hexagonal architecture: how, why and when
Hexagonal architecture for the web
ljug-meetup-2023-03-hexagonal-architecture.pdf
Layers, ports and adapters
A very simple hexagonal architecture.pdf
Microservices - why's and how's
Hexagonal Symfony - SymfonyCon Amsterdam 2019
Hexagonal Architecture - message-oriented software design (PHPCon Poland 2015)
Hexagonal architecture message-oriented software design
Hexagonal_Architecture_DDD_Presentation.pptx
Composable Software Architecture with Spring
Onion Architecture / Clean Architecture
Ad

More from Fabricio Epaminondas (10)

PDF
Understanding Web services
PDF
Designing Scalable Applications
PDF
Continuous testing in agile projects 2015
PDF
Info Card - Techical Debt Management
PDF
Software quality - Round table discussion
PDF
Continuous integration practices to improve the software quality
PPTX
Protocol buffers
PDF
Quickstart for continuous integration
PDF
Workshop Guide: RESTful Java Web Application with Spring Boot
PDF
Introduction to developing modern web apps
Understanding Web services
Designing Scalable Applications
Continuous testing in agile projects 2015
Info Card - Techical Debt Management
Software quality - Round table discussion
Continuous integration practices to improve the software quality
Protocol buffers
Quickstart for continuous integration
Workshop Guide: RESTful Java Web Application with Spring Boot
Introduction to developing modern web apps

Recently uploaded (20)

PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
ai tools demonstartion for schools and inter college
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
System and Network Administraation Chapter 3
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Design an Analysis of Algorithms I-SECS-1021-03
Operating system designcfffgfgggggggvggggggggg
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Odoo Companies in India – Driving Business Transformation.pdf
Softaken Excel to vCard Converter Software.pdf
ai tools demonstartion for schools and inter college
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Upgrade and Innovation Strategies for SAP ERP Customers
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Odoo POS Development Services by CandidRoot Solutions
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
2025 Textile ERP Trends: SAP, Odoo & Oracle
How to Migrate SBCGlobal Email to Yahoo Easily
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
System and Network Administraation Chapter 3

Hexagonal architecture for java applications