Hexagonal Architecture Part -II (Use-Case )

Vijay Aneraye
2 min readFeb 1, 2020

--

First of all, if you didn’t read the previous post, please read first part before you jump into this section

Hexagonal Architecture Part -I (Introduction)

Today we are going to discuss about hexagonal archittecture with use case

There three basic components which hexagonal architecture talks about.

  1. Application (Domain Model)
  2. Ports
  3. Adapter

Application

Hexagon is the application itself. Inside the application, we just have the things that are important for the business problem that the application is trying to solve.

Ports

Ports are the medium through which business logic is accessed. Port is a use case boundary i.e. Ports correspond to use-cases in the application

Adapters

An adapter translates between a specific technology and a technology-free port. Adapters is mediums that serve the purpose of transforming the communication between various external actors and application logic through port.

In hexagonal architecture, all actors interact with the application through adapters

User Case

Consider the Loan Application use case.

A customer wants to apply for a loan application using the online website or using an ATM. The application then verifies the credit rating check system, updates information in the database, and sends an update mail to the customer

Hexagonal Bondries are

  • ApplyForLoan
  • CheckCreditRating
  • SaveCustomerInformation
  • SendEmail

Port (API):

  • LoanApplication Port (ApplyForLoan)

Port (SPI(Service Provider Interface)):

  • Credit Rating System Port (CheckCreditRating)
  • FTP Port (SaveCustomerInformation)
  • Notification Port (SendEmail)

Adapters:

  • Load Application Adapter (Assuming ATM interacts with the banking system using a REST API )
  • Credit Rating System Adapter (Interacts with credit rating check system.)
  • Send Notification Adapter ( Interacts with notification system )
  • FTP adapter (For interacting with the FTP server to store customers' information)

Conclusion

This is my understanding of hexagonal architecture.

If you want to get more information on the topic, read Alistair Cockburn’s original article on the subject

I hope this article will help you understand the idea of Hexagonal Architecture and how they come together I’ll be glad for any feedback!

--

--