An awesome way to make scalable node backends.
The main goal of this article isn't to influence you to build your applications my way, it's to illustrate that programming is a creative business, and following everyone else's instructions only leads to building what everyone else has already built. You might make a lot of money building stuff out of Legos, but you won't make more than the guy who created Legos.
Frontends are more dynamic than ever, here's a wild idea to make backends just as dynamic.
Instead of storing your custom modules as files, store them in a standalone database. The code can be executed by the eval method.
Pros -
Code optimization plans become simpler, you can use database reporting tools to see what code is being called, and how often.
Using an object based database such as Mongo or Maria, has the ability to run in cluster mode, which allows event listeners to be attached to the database. This makes building a cloud IDE that allows collaborative real-time development (like Google Docs) much easier to build.
The above allows for automatic code versioning and developer tracking.
The above also allows for the ability to catch errors, and try to run previous versions of the same code when errors occur.
Development of AI becomes simpler, code fragments can be stored and dynamically assembled in real-time when needed.
Server efficiency is improved greatly as node instances run in a process thread. A user that is only using certain features of the application, isn't loading the entire application into memory, shrinking the size of that users thread. Threads become more dynamic.
If a data intrusion takes place, your source code is protected by requiring access to a separate system inside the LAN creating an extra layer of protection.
This can be made super secure by creating private keys that are not accessible to even the admin of the node server because they are dynamically created by the process threads independently in conjunction with the database server, this code is served to the node server also from the database, but from a different user.
Application updates in real-time, while the user is using the app.
The most beautiful pro yet, if platform as a service is your goal, your applications can borrow code from each other in an extremely simple way.
You'll be a rebel.
Cons -
Development occurs inside a database. Can't use VIM, Nano, or even VSCode to edit, requires a custom cloud based IDE. NOT THAT HARD TO BUILD OK?
While can be done on one server, should be done on at least 2.
The eval method is insanely dangerous, it executes code from a string. The core of the application must be write protected in production, and argument validation strictly enforced.
This is a new concept for a node application architecture, there isn't much of an online community supporting it.
NPM modules must remain outside the database due to dependencies. I'm currently writing a module to import and manage them into the db.
You'll be a rebel.
If you've read this far, I hope these ideas have inspired you to branch out more in what you develop. We have have so many tools.
The best architects challenge the best engineers. The worst architects challenge the best engineers. If you're going to be challenged, make sure it's worth it.