CalorieManagement is an API for counting calories. It implements site parsing (https://supercalorizator.ru/). Categories, products and their calories, proteins, fats and carbohydrates, as well as pictures of categories and products are parsed from this site. Implemented the ability to register a user, create a cart for the user (in which products are added to count calories), as well as receive products and categories.
- Python (version 3.11)
- Django
- DRF
- PostgreSQL
- Docker Compose
First, clone project
git clone https://github.com/Niolum/CalorieManagement.git
Further, set up the virtual environment and the main dependencies from the requirements.txt
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
Then, create .env file. set environment variables and create database.
Example .env
:
DBUSER=username
DBPASS=password
DBNAME=db_name
DBHOST=localhost
DBPORT=5432
DEBUG=0
SECRET_KEY='some_secret_key'
DJANGO_ALLOWED_HOSTS="*"
URL='https://supercalorizator.ru/'
Before starting, you need to execute several commands:
python manage.py migrate
python manage.py scrapy
Run application:
python manage.py runserver
For start in docker-compose change .env:
POSTGRES_USER=username
POSTGRES_PASSWORD=password
POSTGRES_DB=db_name
DBUSER=username
DBPASS=password
DBNAME=db_name
DBHOST=postgres
DBPORT=5432
DEBUG=0
SECRET_KEY='some_secret_key'
DJANGO_ALLOWED_HOSTS="*"
URL='https://supercalorizator.ru/'
Before running docker-compose:
docker volume create caloriedb
docker volume create calorie_media
To start the project, use the following command:
docker-compose up -d
To run all the tests of a project, simply run the pytest command:
pytest