No description
Find a file
jableader f51c90f922 - [x] Wire routers in main with minimal app code
- [x] Create api/deps module for get_db, cookie_person, and error_response
- [x] Use settings.py (DOOF_DB) for DB path in main and deps
2025-10-18 17:14:03 +11:00
.github/workflows Squashed commit of the following: 2025-10-18 16:44:36 +11:00
api - [x] Wire routers in main with minimal app code 2025-10-18 17:14:03 +11:00
ingredients Squashed commit of the following: 2025-10-18 16:44:36 +11:00
meals Squashed commit of the following: 2025-10-18 16:44:36 +11:00
persons Squashed commit of the following: 2025-10-18 16:44:36 +11:00
products Squashed commit of the following: 2025-10-18 16:44:36 +11:00
recipes Squashed commit of the following: 2025-10-18 16:44:36 +11:00
scripts Squashed commit of the following: 2025-10-18 16:44:36 +11:00
shopping Added ruff, black and mypy 2025-10-18 14:26:42 +11:00
tests Squashed commit of the following: 2025-10-18 16:44:36 +11:00
.editorconfig Added ruff, black and mypy 2025-10-18 14:26:42 +11:00
.gitignore Added ruff, black and mypy 2025-10-18 14:26:42 +11:00
common.py Squashed commit of the following: 2025-10-18 16:44:36 +11:00
db.py Added ruff, black and mypy 2025-10-18 14:26:42 +11:00
main.py - [x] Wire routers in main with minimal app code 2025-10-18 17:14:03 +11:00
openapi-baseline.json Squashed commit of the following: 2025-10-18 16:44:36 +11:00
openapi.json Squashed commit of the following: 2025-10-18 16:44:36 +11:00
plan.md Significant refactor 2024-01-13 12:54:04 +11:00
pyproject.toml Added ruff, black and mypy 2025-10-18 14:26:42 +11:00
README.md Squashed commit of the following: 2025-10-18 16:44:36 +11:00
refactor-project-strategy.md - [x] Wire routers in main with minimal app code 2025-10-18 17:14:03 +11:00
requirements.txt Fixed requirements.txt 2024-09-20 20:12:46 +10:00
settings.py Scaffolding 2025-10-18 16:50:43 +11:00
transform.sql Squashed commit of the following: 2024-10-13 19:19:57 +11:00
units.py Added ruff, black and mypy 2025-10-18 14:26:42 +11:00

Meal planner backend

Structure

  • main.py: FastAPI app with all HTTP endpoints.
  • db.py: aiosqlite connection + schema bootstrap across subpackages.
  • Domain packages with models and persistence:
    • products/ (db, scrapers for Woolworths/Coles)
    • ingredients/
    • recipes/ (db, scraping)
    • meals/
    • persons/
    • shopping/
  • tests/: unit and API tests with sample HTTP fixtures.

Getting started

Install packages

pip install -r ./requirements.txt

Run API (dev)

uvicorn main:app --reload

Run tests

python -m unittest -q

Tooling

This repo includes baseline configs in pyproject.toml:

  • black (format)
  • ruff (lint)
  • mypy (type check)

Optional commands (install these locally first):

ruff check .
black .
mypy .

Environment variables

  • DOOF_DB: Path to sqlite database (default: ./data/doof.sqlite)
  • DOOF_PORT: Port the server listens on when containerized; align Dockerfile EXPOSE accordingly.

OpenAPI schema

  • Generate the schema artifact used by the frontend and CI checks:
python scripts/export_openapi.py

This writes openapi.json to the repo root. Versioned endpoints live under /api/v1, legacy under /api (deprecated with Deprecation header).

Schema lint/diff (manual)

Optionally, lint and compare schemas locally using Node tools:

npx -y @stoplight/spectral-cli lint openapi.json
npx -y openapi-diff --fail-on-changed --fail-on-incompatible path/to/baseline.json openapi.json

Keep a baseline.json on release branches to detect breaking changes.