Building software that works is one thing, building software that last is another, especially when the code size increases rapidly together with the number of people involved in its development.

In this article we will go through some maintainability issues and techniques to avoid them, using a  nodejs web server built with  Fastify (web framework) and  Mongodb (database) as example.

Definition of the web service.

This particular service is a simple  CRUD store for movies, but for many web services, you can scatter in the same way their various components somewhere along a line:

diagram of web service components stack

The bits on the left are very common and have probably little added value for your specific application. The relative value of your service lies in the data you have/collect and what you do with this data (the business logic).

It is important to note that the borders between the layers are not strict and may vary for different projects.

For example, a team with high skills in RDMS can do data aggregation and statistical calculation within a SQL query/function while another team will chose to do the same in the application code, finding it easier to maintain and test.

However, separating the different concerns will ease the maintainability of the codebase anyway, that is what we are going to review here.

#javascript #fastify #clean-code #nodejs

Separation Of Concerns: Example with A Nodejs-Fastify-MongoDB Stack
1.35 GEEK