This is a small REST service written with Django REST framework for managing couriers and orders for a candy shop. It is a part of selection process to Yandex Backend School.
The app implements several APIs:
[POST] /couriers
[GET] /couriers/{courier_id}
[PATCH] /couriers/{courier_id}
[POST] /orders
[POST] /orders/assign
[POST] /orders/complete
There are several core files for processing each of them:
- a request is recieved inside views,
- then deserialized and validated inside serializers,
- business logic is applied from services,
- complex queries are moved to models.
To install the app for development
- install python>=3.7
- install dependencies from
requirements.txt
, it is better to do it inside virtual environment
$ python -m venv env
$ . env/bin/activate
$ pip install -r requirements.txt
- after that make sure you have Postgres installed (I used v.11)
- use default config for postgres
- create
candy_shop
db - create
.env
DJANGO_SETTINGS_MODULE=candy_shop.config
DJANGO_CONFIGURATION=Local
- run tests to check your installation
$ pytest
The app was deployed to the corresponding virtual machine, which was given to all entrants. My setup for deployment were taken from this video. The video offers to deploy through gunicorn, nginx and supervisor, which I did.
PyTest was used for testing. So far, only integration tests have been written.