Questions tagged [hexagonal-architecture]

The Hexagonal Architecture is a software architecture proposed by Alistair Cockburn. It is also called Ports and Adapters. It is similar to the Onion Architecture proposed by Jeffrey Palermo.

Alistair Cockburn proposed the Hexagonal Architecture, also called Ports and Adapters. The architecture is similar to the Onion Arcitecture proposed by Jeffrey Palermo.

The fundamental motivation of the approach is to avoid layer-to-layer dependencies usually associated with the N-tier architecture approach. This is achieved by placing all infrastructure, including databases, outside the problem domain.

The problem domain is then completely independent of the required infrastructure (testing, databases, security, etc.). For example, this means that testing database accesses can be done thoroughly without a real database.

176 questions
0
votes
0 answers

Dealing with JPA relationships in hexagonal architecture

I'm new to hexagonal architecture & ran into a scenario where I can't figure how it can be achieved. I have two domain objects say Employee & Vehicle. Employee can have many vehicles. My Employee domain object has the List of Vehicles. Similarly, I…
0
votes
1 answer

Spring application events without extending ApplicationEvent

Is there any way to define custom application events without extending ApplicationEvent? We are having submodules based on ports and adapters principle, domain module not having any any external dependencies like spring-context. And application…
sidgate
  • 14,650
  • 11
  • 68
  • 119
0
votes
2 answers

Spring Boot: Use incoming access token for outgoing requests. (Internally pass access token from RestController to Component.)

I am wondering what is the best way in a Spring Boot application to internally pass an access token from an incoming request through the different layers, before using it in an outgoing request? The situation is the following: I am developing a…
0
votes
1 answer

Clean Architecture and Spring Boot

I am implementing a spring boot microservice using Clean Architecture. I have a multi module java app, with domain, application and infrastructure. Domain and Application modules do not know anything about Spring framework. In domain I have my…
0
votes
1 answer

Calling instance of adapter class plugged into port is causing mypy issues

I'm currently plugging an Adapter into a port in a handler which can help you get an instance of that port. Here is a simple setup to reproduce: from typing import Protocol class SomePort(Protocol): def caller(self): raise…
0
votes
1 answer

How do I decide what goes into the entity and what goes into the port in Hexagonal Architecture?

Usually, when I create a domain entity (for example a bank account) it includes things like account id and starting balance. But I have seen some Hexagonal projects that also have functions like calculateBalance or createAccount. I usually put these…
Vinn
  • 1,030
  • 5
  • 13
0
votes
3 answers

Hexagonal architecture - Spring Boot

I am going to create a spring boot application following the best way of hexagonal architecture. I found many examples, each one implement the hexagonal differently. I have some questions I need to understand: Assumptions: I want to have three…
Amir Choubani
  • 829
  • 2
  • 14
  • 28
0
votes
1 answer

What sub-packages are recommended to use to dispatch classes when creating an hexagonal architecture for a Java (here spring-boot) application?

I discovered the hexagonal architecture and I'm willing to apply it on a rather large Spring Boot application. A stackoverflow user started a question with a list of sub-packages looking to me really convenient to use, or at least to think about, in…
Marc Le Bihan
  • 2,308
  • 2
  • 23
  • 41
0
votes
0 answers

Hexagonal Architecture : how/where to merge 2 adapters in 1 entity

I'm currently trying to implement a simple Hexagonal Architecture (in Java but it shouldn't matter for my question). I made 3 modules at this moment : A "domain" module and 2 "adapters" modules (for Mongo and Stripe adapters). In my MongoDB, I'm…
0
votes
0 answers

Hxagonal architecture and DDD with Hibernate and OneToMany relationship

Let's assume I have a project done with hexagonal architecture together with DDD where my domain objects doesn't depend on any JPA implementation. Example project structure looks like below: com.example.domain: class User { Integer id; …
a4dev92
  • 531
  • 6
  • 15
0
votes
0 answers

hexagonal architecture JWT

I'm looking for a good example of login using hexagonal architecture. I use spring boot, but it doesn't matter if you reply in other languages and frameworks. Send username, password from incoming adapter layer to application layer. The application…
0
votes
1 answer

Should I restrict the construction of a domain object to an external service?

Let's say I have the value object LicensePlate. It is part of a Car, which is an entity in my domain. However, the logic for building the plate doesn't belong to my domain, I simply obtain that from a domain service…
0
votes
3 answers

Port & Adapter Pattern - invoke multiple implementation of same output port

I have some doubt about how implement a simple scenario for a my style exercises following the Hexagonal architecture or Port & Adapter Pattern. I have a UseCase (or service) that has to send a Contact (received from a contact form) to an external…
LurenzZ
  • 23
  • 6
0
votes
1 answer

Design Patterns implementation in Domain Driven Design

I'm building an application using DDD and Hexagonal Architecture with Typescript as a primary language. Recently I had a problem that needed the observer design pattern implementation to be solved. It is now solve and I want to refactor it, the…
0
votes
0 answers

When I'm using a service as an adapter can I stub said service for my tests or should I use it with its own stubs?

So the situation is as follows, we have an adapter that was complex enough to make it a full service (Service B) (ie. decouple the call to the external dependencies to another adapter and test the logic with stubs). Now if I want to make tests in…