osmium8 / fresh-pizza-store

Backend service of a pizza store.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hot Fresh Pizza🍕

Notes:

  • All endpoints can be explored and tried at Swagger UI -> http://127.0.0.1/api/schema/docs/
  • pizzeria/management/commands/setup_test_data.py creates test data, can be used as a management command
  • category.required_amount field + serializer validation is used to impose business restriction of 1 Base, 1 Cheese, 5 Toppings
  • A celery tasks at audit/tasks.py recursively updates the order status
  • db_design.png shows all tables and relations, source DBML at dbdiagram/pizza.

Here's how frontend gonna use few of the APIs:

  1. add/modify pizzas to his/her order -> [POST,PATCH] /api/pizzeria/orderitem/
  2. review order -> [GET] /api/pizzeria/order
  3. place order -> [POST] /api/pizzeria/order/place-order
  4. track order -> [GET] /api/audit/track/{id}/

Docker:

  • system prerequisites: Docker and Docker Compose
  • if you tried local setup before, paste content from settings_docker.py to settings.py
  • http://127.0.0.1/api/schema/docs/
sudo docker-compose build
sudo docker-compose up

Local Setup:

  1. replace the content of settings.py file with settings_local.py file

  2. create venv, using python -m venv venv

  3. activate the environment

    Ubuntu `source venv/bin/activate`
    Windows Powershell `venv\Scripts\Activate.ps1`
    Windows CMD `venv\Scripts\activate.bat`
  4. install dependencies pip install -r requirements.txt

  5. connect with local DB instance at project/settings.py

    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.<db_name>',
            'NAME': '<schema_name>',
            'USER': '<user_name>',
            'PASSWORD': '<password>',
            'HOST':'localhost',
            'PORT':'3306',
        }
    }
    
    # change redis server's port, default is 6379
    CELERY_BROKER_URL = "redis://localhost:6379"
    CELERY_RESULT_BACKEND = "redis://localhost:6379"
    
  6. make migrations, migrate, generate test pizzas and runserver

    python manage.py makemigrations
    python manage.py migrate
    
    python manage.py setup_test_data
    
    python manage.py runserver 8000
  7. start redis server

    > redis-server
    
  8. start celery worker

    > celery --app=project  worker -l INFO --pool=solo
    

About

Backend service of a pizza store.


Languages

Language:Python 99.0%Language:Shell 0.7%Language:Dockerfile 0.3%