Skip to main content

Rideshare APIs and Schemas

Database Tables

Rideshare Diagram

Users

This table would store information about the users of the app, such as their name, email address, phone number, and login credentials.

Column NameColumn Type
user_idINT
nameVARCHAR(255)
emailVARCHAR(255)
phone_numberVARCHAR(255)
usernameVARCHAR(255)
addressVARCHAR(255)
payment_infoVARCHAR(255)
preferenceVARCHAR(255)

Drivers

This table would store information about the drivers who use the app, such as their name, email address, phone number, and the type of vehicle they drive.

Column NameColumn Type
driver_idINT
nameVARCHAR(255)
emailVARCHAR(255)
phone_numberVARCHAR(255)
vehicle_typeVARCHAR(255)
locationVARCHAR(255)
availabilityBOOLEAN
ratingDECIMAL(2,1)

Vehicles

Vehicles: This table would store information about the vehicles that are used by drivers, such as the make, model, year, and license plate number.

Column NameColumn Type
vehicle_idINT
makeVARCHAR(255)
modelVARCHAR(255)
yearINT
license_plateVARCHAR(255)
driver_idINT
locationVARCHAR(255)
availabilityBOOLEAN

Rides

Rides: This table would store information about each ride that is requested and completed through the app, such as the pickup and drop-off locations, the driver and passenger involved, and the cost of the ride.

Column NameColumn Type
ride_idINT
pickup_locationVARCHAR(255)
dropoff_locationVARCHAR(255)
driver_idINT
passenger_idINT
costDECIMAL(10,2)
statusVARCHAR(255)
start_timeTIMESTAMP
end_timeTIMESTAMP
distanceDECIMAL(10,2)

Payment

Payment: This table would store information about payments made through the app, such as the payment method used, the amount paid, and the transaction ID.

Column NameColumn Type
payment_idINT
payment_methodVARCHAR(255)
amountDECIMAL(10,2)
transaction_idVARCHAR(255)
user_idINT
driver_idINT
ride_idINT
payment_timeTIMESTAMP

APIs/Microservices

  • Authentication and Authorization API

    • User registration, login, and authentication. It would also handle user roles and permissions.
  • User Profile API

    • Management of user profiles, including personal information, payment methods, and ride history.
      • User Management Microservice
        • This service would handle user registration, login, and authentication. It would also handle user roles and permissions.
      • Profile Microservice
        • This service would handle the management of user profiles, including personal information, such as name, address, phone number, etc.
      • Payment Microservice
        • This service would handle the management of payment methods, such as adding, editing and deleting credit card information or other payment options.
      • History Microservice
        • This service would handle the management of ride history, including past rides and their details such as pick-up and drop-off location, fare, driver, etc.
      • Preference Microservice
        • This service would handle the management of user preferences, such as preferred driver, vehicle type, and other settings.
      • Rating Microservice
        • This service would handle the management of user ratings, including ratings given by the user and received by the user.
  • Booking API

    • The Process of booking a ride, including searching for available drivers, estimating fares, and confirming the ride.
  • Location and Map API

    • Management of driver and vehicle locations, as well as providing routing and navigation information to drivers.
  • Payment API

    • Processing of payments, including charging riders and paying drivers.
  • Notification API

    • The sending of push notifications to riders and drivers, including updates on ride status and driver arrival.
  • Data Analysis API

    • The collection and analysis of data from the app to inform business decisions and improve the overall user experience.
  • Rating and Feedback API

    • The collection of rider and driver ratings, as well as handling any feedback provided by users.

API-DB Connection

