# Current architectures

Let's have a quick look at some of the mainstream software architectures before we compare them to Polylith later on.

We'll describe our development and production experiences with three mainstream software architectures. But we'll start by defining our terms:

{% hint style="success" %}
**Software architecture:**

* The **high-level** structures of a software system
* Fundamental structural **choices**, which are **costly to change** once implemented
{% endhint %}

{% hint style="info" %}
**Monolith:**

* A software architecture where the code is stored in a **single codebase** and deployed as a **single artefact**
{% endhint %}

{% hint style="info" %}
**Microservices:**

* A software architecture consisting of **small** and **independently deployable** services
* Each service runs in a **separate process** and communicates with the others across a **network**
{% endhint %}

{% hint style="info" %}
**Serverless:**

* A software architecture based on a **cloud-computing** execution model
* The **cloud provider** dynamically **manages** the allocation of machine resources
{% endhint %}

### Development experience

{% hint style="warning" %}
The traffic lights are a rough summary of our personal experiences. Please take them as our subjective opinions, not as objective truths.
{% endhint %}

{% hint style="info" %}
We split the ratings into "small" and "large", because building larger and more complex systems usually gave us a different experience.
{% endhint %}

![Our subjective development experiences](https://3095132514-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAhrWK1psIWk5h5zNLV%2F-LMh-mwpiFVmJF_rCqh9%2F-LMh-s5bMJuCTQ7B9CB1%2FDevelopment02.png?alt=media\&token=9a047027-8e23-4d95-8fbf-cacc50e783cf)

Monoliths keep all their code in one place, which gives a friction-free development experience for code navigation, refactoring, debugging, code reuse, and testability. However, as Monoliths grow, they trend towards "big balls of mud", which become very difficult to maintain.

Working with a single Microservice is great, as it gives us the same benefits as working with a small Monolith. However, the more Microservices we maintain, the worse our development experience becomes. That's because each new service boundary increases the friction for code navigation, refactoring, debugging, code reuse, and testing.

Serverless architecture is inherently modular and functional, which gives significant advantages for simplicity and testability. However, the distributed nature of its code execution has a negative impact on our code reusability, debugging and testing.

### Production experience

![Our subjective production experiences](https://3095132514-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LAhrWK1psIWk5h5zNLV%2F-LMh-mwpiFVmJF_rCqh9%2F-LMh0-8KqNHH1oouolN_%2FProduction02.png?alt=media\&token=756ccefb-c347-44f7-ae67-eb67841ffc13)

Monolith's one artefact approach keeps operation costs low and simplifies deployment, but makes horizontal scalability difficult.

Microservices' distributed approach gives excellent scalability and robustness, but makes deployment complex and hosting expensive.

Serverless' "outsourcing" approach gives excellent scalability, reduces our ownership of deployment complexity, and keeps server costs in-line with our usage, but also gives us an air-tight vendor lock-in.

### So what's missing?

These architectures give us plenty of guidance on how to _deploy_ our systems, but very little guidance on how to _structure_ our code within each system. Over the years, we've tried many different approaches to improve our systems' internal structures (e.g. [DCI](https://en.wikipedia.org/wiki/Data,_context_and_interaction), [DDD](https://en.wikipedia.org/wiki/Domain-driven_design), [Design Patterns](https://en.wikipedia.org/wiki/Software_design_pattern), [SOA](https://en.wikipedia.org/wiki/Service-oriented_architecture), [SOLID](https://en.wikipedia.org/wiki/SOLID), [Hexagon](https://en.wikipedia.org/wiki/Hexagonal_architecture_\(software\)), etc.), but none of them took us all the way to development nirvana.

To get there, we realised we needed to roll up our sleeves and invent a whole new approach.
