This repository contains the case study analysis report, the demo video as well as the code implementation for the MoveInSync case study titled "Smart Cab Allocation System".
Click here for the case study analysis report.
Click here for the demonstration video of the implementation.
Click here for the code repository of the implementation.
- Languages: Go; for backend development & YAML; for writing config files.
- Databases: MongoDB: used MongoDB Atlas to manage cloud instances.
- Deployment Tools: Docker; used Docker-Compose to manage & deploy multi-container applications. Postman; for API-testing. Prometheus & Grafana; as the monitoring stack.
admin-service: Service responsible for all admin actions; namely: admin creation, admin login, adding cabs & suggesting/allocating cabs.cab-data-service: Service responsible for real-time cab location data integration. It is a web-socket server that listens for cab devices reporting location data and writes it back to the database.user-service: Service responsible for all user actions; namely: user creation, user login, booking trips & requesting to display engaged cabs.prometheus: Responsible for metrics collection from the necessary services.grafana: Responsible for metrics visualizations as well as alerting for the necessary services.
-
Clone the GitHub repository using the following command to your local machine.
git clone https://github.com/sankalp-12/moveinsync -
Make sure you have installed Docker and Docker-Compose on your machine. Now, change the working directory to the newly cloned repository.
cd moveinsync -
Now, to start all the containers, run the docker-compose.yml file.
sudo docker-compose build && sudo docker-compose upIf you face any errors during the executions of the above command, ensure that all the ports required are free on your machine. You can check for the required ports in the
docker-compose.ymlfile. -
After execution, run the command:
docker psto ensure that all the containers are up and running. -
Once verified, access the port: 3001 by default assigned to the Grafana instance. The credentials by default are:
Username: admin
Password: admin
-
Once logged in, you can start making dashboards to monitor the application metrics and send alerts. A template dashboard has been provided in
grafana/dashboards/moveinsync.jsonwith a limited number of visualizations, which you can upload to Grafana through the import option while creating a new dashboard. -
The setup is now complete! You can now start sending HTTP requests to the services (using curl or Postman). The different endpoints and their respective request body structures are provided below.
-
Create Admin
- Endpoint: `http://localhost:8081/api/v1/admin/create` - Method: POST - Request Body: { "username": "demo", "password": "moveinsync" } - Expected Response: { "status": "success" }
-
Admin Login
- Endpoint: `http://localhost:8081/api/v1/admin/login` - Method: POST - Request Body: { "username": "demo", "password": "moveinsync" } - Expected Response: { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTM1NzUxMzcsInVzZXJuYW1lIjoic2Fua2FscCJ9.0ySKDMXCGP7mFytkrAFFQo2JonX955OlKlWClwbTHLw" }
-
Add Cabs
- Endpoint: `http://localhost:8081/api/v1/admin/addcabs` - Method: POST - Authorisation Header: Bearer [token] - Request Body: { "location": { "type": "Point", "coordiantes": ["[longitude]", "[latitude]"] } "status": "Available"/"Busy" } - Expected Response: { "status": "success" }
-
Create User
- Endpoint: `http://localhost:8080/api/v1/user/create` - Method: POST - Request Body: { "username": "demo", "password": "moveinsync" } - Expected Response: { "status": "success" }
-
User Login
- Endpoint: `http://localhost:8080/api/v1/user/login` - Method: POST - Request Body: { "username": "demo", "password": "moveinsync" } - Expected Response: { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MTM1NzUxMzcsInVzZXJuYW1lIjoic2Fua2FscCJ9.0ySKDMXCGP7mFytkrAFFQo2JonX955OlKlWClwbTHLw" }
-
Book Trip (Available Cabs)
- Endpoint: `http://localhost:8080/api/v1/user/booktrip` - Method: POST - Authorisation Header: Bearer [token] - Request Body: { { "longitude": "81.60", "latitude": "21.24" } } - Expected Response: { { "_id":"661f75e1b80a04c2f7adc774", "distance":29187.820383017817, "last_updated":"2024-04-17T07:10:25.83Z", "location": { "coordinates": [81.31886422688906,21.249442177652497], "type":"Point" }, "status":"Available" } }
-
Display Nearby Cabs (Busy Cabs)
- Endpoint: `http://localhost:8080/api/v1/user/displaynearbycabs` - Method: POST - Authorisation Header: Bearer [token] - Request Body: { { "longitude": "81.60", "latitude": "21.24" } } - Expected Response: { { "_id":"661f75e1b80a04c2f7adc774", "distance":29187.820383017817, "last_updated":"2024-04-17T07:10:25.83Z", "location": { "coordinates": [81.31886422688906,21.249442177652497], "type":"Point" }, "status":"Busy" }, ... (upto 5 cabs) }
- Real-Time Cab-Location Data Integration
- Endpoint: `http://localhost:8082/cab/ws` - Method: POST - Request Body: { "ID": "cab_id", "location": { "type": "Point", "coordiantes": ["[longitude]", "[latitude]"] } "status": "Available"/"Busy" }