README.md 2.63 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Visualization of bike sharing data in London

![](./imgs/architecture-overview.png)

## Project structure:
| path            | explanation |
| --------------- | ----------- |
| `app/backend`   | A node.js server, storing bike trip and bike point documents and providing dynamic statistics about those at several endpoints |
| `app/frontend`  | A React.js Web Frontend, visualizing statistics provided by backend in diagrams and map view |
| `data`          | Information where to download the source data and preprocessing to prepare data for storage in MongoDB |

## Prerequisites
- node and npm must be installed
- docker and docker-compose must be installed

## Run
1. Go into `app/backend/database` and run `docker-compose up -d` to start the database (available on port 27017)
2. Go into `app/backend` and run `npm start` to start the backend (available on port 8081)
3. Go into `app/frontend` and run `npm start` to start the frontend (available on port 3000)

Please note: At first startup, the server will store bike trip documents from a sample json file into the database. This might take a few seconds. 

## More bike trip data
The sample bike trips (`app/backend/src/shared/data/bike-sharing-trip-data-4-january-28-february-reduced.json`) range from 4. January to 28. February, with many trips removed to reduce the file size. If you want to use more bike trips of a larger time range, follow these steps:

1. Download the bike trip CSV-files [for 2015](https://cycling.data.tfl.gov.uk/usage-stats/2015TripDatazip.zip) and [for 2016](https://cycling.data.tfl.gov.uk/usage-stats/2016TripDataZip.zip). More csv files are available [here](https://cycling.data.tfl.gov.uk/), in the folder 'usage-stats'.
2. Go into `data/trips/preprocessing` and follow instructions in README there. It will result in a single json file.
3. Copy the json of step 2 into `app/backend/src/shared/data`
4. Open the file `app/backend/src/Server.ts` and adjust the path in 'createReadStream(...)' to match your newly created json file.
5. If you've used the server in the past, delete the folder `app/backend/database/db`.
6. Start the database and then the server, it will load all the documents from your new json into the database. In subsequent runs it won't do that again, only if you clear your database again.

## Bike point data
We don't use live data of bike points in our visualizations, so we just downloaded all bike point documents once and added them to the repository (`app/backend/src/shared/data/bike-point-data.json`), to be used by the server.
 
If you want, you can download the most up to date bike-point documents [here](https://api.tfl.gov.uk/BikePoint/) and use those instead.