ShreehariVaasishta / order_delivery

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Order_delivery

A simple order delivery API app using Python, Django, Django Rest Framework

Features

  • Order Calculator
  • List items
  • Add to cart feature
  • Save orders to database
  • Order Tracking

Demo

This Django application is hosted on aws ec2 instance in DEBUG mode and it can be accessed here. It is hosted using Nginx, Supervisor, Gunicorn.

Usage

  1. Clone this repository
git clone https://github.com/ShreehariVaasishta/order_delivery
  1. Go to the root directory of this project
cd order_delivery
  1. Install the dependencies using pip. Activate virtual environment if you use one.
pip3 install -r requirements.txt
  1. Create a .env file and make sure the following variables are set
DJANGO_SECRET_KEY=
DEBUG=
  1. Start the django server
./manage.py runserver

OR

python3 manage.py runserver

Now you should be able to access the Django app running locally at port 8000. Additionally you can specifiy the port for the django app to run in local

./manage.py runserver 0.0.0.0:8080

Now the Django app will be accessible at port 8080

Testing

Few basic test cases are already included for the existing order calculation API which inherits Django's TestCase class.
To run those test cases, run the following command

./manage.py test 

OR

python3 manage.py test

Test case results will be displayed in the terminal.

Tech Stack (Programming Language, Framework(s))

  • Python
  • Django
  • Django Rest Framework

Technical Decisions

  1. Added type annotations and comments everywhere which improves code readability
  2. Used DjangoRestFramework's serializers to validate the request body. Which keeps code readable, modularised and also maintainable.
  3. Used python dictionaries to store distance range and price allotted to the respective distance.
  4. Moved utility functions to utility folder. This should keep them easily accessible instead of searching the whole file.
  5. Constants have a dedicated file in the app which might not change frequently.

Screenshots

  1. With FLAT offer Flat
  2. With DELIVERY offer Delivery
  3. Without OFFER No offer
  4. Order 4 Order 4
  5. Order 5 Order 5
  6. Order 6 Order 6

About


Languages

Language:Python 100.0%