Over the past few decades, we have seen application architectures evolve at a rapid pace. When I was a young developer, I myself started writing a simple code base that we can call a monolith. I remember writing some HTML/CSS for the front-end and some PHP on the back-end. Those were the good old days, but then came the time and the need for distributed architectures, which we can now call microservices.
I am not going to paint you a picture about the fact that monoliths have become less and less desirable and a lot of developers have started to preach about microservices. Because microservices offer these benefits:
However, regular and sometimes extended use of microservices has some drawbacks:
But as any wise developer will tell you, the answer to any architectural choice is always “it depends”.
So this monolith vs. microservices debate made me realise that in a well-decoupled architecture we “only” have to deal with 4 different parts at most:
From this familiar pattern, we already have the appropriate tech stacks:
If we care about simplicity, I think there is room for improvement. We should also agree on how much of each part of the tech stack we need:
N = (2 * UI) + (1 * BFD) + (3 * DB)Again, as the saying goes, “less is more”, so our aim is to try and reduce this number (N) to the absolute minimum.
Keep It Simple, Stupid.
An incredible evolution that we have seen in the past has been the creation of several front-end meta-frameworks. The most notable areNext.js,Remix andSvelteKit. The goal of a meta-framework is to handle both the front-end and the back-end sides of the front-end (yeah, that does not sound smart when you say it like that). In other words, it means building UI + BFF with a single technology.
And thanks to today’s Cloud and hosting solutions likeVercel, we can easily deploy meta-frameworks in a Serverless mode.
N = META-FRAMEWORK + (1 * BFD) + (3 * DB)From there, we reduced the number of technologies by 1… for each front-end!
There is also a trend right now for solutions around Database as a Service (DaaS) or I should say Backend as a Service (BaaS). The goal of a BaaS is to provide all the functionality that your application needs so that you don’t have to write a single line of code on the backend. All you have to do is write queries inside your BFF and voilà.
The best known BaaS is undoubtedlyFirebase, which offers a myriad of features such as a real-time document database, an authentication service, a permissions mechanism on top of the database, a file system storage, and so on…
However, Firebase has some serious limitations:
There is alsoSupabase, another famous BaaS trying to match Firebase. Using a relational database like PostgreSQL removes some of the limitations of Firebase, but it is still a single-model database…
One project that has caught my attention recently isSurrealDB. It is a database with a built-in backend that has many, many features (and I think I did not write “many” enough). Being a true multi-model database and with a new kind of query language, they are able to provide features that should have forced you to write some code.
In recent times, this type of database has become more and more widely known as a meta-database.
N = META-FRAMEWORK + META-DATABASE
And from there we drastically reduced the number of technologies at another level.
As with microservices, writing monoliths means having the right toolbox. A toolbox that removes the constraints we usually deal with, such as:
With this architecture, the need for a pure and holistic monolith (front-end + back-end) is out of the equation. However, the meta-framework is the part where more than 80% of the code will essentially reside. And for that, there are now tools you can use, such asturborepo.
One thing we have not mentioned is the inevitable need for script migration for the database. Of course, these scripts need to be stored in a separate repository. Nothing fancy here.
In conclusion, we achieve the ability to consume only 2 technologies in our tech stack. First, a meta-framework to handle the front-end logic, and then a single “framework” to handle the back-end.
It all makes sense because you have the data on one side and the user interface on the other.
At the moment, I do not think it is a viable decision to have only one solution to do everything. If you think otherwise, please let me know in the comments.
Software designer, open-minded, Lean being and UX advocate.