Skip to content

Mist3s/user_restfull_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

User REST API

Test task for the position of Python backend developer, to implement a user API on Django REST Framework. During the test task, the following RESTful API endpoints were developed: user registration, login, getting a user profile, updating a user profile, and deleting an account using Django Rest Framework (DRF). Implemented password storage in encrypted form using the Django Argon encryption algorithm. Authorization was developed on the basis of sending OTP codes with a limited validity period to the user's email using Celery.

Stack:

Django DjangoREST Docker Celery Gunicorn Postgres RabbitMQ Nginx Flower pgAdmin

Installation

To deploy the project, usedocker-compose.yml. Make sure you have Docker installed and Docker Compose.

Clone the project from Github:

git clone git@github.com:Mist3s/user_restfull_api.git

Create a ".env" file in the project root, filling example:

POSTGRES_USER=django_user
POSTGRES_PASSWORD=mysecretpassword
POSTGRES_DB=django
DB_HOST=db_host
DB_PORT=5432
SECRET_KEY='django-insecure-b9)zjp+%-wty5656gfdh5pw4qr(-452xrn_xrlinz^!+@=dk&96'
DEBUG=False
PGADMIN_DEFAULT_EMAIL=admin@email.com
PGADMIN_DEFAULT_PASSWORD=adminpassword
RABBITMQ_DEFAULT_USER=rabbitmq
RABBITMQ_DEFAULT_PASS=rabbitmq

Run Docker Compose with this configuration on your machine

docker compose up -d

Run the migrations, collect the backend static files and copy them to /static/static/:

sudo docker compose exec backend python manage.py makemigrations
sudo docker compose exec backend python manage.py migrate
sudo docker compose exec backend python manage.py collectstatic
sudo docker compose exec backend cp -r /app/static/. /static/static/

API documentation is available at: user-restfull-api.mist3s.site/api/v1/docs/ or locally 127.0.0.1:8000/api/v1/docs/

Installing Docker

Installation on Ubuntu
  1.  sudo apt-get update
  2.  sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common
  3.  curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
  4.  echo "deb [signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  5.  sudo apt-get update
  6.  sudo apt-get install -y docker-ce docker-ce-cli containerd.io
  7.  sudo usermod -aG docker $USER
  8.  sudo reboot
Installation on Windows
  1. Download the Docker Desktop installer from the official Docker website and install it.
  2. Launch Docker Desktop after installation.
Installation on macOS
  1. Download the Docker Desktop installer from the official Docker website and install it.
  2. Launch Docker Desktop after installation.

About the author

Python developer

Andrey Ivanov