/code-20210609-shravankumar

This repository hosts a node application which calculates vitals of a data set

Primary LanguageJavaScript

Simple Vitals Calculator

An application which categorizes people based on the vitals (height and weight). It computes the health risk and category under which the people fall based n BMI(Body Mass Index).

People fall into category/health risk based on the bmi computed by height and weight vitals.

Below table shows the category and health risk based on BMI value

BMI Range Category Health Risk
18.4 and below Underweight Malnutrition risk
18.5 - 24.9 Normal weight Low risk
24.9 - 29.9 Overweight Enhanced risk
29.9 - 34.9 Moderately obese Medium risk
34.9 - 39.9 Severely obese High risk
34.9 and above Very severely obese Very High risk

This is a node application which runs with express, it loads the one-million-input.json file found in src/resources which contains one million sample vital data set that the app uses and serves the request through below mentioned endpoints. The data set is generated by a python script data_set_creator.py.

Endpoints configured

There are two routes to the application

  1. Route to show people vitals http://localhost:3000/peopleVitals/10
  2. Route to show count of people classified as overweight along with the people vitals http:/localhost:3000/overweight/people/10

Generating the data set

python3 data_set_creator.py
mv src/resources/one-million-input-1.json src/resources/one-million-input.json

Running the application in local

  1. Ensure you have npm installed.

Follow the instructions for your platform here.

  1. Install all dependencies:
npm install
  1. To run jest tests
npm test
  1. To start the express application
npm start

The server is now running at localhost:3000

Running the application as container

  1. Ensure you have docker installed.

Follow the instructions for your platform here.

  1. Build the container
docker build -t ${user-name}/${application-name}:${version} .
# example
docker build -t shra012/simple-vitals-calculator:latest .
  1. Run the container
docker run --name ${container-name} -p 8080:8080 -d ${user-name}/${application-name}:${version}
# example
docker run --name simple-vitals-calculator -p 8080:8080 -d shra012/simple-vitals-calculator:latest

CI Pipeline

This application is built with github actions and published to docker hub as a image. CI has a two individual jobs "test" and "docker".

  • Test work flow runs npm tests on the current commit.
  • Docker work flow builds and publishes the docker image to docker hub under the tag shra012/simple-vitals-calculator:latest.

Observations

  • Data set file path is hard coded in the app.js which makes test use the actual data set.