Skip to content

FastAPI backend for Yes Chef application that manages user ingredient inventories and shopping lists

Notifications You must be signed in to change notification settings

bitgeese/yes-chef-api

Repository files navigation

Yes Chef API

A secure, multi-user API service using FastAPI and SQLModel that manages user ingredient inventories and shopping lists with authentication.

Tech Stack

  • Language: Python 3.10+
  • Web Framework: FastAPI
  • ORM/Data Modeling: SQLModel
  • Database: PostgreSQL
  • Authentication: fastapi-users
  • Database Migrations: Alembic
  • Containerization: Docker

Project Structure

src/
├── main.py                  # Application entry point
├── config.py                # Global configuration
├── database.py              # Database connection setup
├── migrations/              # Alembic migrations
├── auth/                    # Authentication module
│   ├── models.py            # User model
│   ├── schemas.py           # Pydantic schemas
│   ├── dependencies.py      # Auth dependencies
│   ├── router.py            # Auth endpoints
│   └── service.py           # Auth business logic
├── ingredients/             # Ingredients module
│   ├── models.py
│   ├── schemas.py
│   ├── dependencies.py
│   ├── router.py
│   └── service.py
├── shopping_lists/          # Shopping lists module
│   ├── models.py
│   ├── schemas.py
│   ├── dependencies.py
│   ├── router.py
│   └── service.py
└── utils/                   # Shared utilities
    ├── exceptions.py        # Custom exceptions
    └── pagination.py        # Pagination helpers

Getting Started

Prerequisites

  • Python 3.10+
  • Docker and Docker Compose (optional)
  • PostgreSQL (if not using Docker)

Environment Setup

  1. Clone the repository
  2. Create a .env file based on example.env:
cp example.env .env
  1. Update the environment variables in .env with your values

Running the Application

With Docker

docker-compose up -d

Without Docker

  1. Create a virtual environment and activate it
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies
pip install -r requirements/dev.txt
  1. Run the application
uvicorn src.main:app --reload

Database Migrations

Initialize migrations (first time):

alembic revision --autogenerate -m "Initial migration"
alembic upgrade head

Apply migrations:

alembic upgrade head

API Documentation

When the application is running, visit:

  • Swagger UI: http://localhost:8000/docs
  • ReDoc: http://localhost:8000/redoc

Development

Code Formatting and Linting

To set up pre-commit hooks:

pip install pre-commit
pre-commit install

To manually format code:

black src
isort src
flake8 src

Running Tests

pytest

About

FastAPI backend for Yes Chef application that manages user ingredient inventories and shopping lists

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published