Polylith compared to other software architectures #561
Replies: 6 comments 5 replies
-
|
One thing I spotted: typo: union -> onion Also, both Onion and Clean are variations of the Hexagonal architecture, not the Layered one directly. |
Beta Was this translation helpful? Give feedback.
-
|
I still stand by my earlier comments on the topic in other places :)
This is the selling point of Polylith: the tooling that enables [smoother dev/incremental testing/flexible deployment strategies/etc] if you agree to organize your workspace according to the Polylith conventions.
It might be beneficial to separate Poly's documentation along the lines of:
Following what I put in point 1 above does not make any architecture automatically emerge. This is actually a great thing because Polylith does not enforce any architecture, resulting in:
Following what I put in point 2 might result in what you put into the OP's point 1. However, on
and
what emerge in these situations already have their names. If you start from a blank workspace, and Hexagonal emerges, then that's exactly Hexagonal inside a Polylith workspace. And this is good, because it's a known pattern and someone new to your workspace can just be told "yo, we're doing hexagonal here like so" and it will be clearer to them what will be expected from future contributions. It's like design patterns - conveying important information in a few words.
My suggestion: Ultimately, you can use Polylith as a workspace framework/tooling, providing you xyz benefits, while leaving you the ability to draw your architecture your way and achieve the desired behavior of your systems. Additionally, if you follow these architectural recommendations by its authors, you might naturally end up with something close to Hexagonal, deployed into microservices. |
Beta Was this translation helpful? Give feedback.
-
|
I've always had a hard time accepting that Polylith is an architecture in and of itself. It's an approach to code organization that supports various architectures and provides tooling to help developers understand and manage their monorepo codebase. |
Beta Was this translation helpful? Give feedback.
-
|
Hmm, maybe the argument of "what is an architecture really?" is a little too ontological/semantic to be useful here? (In which case we can reference a specific definition on wikipedia or something. The wikipedia one at least would support considering Polylith an architecture IMO:
Though maybe that hinges on the further semantics of 'what is structure/elements/relations exactly?' ad infinitum.) I think of Polylith as a code-base architecture, prescribing "organization rules" yes, but also "composition rules" (via the abstraction of components vs bases)- I do not think of Polylith as a system architecture, prescribing how to compose/orchestrate different services/artifacts. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
I'm in favor of the statement proposed by @tengstrand. Our codebase is deeply influenced by one of your blogposts explaining polylith with hexagonal architecture(https://medium.com/@joakimtengstrand/understanding-polylith-through-the-lens-of-hexagonal-architecture-8e7c8757dab1). Our actual implementation combines the hexagonal aspects with domain driven design principles, and it works very well for us. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Polylith + Simple Guiding Rules
This is a discussion I want to have to see if my view of Polylith as an architecture aligns with the community’s.
Statement:
1. Architectures that naturally emerge from Polylith + simple rules
By following Polylith principles — composable components, bases, and projects — and adding minimal conventions, you automatically get:
Polylith itself is the architecture; other styles emerge from minimal, intentional conventions. Polylith also provides benefits not often found in other architectures, such as tooling support, smoother development, and a more flexible deployment situation.
1 Let each layer (presentation, application, domain, infrastructure) become a collection of single-responsibility components (making each layer implicit). Each layer of components is only allowed to talk to "lower" layers. Similar architectures, such as Onion and Clean Architecture, will also rely on components, but with different conceptual layers.
2 People sometimes suggest “use Hexagonal inside Polylith”, but that is misleading. Polylith already provides the core mechanisms Hexagonal aims to achieve: interfaces act as ports, components serve as "mini application cores" and outgoing adapters, and bases handle incoming adapters (see diagram below). With the small guiding rule of having pure domain components (along with other components) you automatically get the separation of concerns, testability, and replaceable dependencies Hexagonal promises. In other words, Hexagonal is not being embedded into Polylith — following Polylith correctly makes its benefits emerge naturally.
The diagram is taken from this blog post, where I explain Polylith through the lens of Hexagonal Architecture. It shows a base (1) delegating to a domain component (3) which communicates with three other domain components and two infrastructural components via their interfaces (4). As you can see, there are no ports, adapters, or application core here, only a base and a set of components.
2. Architectures that do NOT automatically emerge
Some architectures depend heavily on runtime behavior or distributed guarantees, which Polylith alone does not enforce:
Polylith provides a strong foundation with many benefits over other architectures, but it doesn't automatically implement runtime guarantees or distributed behaviors, so additional design is required for such architectures.
Summary
Ultimately, you can use Polylith as a base architecture, and then add additional design to achieve the desired behavior of your systems.
/Joakim Tengstrand
Beta Was this translation helpful? Give feedback.
All reactions