Plantrol

hey
Live demo

Context

  • Timeline: March – June 2021.
  • Type: Group project.
  • Course: IDG2671 - Web Project.
  • Role: Back-end developer.
  • Tools: React.js, Express, Node.js, MongoDB, Mongoose, Passport, Swagger, Nodemailer, PassportJWT, Bcrypt and Yup.

Purpose of this project

Plantrol is a tool designed to keep the plants decorated around Mustad maintained. Mustad is part of the campus at NTNU Gjøvik. The problem we were presented with was that the plants either got too much or no water. The solution was to create a tool that made it easier for those who watered the plants to know when the next watering should occur.

The idea was that the students could scan a QR code to see the plant's information, when it was last watered and that it was possible to send a notification that the plant needs irrigation.

The gardeners who maintain the plants can see plants that need to be watered, postponed, or see information about the plant.

An administrator can add, remove, or change the location of the plants. An administrator can also add or remove gardeners from the tool.

Strengths

  • Well documented
  • Tailor made for Mustad.

Potential improvements

  • Gzip Compression or reverse proxy
  • Query optimization
  • Deploy to a single DigitalOcean droplet
  • CloudFlare CDN

Gzip Compression or reverse proxy

Using GZIP compression reduces the size of the response body, increasing the speed of the web application. Although if the website has high traffic the best implementation is to use a reverse proxy. The reverse proxy can handle compression, caching, serving files and do load balancing among other things.

This will benefit the gardener that waters the plants at Mustad. Mustad has a lot of brick walls that can weaken the WIFI signals and smaller payloads will reduce the amount of time it takes to download the plant information. For example, when watering a plant that is in a corner far away from the next access point.

Query optimization

MongoDB uses indexing to make query processing more efficient. If there is no indexing, MongoDB must scan every document in the collection and only retrieve those documents that match the query. In short, indexes are special data structures that stores some information related to the document so that it becomes easy for MongoDB to find the right data file.

Creating better indexes for Plantrol will increase the performance when querying for plants that need watering. This will reduce the amount of time it takes for retrieving plant information and will in result create a better experience for the gardeners using Plantrol.

DigitalOcean droplet

Plantrol is currently deployed to Heroku which is free and will shut down the back end after a certain amount of time. Deploying both front-end and back-end to a single Digital Ocean droplet with a reverse proxy will both benefit the payload size (compression), increase the performance of the application, and ensure that a gardener will not have to wait 20 seconds for retrieving plant information.

Cloudflare CDN

Using Cloudflare as CDN enables caching of plant information at an edge server near Mustad. Cloudflare ensures that all their edge servers are using green hosted energy, this will make sure that Plantrol is hosted green.

What would i have done differently?

If I had recreated the back end of Plantrol again, I would have implemented measures to improve the performance. Currently the front-end is requesting the same plant information every time from the back end which is fetching data directly from the database. Considering that the gardeners will not access the data every day, updating the plant state would make it possible to cache the plant information at an edge server. The lifetime of the cache would be set to the next time a gardener updates any plant. As a result, the back end would not have to fetch data directly from the database, but rather provide already cached data every time an anonymous user (students, employees, etc.) is browsing Plantrol.