This project is made using java Spring boot and postgres database.
Following APIs are implemented:
- To create a new ride.
- To allow driver to rate a passenger after ride completion.
- To allow passenger to rate a driver after ride completion.
- A driver or passenger can get his aggregate ride ratings.
Given google doc contains all the APIs: https://docs.google.com/document/d/1z5hjIyoM1AxqzFe1egGshU_wcWUj7mR0-t7su6_iSv8/edit
- First we create a ride using driverId and passengerId with status ON_GOING.
- If driver or passenger is in another ride i.e if there is any ride exist in which status is ON_GOING for the given driver or passenger then a new ride cannot be created.
- After ride is completed , passenger can rate a ride given passenger id, driver id, and rating in range of 1-5 stars if any ride exists between them.
- We update the aggregate rating by fetching driver entity/passenger entity for that driver Id/passenger Id and incrementing the rating count by dividing aggregateRating with new increment count.
- So after every rating we have aggregate rating stored in our Driver and Passenger tables of our database.
- To fetch rating of driver or passenger we use params driverId or passengerId and get the aggregate ratings info for the driver or passenger.
This project contains three relations(tables) i.e Driver, Passenger, Ride.
-
Install java 8 and postgres on your system.
-
Run following commands on terminal to setup postgres databaes:
sudo -u postgres psql postgres=# create database mydb;
postgres=# create user myuser with encrypted password 'mypass';
postgres=# grant all privileges on database mydb to myuser; -
Update application.properties file with your database credentials.
-
Execute following commands project directory on terminal to run the application:
first build : mvn -T 1C clean install -f pom.xml -DskipTests
then run : mvn spring-boot:run -Dspring.profiles.active=dev -T 1C