README
nxn-boot
framework for large scale applications, supporting configuration file, services, routes, express middleware, client data.
This npm module addresses requirements of medium to large applications.
Included in this framework:
Modular development :
- applications are organised with : services, routes, test, models, scripts, nodes that are written as js classes.
- code can be generated using "nxg" (ex. nxg service myapp/mysce generates a class /applications/myapp/services/mysce.service.js). nxg is a npm cli (@nxn/cli)
- each service/route/test/script can use configuration parameters that are managed by the framework (thanks to @nxn/config package). Configuration is written in json or yaml.
- the framework supports "nodes" that are services with a "message" interface similar to Node red nodes and injections. A node implement a functionnality (ex. read Google buckets, mongodb collections, files, etc.) and are linked to other nodes (ex. parser, writer to another DB, etc.) with injections. A Node : "process" received message, do something and send message(s) to connected nodes.
Application = Configuration : application are organised as:
- code of the application : organised as services, nodes, tests, etc.
- a "boot" configuration that executes the application modules. we can then define one or several configurations that use applications module, and thus implement several versions of applications with the same code base. An exemple is to run a local application with mongodb for testing, and the same application running firestore when deployed on GCP. Because of the modular design, the application doesnt need to know which db it runs with..
Multi tenant and multi applications :
- it is possible to have one or several "clients" on the same project. nxn boot supports a "client data" directory where all information/data related to a client is stored.
- an application is actually a configuration and can be deployed to several clients.
Management of express middleware :
- main index.js file doesn't need to be modified. It is generated by the nxg CLI and is the same for all applications. Nxn boot use middleware that is requested in the configuration file (ex. cors, json, etc.). Middleware are also written (ideally) as classes.
- express can be used along with nxn boot if the application implements an API. But an application can also be written as a programm that execute tasks at specified times (using "cron" service that executes "tasks").
This framework is inspired by :
- Angular : injections, services, components and cli
- APIGEE : management of middleware,
- node red : implementation of flow based applications, granular configurations of each node and service,
- PHP propriatery framework from PresenceSoft : multi tenant architectures (client data) and "applications as configuration",
- low code frameworks : granular and independant tasks for creating a functionality.
- OAS / Swagger : configuration oriented spec and $ref() in YAML
The framework is best used with other modules from @nxn:
- files : service providing async access to files,
- cli : generating code,
- config : for reading configuration files in YAML, json or env formats,
- google : a set of services and nodes for accessing google APIs in a "configrable" way (bucket reader/writer, firestore, auth, etc.)
- ext : tools extending arrays, objects and strings,
- db : mongodb and mysql.
How to use it : Install boot: npm install @nxn/boot
Install cli globally : npm install @nxn/cli -g
Use cli to generate application and default config & client data: nxg client default
run application: node index.js default config or node index.js
Words of caution nb. the cli tool is very convenient for generating services and nodes. It needs to be improved so that we can generate the main app, configuration, etc. and alos update the config files automatically when a node or service is added. This will come soon, although the focus now is on the nodes themselves and further integration with Google products and other APIs. In its current version, it is similar to Angular CLI tool for generating components : it generates code. But like Angular CLI, it idoesn't yet declare the components in the list of modules/nodes config. So still a bit manual. The goal it to complete it so that it goes the extra mile and declare the node/service in the application config. Just like node-red does when a node is added to the config....
The latest version of @nxn/config is very promising as it provides lots of flexibility in writing configuration with variables, environements and inclusion of other files.. We'll come back to that point later as this opens paths to other ideas...