Clean Architect about Application, Core and Infrastructure


#1

Hello,

By going through the project of “Pacco” micro service, I am having some trouble to figure out reason
behind of separate the architect into those 3 sub project as “Core --> Application --> Infrastructure --> Api”. It seems like:

  • the Core is the base layer for dealing with POJO objects as in traditional architecture
  • the Application is the “service” middle layer as in traditional architecture
  • the Infrastructure is the final interface for services to expose with api.

However, I also found that handlers are being implemented both in Application(for command) and Infrastructure(for queries), why is that and why not combine all handlers in Application layer only while all command and query in Infrastructure?

Many thanks,


#2

Hi Kevin,

As you can see Pacco follows CQRS pretty much everywhere.
Commands have a lot to do with business logic therefore their handlers use ports (i.e. repository ports) whereas queries are just some basic data retrieval mechanisms that:

  1. Have nothing to do with business logic
  2. Their handlers don’t use any ports, but rather work on the DB directly

Given the aforementioned reasons I believe that application’s layer is a natural place for command and event handlers and infrastructure is a natural layer for query handlers as they’re tightly coupled to persistence implementation details.

Maybe Pacco’s authors had some different reasoning in their mind about it, but I am almost sure that this is why it was orchestrated this way.

Cheers


#3

Hi Zaravvski,

Your explaination makes perfect sense! Thank you very much for sharing your thoughts here!

Best regards