A Python library and server application that figures out the best routes for riders in a last mile delivery warehouse setup. Optimised in accordance to Inter IIT 2023, Problem Statement 3.
To install the required dependencies, follow the steps below:
- Clone this repository, and
cd
into it
git clone https://github.com/rishvic/optirider.git
cd optirider
- Set up a virtual environment, and activate it
python -m venv .venv
# 2.1. For *nix (bash/zsh)
source .venv/bin/activate
# 1.2. For Windows (Powershell)
.\.venv\Scripts\activate
- Install all the dependencies
pip install -r ./requirements.txt
- (For development) Install dev dependencies, and set up pre-commit hooks.
Note: Installing the development dependencies will setup
pre-commit
with the formatter Black. What it does is check all files for proper formatting before a commit is performed. If it finds that any file is improperly formatted, it aborts the commit, and formats all improperly formatted files. The changes done by the formatter will show up as unstaged changes on top of the staged changes, for the developer to add & commit after review. For more information, read thepre-commit
docs and Black docs.
pip install -r ./requirements-dev.txt
pre-commit install
To run the Django HTTP server, run the following commands:
# ... assuming that requirements.txt has been installed
# Development server
python manage.py runserver
# Production server, more details on how to deploy linked below:
# https://docs.djangoproject.com/en/4.1/howto/deployment/#how-to-deploy-django
# Eg: Deploying on ASGI using Uvicorn
pip install uvicorn
python -m uvicorn optiserver.asgi:application
Note: Before running in a production environment, certain settings need to be
set properly (eg. setting DEBUG = False
, configuring ALLOWED_HOSTS
etc.).
For all required production configuration, see the Deployment Checklist.
On top of all the Django server settings, the OptiRider parameters have been set
in the settings.py
, under the dictionary
OPTIRIDER_SETTINGS
and OSRM_SETTINGS
, accordingly.
The server exposes a REST API interface, through which communication is
performed. The server schema should be available on the endpoint
api/schema/swagger-ui/
or api/schema/redoc/
. The OpenAPI schema YAML file is
available on api/schema/
. The YAML schema file can be uploaded & checked
in Swagger Editor or ReDoc Interactive Demo.
Docker configurations have been uploaded, for development and production environment. The API will be exposed on port 8010 of the host. The details for the profiles are as follows:
-
In the development profile, the source code is live mounted into the image, thus making changes to the code will automatically restart the server. To run the development container,
cd
to docker/development and rundocker compose up -d
. -
In the production profile, production settings are configured thru environment variables. read the docker/production/docker-compose.yml for options. To run the production container,
cd
to docker/production and rundocker compose up -d
.
- Add a test module, which will verify that the path given by solver module is feasible.