README ¶
Table of Contents
About The Project
Passenger page for getting current status, viewing trips and requesting for trips. []
Driver page for getting current status, starting and ending ride. []
The Ride Share Assignment requires at least 2 microservices that is derived from applying the techniques of Decomposition using Strategic DDD and Tactical DDD. It also has an optional requirement for a frontend to be implemented. The following will explain what each of the microservices currently do, how is the services derieved and what frontend is being used together with a visual representation of the Microservices diagram.
There are a total of 3 microservices: (the functions and http method will be shown in each microservice.)
- Passenger
- GET - Log in, Get Passenger Details
- Example: "http://localhost:5000/Passengers/1"
- PUT - Update Passenger Details
- Example: Update Passenger Act: curl -H "Content-Type: application/json" -X PUT http://localhost:5000/Passengers/{passengerid} -d "{"fn":"jacob","ln":"lim","mn":"92323812","ea":"[email protected]"}"
- POST - Create Passenger
- Example: Create Passenger Acct: curl -H "Content-Type: application/json" -X POST http://localhost:5000/Passengers/{passengerid} -d "{"fn":"jacob","ln":"lim","mn":"92323812","ea":"[email protected]"}"
- DELETE - Delete will not be allowed (Error message will occur)
- Example: curl -X DELETE http://localhost:5000/Passengers/1
- GET - View all trips (in reverse chronological order)
- Trip
- PUT (But Post was used to accomodate to golang) - Updates OnRide status (Driver & Passenger)
- POST - Request trip (Passenger)
- Example: curl -H "Content-Type: application/json" -X POST http://localhost:5080/Passengers/1/Trip -d "{"startpc":"670210","endpc":"210999","timestamp":"2021-11-23 17:59:59","dID":"","pID":"","tripStatus":""}"
- GET - Retrieve Available driver
- PUT - Start ride (Driver)
- curl -H "Content-Type: application/json" -X PUT http://localhost:5080/Drivers/1/Trip?action=startTrip
- PUT - End ride (Driver)
- curl -H "Content-Type: application/json" -X PUT http://localhost:5080/Drivers/1/Trip?action=endTrip
- Driver
- GET - Log in, Get Driver Details
- Example: curl http://localhost:5050/Drivers/1
- PUT - Update Driver Details ('identificationNo' will not be allowed)
- Example: curl -H "Content-Type: application/json" -X PUT http://localhost:5050/Drivers/{driverid} -d "{"fn":"jacob","ln":"lim","mn":"92323812","ea":"[email protected]","cln":"s111fx","idno":"s1010201F"}"
- POST - Create Driver
- Example: curl -H "Content-Type: application/json" -X POST http://localhost:5050/Drivers/{driverid} -d "{"fn":"jacob","ln":"lim","mn":"92323812","ea":"[email protected]","cln":"sx234f",\”idno\”:\”t0029201F\”}"
- DELETE - Delete will not be allowed (Error message will occur)
- Example: curl -X DELETE http://localhost:5050/Drivers/1
- GET - View Current Trip
- Example: curl http://localhost:5050/Drivers/1
Design Consideration of Microservices
Why 3 Microservice:
- With Driver, Passenger and Trips seperated it allows lesser dependencies between how they will communicate.
- Driver and Passenger will focus on functions like Creating, Updating and Getting their personnal details.
- Trips will focus on Requesting of trip, Assigning trip and both start and end trips.
- This allows each area of focus to be seperated in case if one microservice is required to be shut down for enhancement or errors the other microservices can still operate thus ensuring user experience from the running microservices.
- Example: If Trips microservice is shutdown, Driver and Passenger microservice will still allow the users to create profiles, update and get personnal details.
Frontend:
- Monolith Frontend:
- Above is chosen because this assignment's implementations will not be growing and it also shows how technologically agnostic the frontend, microservice and backend can be.
Design Pattern used:
- Decomposition:
- Strategic Domain-Driven Design Result:
- Accounts
- Trips Management
- Tactical Domain-Driven Design Identified Microservice:
- Driver Microservice (Handle Functions: Create, Retrieve, Update Driver Account, Retrieve Current Trip)
- Passenger Microservice (Handle Functions: Create, Retrieve, Update Passenger Account, Retrieve List of Trips Taken)
- Trip Microservice (Handle Functions: Request Trip, Start Trip, End Trip, Update Account On Ride Status)
- Strategic Domain-Driven Design Result:
To better understand, below is a diagram of the assignment's structure and how communications are made. [] []
Built With
The main objective of this assignment is to put the knowledge and skills learnt about Golang to use. Vanilla Javascript and HTML CSS is used for the frontend.
Getting Started
Prerequisites
Make sure that MySQL and Golang is downloaded on your device.
Installation
- Clone the repo
git clone https://github.com/gabgohkb/ETI_Assignment1.git
- Install necessary libraries
go get -u github.com/go-sql-driver/mysql go get -u github.com/gorilla/mux go get -u github.com/gorilla/handlers
- Execute database start script in
/DB/ExecuteDBSQL.sql
Usage
To start using the ride-hailing platform, follow the below steps:
- Run all microservices in each directory
cd Assignment1\DB_Passenger
go run main.go P_Database_Func.go
cd Assignment1\DB_Driver
go run main.go D_Database_Func.go
cd Assignment1\DB_Trip
go run main.go T_Database_Func.go
- Open frontend by opening
Home.html
inAssignment1\Templates
Roadmap
- Backend using Golang
- Frontend using HTML JavaScript
- Tidy up both backend and frontend
License
Distributed under the MIT License. See LICENSE.txt
for more information.
Contact
Gabriel Goh - School Email
Project Link: https://github.com/gabgohkb/ETI_Assignment1.git