πŸš– Uber - Driver Management Service

Efficient Driver Assignment & Tracking

3 hours
medium
1 submissions

Project Overview

Efficient Driver Assignment & Tracking

Uber requires a Driver Management Service to handle driver registration, real-time location updates, and availability tracking. This microservice is responsible for maintaining an up-to-date list of available drivers, ensuring they can be efficiently assigned to ride requests. Your task is to develop an API that allows drivers to register, update their location, toggle availability, and be retrieved by the system for ride-matching.

This service will integrate with other microservices, including the Ride Request Service (to assign drivers) and the Surge Pricing Service (to dynamically adjust fares based on driver availability).

Read the uber project microservices overview beforehand to understand how this fits in the architecture of the entire microservice.

Your submissions

No submissions yet, start by making your first submission

Detailed Project Description

Read the uber project microservices overview beforehand to understand how this fits in the architecture of the entire microservice.

The Uber Driver Management Service is a core component of the Uber Microservices Project, responsible for managing driver registration, real-time location tracking, and availability status. This service ensures efficient driver assignment and ride operations.

πŸ”Ή Key Features

  • Your API should run on the port 5003.
  • Driver Registration: Adds new drivers to the system.
  • Location Tracking: Updates driver locations in real-time.
  • Availability Management: Toggles driver availability for ride requests.
  • Nearby Driver Search: Fetches available drivers near a given location.

πŸ“ Required API Endpoints

Your Driver Management Service API should expose the following endpoints:

1️⃣ Register a New Driver

  • Endpoint: POST /drivers/register
  • Description: Adds a new driver to the system.
  • Request Body:
    { "name": "John Doe", "lat": 40.7128, "lng": -74.006 }
  • Expected Response:
{ "message": "Driver registered successfully", "driver": { "driver_id": "a1b2c3d4-e5f6-7890", "name": "John Doe", "location": { "lat": 40.7128, "lng": -74.006 }, "available": true } }
  • Logic:
    • A new driver_id should be generated.
    • The driver is marked as available by default.
    • The system should store the driver's location.

2️⃣ Update Driver Location

  • Endpoint: POST /drivers/update
  • Description: Updates a driver's location in real time.
  • Request Body:
    { "driver_id": "a1b2c3d4-e5f6-7890", "lat": 40.7306, "lng": -73.9352 }
  • Expected Response:
    { "message": "Driver location updated" }
  • Logic:
    • The driver must exist in the system.
    • If the driver is not found, return a 404 error.

3️⃣ Get Available Drivers

  • Endpoint: GET /drivers/available?lat={lat}&lng={lng}
  • Description: Retrieves a list of nearby available drivers.
  • Expected Response:
    { "available_drivers": [ { "driver_id": "a1b2c3d4-e5f6-7890", "name": "John Doe", "location": { "lat": 40.7306, "lng": -73.9352 } } ] }
  • Logic:
    • The API should return a list of available drivers near the given location.
    • If no drivers are available, return an empty list.

4️⃣ Set Driver Availability

  • Endpoint: PATCH /drivers/{driver_id}/availability
  • Description: Updates a driver's availability status.
  • Request Body:
    { "available": false }
  • Expected Response:
    { "message": "Driver set to unavailable" }

or

{ "message": "Driver set to available" }
  • Logic:
    • Drivers can toggle their availability on or off.
    • If the driver does not exist, return a 404 error.

βš™οΈ How It Works

  1. Driver Registration: When a driver registers, the system stores their information and marks them as available.
  2. Location Updates: The service keeps track of driver locations in real time.
  3. Driver Availability: The system tracks which drivers are active and available for ride assignments.
  4. Finding Nearby Drivers: The Ride Request Service queries this service to match passengers with the nearest available drivers.

πŸš€ Expected Behavior

ScenarioExpected Outcome
Register a new driverβœ… Driver is added and marked as available.
Update a registered driver's locationβœ… Location is updated successfully.
Update location for a non-existent driver❌ 404 Driver Not Found
Retrieve available drivers when none existβœ… 200 OK with an empty list.
Update availability for a non-existent driver❌ 404 Driver Not Found
  • Your API should run on the port 5003.

By completing this project, you will create a fully functional, real-time driver management system that can be used in a scalable ride-sharing platform like Uber! πŸš–πŸ”₯

Project Completion Criteria

  • The system should allow users to register a new driver with a unique driver_id, name, and initial location.
  • The system should allow users to update a driver's real-time location via the POST /drivers/update endpoint.
  • The system should allow users to fetch available drivers near a given location via the GET /drivers/available endpoint.
  • The system should allow users to update a driver's availability status (available: true/false).
  • The system should return an empty list if no drivers are available in a location.
  • The system should conform to the specified request and response structures for all API endpoints.
  • The system should return a 404 error if a non-existent driver tries to update their location or availability.