Skip to content

A library that allocates orders and routes for riders in a last mile delivery warehouse setup, exposed via a Django server

Notifications You must be signed in to change notification settings

Inter-iit-tech/order-allocation-microservice

Repository files navigation

OptiServer 🚴🖥️

pre-commit Code style: black

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.

Setting up 🧑‍💻

To install the required dependencies, follow the steps below:

  1. Clone this repository, and cd into it
git clone https://github.com/rishvic/optirider.git
cd optirider
  1. 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
  1. Install all the dependencies
pip install -r ./requirements.txt
  1. (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 the pre-commit docs and Black docs.
pip install -r ./requirements-dev.txt
pre-commit install

Running 🏃

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.

Configuration Options ⚙️

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.

API 🖧

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 🐳

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 run docker 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 run docker compose up -d.

TODO 📝

  • Add a test module, which will verify that the path given by solver module is feasible.

About

A library that allocates orders and routes for riders in a last mile delivery warehouse setup, exposed via a Django server

Resources

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •