This repository contains pre-assignment for Solita Dev Academy Finland 2023.
Live demo of app is available at http://citybike.henkka.one/
API documentation is available at https://hvikman.github.io/helsinki-city-bike-app
Used technologies:
- React 18.2.0 for frontend
- Node.js 18.12.1, express 4.16.1 and MySQL 8 for backend
- Python 3 for data validation
Backend is running in free version of Azure App Service at : https://henkkacitybike.azurewebsites.net/
Database is Azure Database for MySQL.
- Import data from the CSV files to a database or in-memory storage
- Validate data before importing
- Don't import journeys that lasted for less than ten seconds
- Don't import journeys that covered distances shorter than 10 meters
- List journeys
- For each journey show departure and return stations, covered distance in kilometers and duration in minutes
- Pagination
- Ordering per column
- Searching
- Filtering
- List all the stations
- Pagination
- Ordering per column
- Searching
- Station name
- Station address
- Total number of journeys starting from the station
- Total number of journeys ending at the station
- Station location on the map
- The average distance of a journey starting from the station
- The average distance of a journey ending at the station
- Top 5 most popular return stations for journeys starting from the station
- Top 5 most popular departure stations for journeys ending at the station
- Ability to filter all the calculations per month
-
Clone the repository:
git clone https://github.com/HVikman/helsinki-city-bike-app.git
-
Navigate to the backend directory:
cd helsinki-city-bike-app/backend
-
Install the required dependencies using npm:
npm install
-
Set up environment variables:
- Create a .env file in the root of the backend directory.
- Specify the required environment variables in the .env file. Refer to .env.example for the list of variables.
-
Create a MySQL database for the backend:
-
Make sure you have a MySQL database server installed and running.
-
Open a terminal or command prompt.
-
- Log in to the MySQL server using the command:
mysql -u your_username -p
- Create a new database
CREATE DATABASE your_database_name;
- Exit mysql
EXIT;
-
Import database
mysql -u your_username -p your_database_name < create_db.sql
-
Start backend
npm start
Backend will be running at http://localhost:4000 unless different port is specified in .env file.
-
Navigate to the frontend directory:
cd helsinki-city-bike-app/frontend
-
Install the required dependencies using npm:
npm install
-
Edit apiurl constant in /pages/JourneyList.js and /pages/StationList.js to your backend url.
-
Build the frontend:
npm run build
Bundled files will be in build directory
- Download three datasets of journey data. The data is owned by City Bike Finland.
- https://dev.hsl.fi/citybikes/od-trips-2021/2021-05.csv
- https://dev.hsl.fi/citybikes/od-trips-2021/2021-06.csv
- https://dev.hsl.fi/citybikes/od-trips-2021/2021-07.csv
- Download dataset that has information about Helsinki Region Transport’s (HSL) city bicycle stations.
- Dataset: https://opendata.arcgis.com/datasets/726277c507ef4914b0aec3cbcfcbfafc_0.csv
- License and information: https://www.avoindata.fi/data/en/dataset/hsl-n-kaupunkipyoraasemat/resource/a23eef3a-cc40-4608-8aa2-c730d17e8902
-
Ensure you have Python 3 installed on your system.
-
Install the required Python dependencies:
pip install -r requirements.txt
-
Modify the script to have your database information and uncomment lines containing database insertion.
-
Run the script:
python data_importer.py
The script will import the data into the Helsinki City Bike App's database.
I have created quite a lot of tests for the frontend. You can run tests by:
-
cd frontend
-
npm test
-
All tests should pass
There is only few backend tests, but you can run them:
-
cd backend
-
npx jest
-
All tests should pass