Skip to content

evgrmn/FastAPI_example

Repository files navigation

FastAPI_example

Restaurant menu

Description:

  • Five tables: menu, submenu, dish, user, order
  • The menu has a submenu, the submenu has dishes
  • Each dish can only have one submenu, each submenu can only have one menu
  • The menu is deleted along with all submenus and dishes
  • The submenu is deleted along with all dishes
  • In the "menu" table, the number of submenus and dishes is counted
  • In the "submenu" table, the number of dishes is counted

Features:

  • Docker containerization
  • Redis caching
  • ORM SQLAlchemy
  • Pydantic data validation
  • Pytest testing
  • Celery background tasks:
    • Getting menu as excel file
    • Sending emails using gmail.com
    • Periodic database dump
  • User authorization JSON Web Tokens (JWT)
  • Websocket chat

Creating containers and running the application:

  • docker-compose up --build

Once launched, the API is available at http://localhost:8000/docs

RabbitMQ is available at http://localhost:15672 Username: guest, Password: guest

PostgreSQL can be conncted:

  • Host: localhost
  • Port: 5433
  • Username: postgres
  • Password: password
  • Database: fastapi_database

Run Pytest

Creating containers for testing and running Pytest:

  • docker-compose -f docker-compose.tests.yml up --build

Restarting the test script while test_redis and test_postgr containers are running:

  • docker start -ai test_ylab