Git Product home page Git Product logo

atmoeyes-demo's Introduction

AtmoEyes Demo


What is this?

This repo contains all the code used for the demo presented by Group A of UNIPA (Università degli Studi di Palermo) for "Samsung Innovation Campus 2021 Smart Things Edition" in Palermo. Eventually 3 of the 4 members of Group A (atmoeyes) won the edition.


Below are developement notes.




Routes


/frontend

URI Method Description
/ GET Live Map page

/backend

URI Method Description
/data/aqi GET Returns GeoJSON aqi data layer
/data/aqi/send POST Send sensor data to aqi data layer (CURRENTLY UNPROTECTED)

Data


AQI Data - Post Body

Value Lon Lat
Int Float Float

GeoJSON Structure


{
    "type": "FeatureCollection",
    "features": [
        {
            "type": "Feature",
            "properties": {
                "aqi": 7
            },
            "geometry": {
                "type": "Point",
                "coordinates": [-30, 10]
            }
        }, 
    ...
}

Frontend code maintenance


Specify project specific parameters in .atmoeyes

{
    "backendUrl": "https://emanuelemessina.altervista.org/uni/ssmic2021/atmoeyes/backend"
}

Backend code maintenance


Routing Flow

  1. Calls to /backend are redirected to kernel.php via .htaccess RewriteRule.
  2. kernel.php - calls db, calls router.
  3. /db.php - initializes db connection, declares db methods.
  4. /router/router.php - declares route matching methods, calls routes.php.
  5. /router/routes.php - sets application/json response header, calls declared routes, which are then parsed by the router. If no match is found, 404 is thrown.
  6. When a match is found, execution is passed to the matched route controller.

Examples


Update a record with QuickQuery

$input_schema = [
    "id" => "int",
    "value" => "int"
];

$qq = new QuickQuery('json-input', $input_schema);
$validated_data = $qq->getValidatedData();
$response = $qq->update(
    'data', // table
    ['value'], // fields to update
    [ // where clause
        'id' => $validated_data['id'] 
    ]);

echo json_encode($response);

Validation is automatically done and all errors are reported in the response.
Table names are already prefixed with 'atmoeyes_'.


Declaring routes in routes.php

get('/data/aqi/$optional_get_param', 'aqi-data.php'); 
  • Controller files are placed under /controllers.
  • Optional GET parameters are accessible in the controller via $parameters array.

Docs



Info

CAQI

Mapbox

Heatmap

Live Data Updates

PHP

PHP Router

Medoo

Firebase

Get Started

atmoeyes-demo's People

Contributors

emanuelemessina avatar

Watchers

 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.