Simple Taxi Booking System

Running via Python3

Make sure you have these requirements - Python 3.8 - pip3

It's also good to have separate python environments. You can read about that here

At this point, you must have activated your environment as well if you have chosen to have one.

To Install requirements run pip install -r requirements.txt

To Run the Service run python3

The service will run on port 8080

Terminate by Ctrl+C

Running via Docker

Building and Running

Make sure docker is installed and run these commands

  1. docker image build -t simple-taxi-booking .
  2. docker run --name=simple-taxi-booking-docker -p 8080:8080 -d simple-taxi-booking

This will run the service on port 8080

Stopping the Service

docker stop simple-taxi-booking-docker

Restarting the Service

docker start simple-taxi-booking-docker

Removing the container (when you want to start anew)

  1. docker stop simple-taxi-booking-docker if it is running, else go to step 2
  2. docker rm simple-taxi-booking-docker

Scenario Player

I had some time so I made a quick and dirty scenario player at endpoint /player.

You can view an online version of this scenario player at

The player uses all the APIs below but with a UI (ugly interface haha)

This is a fun tool to view how the scenarios play out.

Be kind with it though, it's very rough

Static file is at project/templates/player.html if you need to see the code

Available APIs

reset: Resets the taxis and states to initial position

This will also create the initial tables if it's blank. You can specify the number of taxis you want to spawn on reset. If no taxi_count param, default is 3 taxis

ENDPOINT: /api/reset
PARAMS: taxi_count {optional integer} -- number of taxis to spawn

    json -- {"message":f"State Reset", "taxi_count":<taxi_count>}

book: Make a car booking

ENDPOINT: /api/book
Parameters: JSON
{"source": {"x": x,"y": y},"destination": {"x": x,"y": -y}}

    json --  { "car_id": id, "total_time":time_unit_to_finish}

tick: Moves the time unit one step

METHOD: post
ENDPOINT: /api/tick

    json -- {"message":"Time Has Moved", "tick_count":<tick_count>})

get_all_data: Gets all the data for the taxis and the tick time

ENDPOINT: /api/get_all_data

    json --  {"taxis":{1:<taxi_data>, 2:<taxi_data>, 3:<taxi_data>}, "tick":7}

add_taxi: API call to increase number of available taxis

ENDPOINT: /api/add_taxi

    json -- {"message":"Added a new Taxi", "taxi_count":<taxi_count>}


The unit tests are in project/test.

You can run the unit tests by: python3 -m unittest project/test/ from the root simple-taxi-booking directory