Coder Social home page Coder Social logo

chaitanya1010 / thermometer Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 24 KB

This is a MEAN stack application to view the records added in a chart for a given device for the give time(hour/day/month), and to add a new device information.

JavaScript 37.51% TypeScript 45.87% HTML 7.10% CSS 9.52%

thermometer's Introduction

Thermometer

  • Project outline
  • Technologies used
  • Installation process
  • Database design
  • End points
  • Points assumed

Project outline:
This is a MEAN stack application to view the records added in a chart for a given device for the give time(hour/day/month), and to add a new device information. This project is a dashboard for a thermometer and has features like adding device, adding records from the device, viewing records according to last 1 hour/day/month on a graph in real-time.

Technologies used:
This project was developed in MEAN stack and Chart.js is used for drawing graphs.

Installation process:
There are two folders frontend_code(which has the angular codes) and server_codes(which has the express code). There is a package.json in each of the folders. After cloning the repo, run npm install by navigating to both of the folders through terminal.
cd \to_the_destination\frontend_codes\thermometer && npm i
cd \to_the_destination\server_codes && npm i
To start the node server, run nodemon index.js in the server_codes directory.
To start the Angular process, run ng serve -o in the thermometer directory.

Database design:
You can configure the connection to mongoDB from the file db_con.js and add a database in your mongoDB with name 'thermometer'.
The mongo DB has two collections: reading_collections, device_collections
reading_collections: stores the readings of individual thermometer for the given time.
Has attributes device_id(the device this temperature belongs to),temperature(the temperature stored for the given device at a given time),created_at(the time when the temperature is added in the database)
device_collections: stores the records of individual thermometer device.
Has attributes actual_device_id(the device id that is added by user),user_name(the name of the owner the device belongs to),device_bought_at(the time when the device is added into the database)

End points:
There are total 6 end-points in Express.
/thermometer_apis is the prefix for all the below requests.
/get_device : to search device with the given ID.
/add_device : to add device the given ID.
/fetch_data_hour : to fetch data the past 1 hour for the given device.
/fetch_data_day : to fetch data the past 1 day for the given device.
/fetch_data_month : to fetch data the past 1 month for the given device.
/add_temperatures : to add random temperatures for a given device every 5 seconds

Points assumed:

  • When a device is being inserted we would check if its ID exists and if it does then the device won't be added again and only if the ID seems new we shall add the device.
  • When the end point for adding temperatures is used, for every 5 seconds a random temperature is added to the mongoDB. This works in the background as long as the node process background, a simple restart of node process would stop the insertion.
  • Since for every 5 seconds a new record has been added into mongoDB, I thought it would be better to aggregate the temperatures and display them in a chart.
    • For month based records, day-based aggregation happens.
    • For day based records, 30-mins aggregation happens.
    • For hour based records, 10-mins aggregation happens.
  • CORS is by default enable for all routes and one can configure it using the middleware of CORS.
  • A middleware is added to check if the device exists or not for many of the routes.
  • The graph reloads every 10mins as it is the min average for which we shall be taking the times

thermometer's People

Contributors

chaitanya1010 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.