asset_monitoring_app_server
v1.55.1
Published
asset_monitoring_app_server
Downloads
1,358
Readme
Asset Monitoring Application Service
This repository contains the source code for the server configuration and setup for the IMI Asset Monitoring Application Server. The server listens on a port 4000.
The Asset Monitoring platform aims to leverage IoT device sensors on IMI's flow control products for near real-time monitoring and predictive maintenance. By shifting from reactive to proactive methods, utilizing sensor data, it provides timely insights and alarms, anticipating system failures and optimizing maintenance schedules. This enhances system efficiency and longevity while ensuring accessible information for all users.
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Prerequisites
Before we get started, we're going to need to make sure we have a few things installed and available on our machine.
Node >= 18.18.0
Minimum
MacOS
curl "https://nodejs.org/dist/latest/node-${VERSION:-$(wget -qO- https://nodejs.org/dist/latest/ | sed -nE 's|.*>node-(.*)\.pkg</a>.*|\1|p')}.pkg" > "$HOME/Downloads/node-latest.pkg" && sudo installer -store -pkg "$HOME/Downloads/node-latest.pkg" -target "/"
Other
See the installation guides available @ nodejs.org:
https://nodejs.org/en/download/package-manager/
Docker
Docker installed on your system. If you haven't installed Docker yet, you can download and install it from the official Docker website: https://www.docker.com/get-started
Docker Compose (MacOS)
brew install docker-compose
Starting the local database environment
cd prisma/local && docker-compose up -d
Ensure your container is up and running. List the containers to get the port
docker-compose ps
will log:
NAME IMAGE COMMAND SERVICE
xx-database postgres:13-alpine "docker-entrypoint.s…" database xx minutes ago Up xx minutes 0.0.0.0:65491->5432/tcp
Check the container's IP address, run:
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <NAME>
this will be the HOST value on your DATABASE_URL.
Check the container 's Port number, run:
docker inspect -f '{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{$conf}} {{end}}' <NAME>
this will be the PORT value on your DATABASE_URL.
Add the postgres connection URL to the environment variable DATABASE_URL with the format specified in the .env.example
postgresql://USER:PASSWORD@HOST:PORT/DATABASE
Generate Prisma
npm run db:migrate
npm run db:generate
npm run db:seed
npm run db:studio
Installing
Below is a series of step by step instructions that tell you how to get a development env running.
Create a local clone of the repository
git clone https://[email protected]/imicci/Asset_Monitoring_Project/_git/AM-APP-SERVER
Enter the cloned repositories' directory
cd AM-APP-SERVER
Install the projects dependencies
npm i
Create a .env
file based on the .env.example template (at the time of writing, no additional env vars are required)
Export the contents of the created .env
file to the current terminal session.
set -o allexport; source .env; set +o allexport
Start the projects development server
npm run start
The project should now be available at http://localhost:4000
Tests
To run the projects unit test simply navigate into the projects root directory.
Then run:
npm run test
The test results should appear in your terminal.
Deployment
Deployments are handled by Azure pipelines, below is an overview of how the deployments work:
- Dependencies are installed with
npm i
- Unit tests are run with
npm run test
- Application is built
npm run build
- Static assets are deployed to Amazon S3 and the cloudfront distribution cache is invalidated.
Environment Variables
These are the environment variables required to successfully deploy the application.
Repository Variables
| key | description | | ------------- ---------------------- |--------------------------------------------- | | API_BASE_URL | Base URL for the API | | ENVIRONMENT | Environment of the application | | PORT | Port number for the application | | LORIAT_API_KEY | API key for LORIAT integration | | LORIAT_API_URL | URL for LORIAT API | | DATABASE_URL | URL for the database connection | | SSL_CERT_BASE64 | Base64 encoded SSL certificate | | NO_REPLY_DOMAIN | Domain used for no-reply emails | | COMMUNICATION_SERVICES_CONNECTION_STRING | Connection string for communication services |
Deployment Variables
Each of the below keys need to be applied to each deployment (dev, uat, prod) and their values will be dependant on the environment.
| key | description | | ------------- ---------------------- |--------------------------------------------- | | API_BASE_URL | Base URL for the API | | ENVIRONMENT | Environment of the application | | PORT | Port number for the application | | LORIAT_API_KEY | API key for LORIAT integration | | LORIAT_API_URL | URL for LORIAT API | | DATABASE_URL | URL for the database connection | | SSL_CERT_BASE64 | Base64 encoded SSL certificate | | NO_REPLY_DOMAIN | Domain used for no-reply emails | | COMMUNICATION_SERVICES_CONNECTION_STRING | Connection string for communication services |
Built With
Details of the tech stack that has been used.
- Node.js - Javascript Runtime
- Express JS - Web framework for Node.js
Structure
Contributing
Please read CONTRIBUTING.md for details on the SovTech standard for commit messages and the accepted pull request process.
Versioning
We use SemVer for versioning. Versioning occurs automatically in the pipelines using Semantic Release. For the versions available, see the tags on this repository.
TODO: Implement SemVer
Changelog
A running changelog can be found here: CHANGELOG.md
Licenses
Place the result of npx license-checker --summary
here
├─ MIT: 457
├─ ISC: 13
├─ Apache-2.0: 7
├─ BSD-3-Clause: 6
├─ BSD-2-Clause: 4
├─ 0BSD: 2
├─ UNLICENSED: 1
├─ CC-BY-4.0: 1
└─ BSD: 1
Troubleshooting
Below are a few common issues users experience - including an overview of their possible cause and solutions.
Meta
| Version | Author | Date | | ------- | -------------------------------------------- | ---------- | | 0.0.1 | Yatin Badal [email protected] | 17/03/2020 | | 0.0.2 | Daniel Harten [email protected] | 15/06/2022 | | 0.0.3 | Daniel Harten [email protected] | 31/05/2023 | | 0.0.4 | Kuda Mhizha [email protected] | 24/05/2024 |