The sequence of a user connecting to a User Profile API and then to a microservice using Kafka and then to a database would look like this:

  1. A user opens the ridesharing app on their device and logs in.

  2. The app sends an authentication request to the User Profile API, which verifies the user's credentials and generates an access token.

  3. The app uses the access token to make a request to the User Profile API for the user's profile information.

  4. The User Profile API, in turn, sends a message containing the request for user's profile information to the corresponding microservice (e.g. Profile Microservice) using Kafka.

  5. The microservice receives the message, processes it, and retrieves the requested information from the database.

  6. The microservice sends a message containing the user's profile information back to the User Profile API using Kafka.

  7. The User Profile API receives the message, processes it, and sends the user's profile information back to the app.

  8. The app receives the user's profile information and displays it to the user.

  9. Kafka is a distributed messaging system that allows microservices to send and receive messages asynchronously. In this example, Kafka acts as a messaging bus between the User Profile API and the microservices, allowing them to communicate without needing to be directly connected.

  10. The messaging part works by the User Profile API sending a message to Kafka topic, the topic is a log of all the messages sent to it, and the corresponding microservice(s) would be listening to that topic and act upon the messages received.

  11. Each message sent by the User Profile API would have a unique identifier, which the microservice can use to correlate the response back to the User Profile API and the User who sent the initial request.

  12. In this way, the User Profile API can send and receive messages to and from multiple microservices concurrently, improving the overall performance and scalability of the system.

  • User Registration:
    • Method: POST
    • Path: /users/register
    • Parameters: username, email, password, first_name, last_name, phone_number
    • Response: HTTP status code (e.g. 200, 400, 500)
  • User Login:
    • Method: POST
    • Path: /users/login
    • Parameters: email, password
    • Response: Authentication token or HTTP status code (e.g. 200, 400, 401)
  • View User Profile:
    • Method: GET
    • Path: /users/{user_id}
    • Parameters: user_id
    • Response: User profile information or HTTP status code (e.g. 200, 404)
  • Update User Profile:
    • Method: PUT
    • Path: /users/{user_id}
    • Parameters: user_id, (any fields to be updated)
    • Response: HTTP status code (e.g. 200, 400, 404)
  • Create Ride Request:
    • Method: POST
    • Path: /rides
    • Parameters: user_id, start_location, end_location, ride_type, payment_method, (optional: start_time, estimated_cost, notes)
    • Response: HTTP status code (e.g. 200, 400, 500)
  • View Ride Requests:
    • Method: GET
    • Path: /rides
    • Parameters: (optional: user_id, status, ride_type)
    • Response: List of ride requests or HTTP status code (e.g. 200, 400, 500)
  • Update Ride Request:
    • Method: PUT
    • Path: /rides/{ride_id}
    • Parameters: ride_id, (any fields to be updated)
    • Response: HTTP status code (e.g. 200, 400, 404)
  • Cancel Ride Request:
    • Method: DELETE
    • Path: /rides/{ride_id}
    • Parameters: ride_id
    • Response: HTTP status code (e.g. 200, 404)
  • View Ride History:
    • Method: GET
    • Path: /rides/history
    • Parameters: user_id
    • Response: List of completed rides or HTTP status code (e.g. 200, 400, 500)
  • View Available Drivers:
    • Method: GET
    • Path: /drivers
    • Parameters: start_location, ride_type
    • Response: List of available drivers or HTTP status code (e.g. 200, 400, 500)
  • Accept Ride Request:
    • Method: POST
    • Path: /rides/{ride_id}/accept
    • Parameters: driver_id, ride_id
    • Response: HTTP status code (e.g. 200, 400, 404)
  • Start Ride:
    • Method: PUT
    • Path: /rides/{ride_id}/start
    • Parameters: ride_id
    • Response: HTTP status code (e.g. 200, 400, 404)
  • Complete Ride:
    • Method: PUT
    • Path: /rides/{ride_id}/complete
    • Parameters: ride_id
    • Response: HTTP status code (e.g. 200, 400, 404)

Terraform:

provider "aws" {
region = "us-east-1"
}

resource "aws_api_gateway_rest_api" "rideshare_api" {
name = "RideshareAPI"
}

resource "aws_api_gateway_resource" "rideshare_resource" {
rest_api_id = aws_api_gateway_rest_api.rideshare_api.id
parent_id = aws_api_gateway_rest_api.rideshare_api.root_resource_id
path_part = "rideshare"
}

resource "aws_api_gateway_method" "get_rides" {
rest_api_id = aws_api_gateway_rest_api.rideshare_api.id
resource_id = aws_api_gateway_resource.rideshare_resource.id
http_method = "GET"
authorization = "NONE"
}

resource "aws_api_gateway_integration" "get_rides_integration" {
rest_api_id = aws_api_gateway_rest_api.rideshare_api.id
resource_id = aws_api_gateway_resource.rideshare_resource.id
http_method = aws_api_gateway_method.get_rides.http_method
integration_http_method = "POST"
type = "MOCK"
}

resource "aws_api_gateway_method_response" "get_rides_response" {
rest_api_id = aws_api_gateway_rest_api.rideshare_api.id
resource_id = aws_api_gateway_resource.rideshare_resource.id
http_method = aws_api_gateway_method.get_rides.http_method
status_code = "200"
}

resource "aws_api_gateway_integration_response" "get_rides_integration_response" {
rest_api_id = aws_api_gateway_rest_api.rideshare_api.id
resource_id = aws_api_gateway_resource.rideshare_resource.id
http_method = aws_api_gateway_method.get_rides.http_method
status_code = aws_api_gateway_method_response.get_rides_response.status_code
}

resource "aws_api_gateway_deployment" "rideshare_deployment" {
rest_api_id = aws_api_gateway_rest_api.rideshare_api.id
stage_name = "prod"
}