REST API JSON Python project which allows users creation of restaurants and visit notes to them.
This is the api part of the Diary of restaurants.
For that project I've used the following technologies:
- Python 3.10
- Poetry modern and powerful package manager
- Django & Django Rest Framework for creation API layer
- Postgres main project database
- Docker & Docker Compose Containerized development tools
- Pytest modern, flexible python framework for testing
- pre-commit additional version control tool
This is the start point of your journey on this project.
For convenience, I tried to use the containerization, which provides by Docker and Docker Compose.
It can significantly isolate and unify process on all machines,
but before using Docker, you have to complete several steps:
Install poetry package manager to your machine
$ pip install poetryActivate poetry
$ poetry shellInstall dependencies to venv
$ poetry installFirstly you need to create a local.env file in root directory. It can be empty, because by default,
Django uses default values for the environment variables. But, if you want to customize them, just add
required environment variables to local.env file.
Next step is build Docker image:
$ docker-compose build
$ docker-compose up --no-start
$ docker-compose run --rm web python restaurant_visits_project/manage.py migrate
$ docker-compose up$ make first-launchFirstly you should register a new user and login, because the application has basic authentication system, which based on JWT:
Registration
http://0.0.0.0:8000/api/auth/registration/
Login
http://0.0.0.0:8000/api/auth/login/
Swagger was used for autogenerated of documentation. You can find everything there:
Autogenerated documentation
http://0.0.0.0:8000/api/schema/swagger/
http://0.0.0.0:8000/api/schema/redoc/
No type of serializer is used for the Crypto endpoint, so the auto-documentation may not be complete.
- for listing all crypto coins
GET method:
http://0.0.0.0:8000/api/v1/crypto/
- for get the required crypto coin
GET method:
http://0.0.0.0:8000/api/v1/crypto/?name=<coin name>
To run the tests I also use the containerization provided by Docker.
$ docker-compose run --rm web pytestafter the tests pass, it is necessary to stop the work of containers.
$ docker-compose stop$ make testpre-commit and other checkers (flake8, mypy, isort, black)
Before starting, you have to install the git hook scripts:
$ pre-commit installNow pre-commit will run automatically on git commit, or you can launch it manually:
$ pre-commit run --all-files