Code Monkey home page Code Monkey logo

river-levels's Introduction

PROJECT STRUCTURE AND LIBRARIES

The web application uses React for the front-end and a Node Express app for the back-end. The two communicate through a proxy set up on the React side. The way this works is, any time the React app makes a request to something that’s not a static asset (not an image or CSS or index.html, basically), it will forward the request to the server specified in the proxy which will be the Express app running on a different port. All of our other dependencies are listed in the package.json of the respective project.

CODE STRUCTURE

  • FRONT-END

The code for the React app is split into pages and components. Starting point is the App.js component which depending on the tab you've clicked on will render one of the four pages. These pages make use of the different components we've created as well as ones we've imported.

  • BACK-END

The bulk of the code for the back-end is in index.js. You can see all of the express routes there as well as functions for connecting to the MQTT server and for making all the REST requests needed. dbConn.js creates a mysql connection to the database using the credentials in the config file. queryHandler.js then uses this connection to manipulate data in the different tables. All queries are parameterised in order to avoid SQL injection. The advantage of using this config file is that the credentials are never hard-coded and different credentials with different access rights can be easily distributed if need be.

DATABASE

We're using a database on dragon which has 5 tables - 2 that hold details for the sensors you've provided and the ones that are relevant for Canterbury from the Environmental Agency, 2 that hold all the logs for these sensors and a table that has the location and email address and phone number of all users that have subscribed for alerts.

SUBSCRIBING AND ALERTS

Users can subscribe to receive daily updates on the conditions of the river. In order to do so, you first have to search for a location on the map and then click the subscribe button. You'll then be able to enter your email, phone number, or both. You'll receive a welcome message after doing so, and then every day at 9am you'll receive a detailed email or text message notifying you of the current river levels and flood alerts.

TEST MODE

In order to test the functionality of the application, you can enter your email or phone number to receive an instant flood alert message.

river-levels's People

Contributors

nikkkola avatar ivan-kasabov 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.