Modular Monolith Application in Symfony
A truly modular monolith application project in PHP
What software architecture would you choose if you were to launch a SaaS startup today? I bet the first thing that comes to your mind is an architecture based on microservices.
There is no serious programming conference these days without at least one topic related to microservices.
No wonder; the topic is so overhyped nowadays:

Many companies embraced such architecture and died in the run. You are going to find a lot of great stories how microservices went wrong for some entrepreneurs.
Netflix started as a simple DVD movie rental system. They did not become the powerful system that we know overnight. It was a process; and it took many years to develop. From a monolith-based application to this monster:

The microservice architecture is, well, hard.
Microservices are supposed to be independent of each other. There are no microservices if they share a database or some other resource.
With five microservices, we are talking about five separate database servers, five Redis instances, five reverse proxy servers, five PHP-FPM processes, etc. And I haven’t even touched the High-Availability topic yet.
There are increasing issues with: debugging, latency, deployment, infrastructure, infrastructure costs, logging, monitoring, service discovery, access management, cost management, etc. The costs rise exponentially.
I do not think a starting business needs such complexity. A correctly written monolithic application is a breeze to work on and deploy.
When starting a business, you want to launch with an MVP. If the venture works out and starts earning serious money, there is nothing to prevent a monolithic project from transforming into a microservice-based architecture. Only then do you have the means to run such architecture: people and money.
In a well-written, high-quality monolith application, such transformation should be painless; as long as the modules are truly independent.
Why does hardly anyone today appreciate monolithic architecture?
How about we try to design such a modular monolith from scratch?
The idea for the application
I am not earning enough on Medium to spend too much time on this project (claps won’t feed my kids, will they?)
Still, I would like it to be somewhat practical: a book store system — a domain that probably all of us are familiar with.
Let’s define some goals, shall we? It would be a web-based application written in PHP 8, based on Symfony 6:
- where people could browse books,
- register and buy books,
- books would be delivered by post,
- the buyer would receive a receipt by e-mail,
- people could be notified when a book becomes available to purchase,
- composed of independent modules with boundaries enforced by Deptrac.
Well, I got a bit carried away, but I already love the idea and I am thrilled to start coding. You know the feeling, right?
I will notify you promptly when I start working on the project. I sincerely hope it’s going to be a useful resource for you.






