Skip to content

oSoc19/RoadReport-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Road Report (Server Part)

This part of the project includes the API and the website

Application . View Demo . Report Bug . Request Feature

Table of Contents

About The Project

Road Report

Road Report is an application that enables citizens to report problems such as potholes they encounter in the city.

Road Report gathers data from citizens who use this app and sends this data to our partner TMaaS, who helps the city of Ghent to spot these problems quicker and effective. This improves the sidewalks and cycling paths for you, making life in the city a nicer experience for everyone.

Built With

Getting Started

This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.

Prerequisites

Basically you need to have a NGINX server(manage website and proxy), MySQL Server (store data), and PHP≥5 (process the data) installed, MapBox API Key and BeSt@ Service.

Website configuration /etc/nginx/sites-available/roadreport.conf:

server {
	listen 80;
    server_name  example.com www.example.com; #your domain(s)
    root         /var/www/html; # directory of the roadreport website
    index        index.php index.html index.htm;

    access_log /var/log/nginx/access.roadreport.log;
    error_log /var/log/nginx/error.roadreport.log;
    client_max_body_size 64M;

    location / {
        try_files $uri $uri/ /index.php?$query_string&query=$uri;
        autoindex off;
    }

    location /best@ {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_pass https://best.osoc.be/v1/; #Address to the BeSt@ service
        proxy_redirect off;
    }

    location ^\.git {
    	deny all;
    }

    # include your php configuration
}

make a symbolic link for nginx

ln -s /etc/nginx/sites-available/roadreport.conf /etc/nginx/sites-enabled/roadreport.conf

Installation

  1. Go on your SSH server et select the empty directory where you want install the website and the API
cd /var/www/html
  1. Clone the repo
git clone https://github.com/oSoc19/RoadReport-backend.git .
  1. Install database with setup/database.sql
mysql -u <your-database-user> -p <your-database-name> < setup/database.sql
  1. Remove setup folder
rm -r setup
  1. Edit the inc.d/settings.php file
	$settings = array(
		...

		"my" => array(
			"hostname" => "< your database host >",
			"database" => "< your database name >",
			"username" => "< your database user >",
			"password" => "< your database pass >",
			"instance" => null
		),
		"mail" => array(
			"ReportTo"	=> "< email that will receive all reports >",
			"from"		=> "< sender's mail >",
			"SMTPDebug"	=> 0,
			"isSMTP"	=> true,
			"Host"		=> "< stmp server host >",
			"SMTPAuth"	=> true,
			"Username"	=> "< stmp server user >",
			"Password"	=> "< stmp server pass >",
			"SMTPSecure"=> "ssl",
			"CharSet"	=> "UTF-8",
			"Encoding"	=> "base64",
			"Port" 		=> 465,
			"instance"	=> null
		),

		"api" => array(
			"mapbox"	=> "< your mapbox api key >"
		)
	);

Structure

Object Report

Field Type Description Required
problem number The id of the problem that happened Yes
comment text Comment describing the problem Yes
location location Object describing the location Yes

Object Location

Field Type Description Required
street Text The street where the problem is Yes
number text The house number where the problem is No
city text The city where the problem is Yes
longitude number The longitude of the location (like: X.XXXXXXXXXXXXXXXX) No
latitude number The latitude of the location (like: XX.XXXXXXXXXXXXXXXX) No

List of problems (default)

## Problem ## Problem ## Problem ## Problem
1 Hole in footpath 2 Hole in bicycle path 3 Damaged footpath 4 Damaged bicycle path
5 Unclear marking pedestrian crossing 6 Unclear marking bicycle path 7 Snow, frost, slipperiness 8 Glass
9 Blocked guiding lines for blind people 10 Obstructive intake of footpath 11 Obstructive intake of bicycle path 12 Sign gone/moved
13 Traffic light defect 14 Traffic light button defect 15 Problem with VMS sign 16 Bicycle counter defect
17 Always full 18 In need of reparation 19 Weed / trash 20 Left bicycles
21 Suggestion for sheltered/indoor bicycle rack 22 Broken cycling pump 23 Broken/empty cycling lights vending machine 24 Broken repair machine
25 Unaccessible footpath for wheelchairs 26 Dangerous crossing for cyclists/pedestrians 27 Dangerous situation for cyclists/pedestrians 28 Crowdedness on footpaths
29 Missing/defect street lights 30 Other

Example of json report

{
	"report" : 
	{
		"problem" : "10",
		"comment" : "Something happened",
		"location":
		{
			"street" : "Randomstreet",
			"number" : "1-12b",
			"city"   : "Brussel",
			"longitude":  4.3496181131285745,
			"latitude" : 50.86576889787819
		}
	}
}

Usage

  • Access to the website, just go on the dedicated domain:
     GET http://example.com
    
  • Access to the dashboard (default login:: username: moderator; password: TheGuardians!)
     GET /dashboard
    
  • See the list of problems for a specific day (ie: the 19th July 2019)
     GET /problem/2019-07-19?page=1
    
  • See a specific report (ie: report #42)
     GET /problem/42
    
  • Update the status of a report (possible values: REPORTED, FIXED or REMOVE)
     POST /problem/update
    
    Request body (ie: The report #12 is fixed)
     {
     	"id"    : 12,
     	"status": "FIXED"
     }

Note

WARNING: The report object doesn't include CSRF token or captcha system

Contact

License

Distributed under the MIT License. See LICENSE for more information.

Acknowledgements

About

a cyclist and pedestrian app

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published