microvolt-lib
v1.0.282
Published
NPM library for MicroVolt webservice architecture
Downloads
27
Maintainers
Readme
microvolt-lib
NPM library for MicroVolt webservice architecture
Building web applications can be hard. No longer can an application survive in creating a monolithe to perform everything. They are not suited for quick development, expanding features easily and for multiple teams to easily collaborate and test on a single code base. Additionally, every web application require very similar basic functionality, including, but not limited to: database, database schema evolution, web requests, intra-service communication, cache, session management (register, login, tokens, SSO, etc.). To higher level services that are found common in web applications, including: Email, SMS, reporting, activity, in/outjest from/to external services, e-commerce and more.
The concept is to have a common set of capabilities that work out of the box and that can be easily extended to meeting the business needs of the web application.
This is a project to create a microservice framework based on Node.js. It is currently being tested on Google Cloud but other hosting environments are planned.
The code base is entirely TypeScript. No Kubernetes required.
Status:
Complete:
- Base microservice class
- Sample microservice
- Database and query abstraction for Postgres
- Dynamic database table setup and seeding
- Session microservice implementation (register, login, auth)
In Work:
- Hub microservice implementation
- Web service implementation
- Actions/events registration and notification
- Email microservice implementation
Planned:
- Data cache layer
- AI microservice implementation
- Activity microservice implementation
- Database abstraction for MySQL
- Database abstraction for NoSQL (e.g. MongoDB)
- ZIMM implementation
Goals:
- Object Oriented Typescript with good design patterns
- Ease of adding new services
- Fast horizontal scaling
- Easy deployment and versioning
It shall include:
- Easy to create new sertvices
- Includes "hub" service to manage:
- Service registration and lifecycle
- Service configuration
- Events/actions between services
- Service discovery
- Includes "webserver" to host static files and act as a gatway
- The hosting environment(s) selected will manage horizontal scaling of services
- Other canned services shall included
- Session management (login, registration, authentication, throttle limits)
- ETL to reporting database
- Activity Service
- Email Service
- Input/Output (web hook) Service
- File/CDN Service
- Report Service
- Import Service
- Zapier Service
- Commerce Service (cart, multi-currency, payment, zipcode/address verification; factory:stripe)
- SMS service (factory: twilio)
- Product Service
- Order Service
- Customer Service
Notes:
Google Deployment Notes:
- For each project this is being deployed to, you will need to:
- Add IAM Role to include Secrets Manager + Secrets Accessor or you will not be able to access saved secrets in the app. You will get a permissions denied even though the project has Edit access to do everything.
CONFIGURATION:
=================== For configurations that contains sensitive information (e.g. passwords) should never be stored in code (hard coded) or in coniguration files that would get checked-in to GIT. This is a major security violation.
Configuration variables being used for secrets or environment variables are case sensitive and should only include letters and underscoress (_). Google Cloud does not allow periods (.) and environment variables do not allow for hypans (-). This will be enforced to avoid needless errors in the different environments.
In Google Cloud, those kinds of configuration variables shold be stored in the Secrets Manager. In the service configuration file, you may set:
"secrets" : { "root" : "projects/<PROJECTID>/secrets" }
Where <PROJECTID>
is the project id for the project of the app engine.
Each environment (e.g. development, staging, product) have unique projects so
each environment will have a unique configuration file (e.g. local.json, development.json, production.json).
In the configuration file, all will need to do is set that variable to indicate that it is a secret. For example:
"database" : { "host" : "secret:hub_db_host/versions/latest",
"port" : "secret:hub_db_port/versions/latest",
"name" : "hub",
"username" : "secret:hub_db_username/versions/latest",
"password" : "secret:hub_db_password/versions/latest" }
Anything prefiexed by "secret:" will assume that it is to be accessed in the Secrets Manager. Note for Google, you can have different versions of the variable to not to break currently deployed versions of your microservce.
For Local developent, you can store sensitive information as an environment variable. So a local.json file may look like:
"database" : { "host" : "env:hub_db_host",
"port" : "env:hub_db_port",
"name" : "hub",
"username" : "env:hub_db_username",
"password" : "env:hub_db_password" }
The prefix of "env:"
will look for the locally set environment variable.
For Windows, you can set the environment varialbe(s) from the Windows GUI or from the terminal prompt by:
$env:hub_db_password = 'passwsord1'
To verify that it is set:
dir env:hub_db_password
Unless set locally, you may need to restart your Windows computer to see the environment variables.
This is a work in progress...