Most of your application should just be Postgres
Right now, at this very moment, an untold number of software developers all around the world are hard at work solving the exact problem in a thousand subtly different ways.
The problem is how to:
- receive requests for data
- check whether the requesting party is allowed to access the requested data
- fetch the data from a database
- restructure the fetched data
- serialize the resulting data into JSON or render some HTML based on it
Sure, there are many minor variations for each of these steps, and requests to write to the database open up a whole range of other complications (which I’ll talk more about below). But these five steps cover a huge chunk of what is called web backend development. Instead of working on intrinsically hard and interesting domain-specific problems, many of us spend inordinate amounts of time trying out some new constallation of languages, frameworks, libraries, and “best practices” just to accomplish these five steps.
It’s almost as if we were dealing with one of the big, unsolved problems of computing here. Well, we’re not, and there is a simple solution that will remove countless layers of error-prone code from your system:
Just let Postgres do the work for you.
Contrary to common opinion over the last 20+ years, the thick database architecture is an excellent foundation for most typical web apps.
- Delegate as much work as possible to the database
- Put business logic in the database
- Place the database at the center of your architecture
- Reinvent functionality that has been
You do need some auxillary lightweight pieces of tooling, but you will end up with a system that is radically simpler, more performant and robust than your current MVC edifice or tangle of services.
Let me go through the steps above in order to convince you that Postgres is (almost) all you need.
postgrest, postgraphile, hasura
nginx, openresty got most of this from postgrest
This is where things start to go really crazy
This should be dead simple, and whenever it isn’t should be considered a smell.
How about writes?
Will address performance, workflow, source control. Stay tuned.
Advanced relational database systems like Postgres have been built to handle most of the
Why Postgres specifically?
Gnarly controllers, each looking different than the other. Model classes that no-one dares touch.