I have been doing some research on the Hexagonal/Ports & Adapters architecture. For the most part, it makes a lot of sense. My initial understanding was that "Driver Ports" were to be implemented by the adapters in the implementing application. The more work I do on my application, it's becoming clear that this is not correct.

For a practical example, I have an OAuth2AuthorizationPort which defines a single piece of functionality.

public interface OAuth2AuthorizationPort {

OAuth2Account authorize(AuthorizationToken authorizationToken);


Where exactly would the implementation of this port exist? Would I have something like 'GoogleOAuth2AuthorizationAdapter' & 'GithubOAuth2AuthorizationAdapter'?

After doing a little more research it sounds like maybe I would have a single OAuth2AuthorizationPort implementation within the hexagon, and the calling application would use this (the interface) to interact with the application. Is this correct?

  • 3
    This post provides a step-by-step treatment of how and where to implement the ports. Oct 15, 2019 at 22:29

1 Answer 1


The central (inner) hexagonal block will define your port "OAuth2AuthorizationPort". The central hexagonal block will also use the port (interface).

You need to create the adapters (GoogleOAuth2AuthorizationAdapter or GithubOAuth2AuthorizationAdapter) in the outer hexagonal block. The outer hexagonal block can reference the inner block. GoogleOAuth2AuthorizationAdapter will implement the port OAuth2AuthorizationPort.

On top of both these hexagonal blocks you have the bootstrap that maps which adapter has to be used for which port

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.