2024-05-23 12:00:13 +00:00
|
|
|
Meal planner backend
|
|
|
|
|
|
2025-10-18 03:26:42 +00:00
|
|
|
## 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
|
|
|
|
|
|
2024-05-23 12:00:13 +00:00
|
|
|
Install packages
|
|
|
|
|
```
|
|
|
|
|
pip install -r ./requirements.txt
|
|
|
|
|
```
|
|
|
|
|
|
2025-10-18 03:26:42 +00:00
|
|
|
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):
|
2024-05-23 12:00:13 +00:00
|
|
|
```
|
2025-10-18 03:26:42 +00:00
|
|
|
ruff check .
|
|
|
|
|
black .
|
|
|
|
|
mypy .
|
2024-05-23 12:00:13 +00:00
|
|
|
```
|
2025-10-18 05:44:36 +00:00
|
|
|
|
|
|
|
|
## 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.
|