- Django project in
snorkelforecast/with settings atsnorkelforecast/snorkelforecast/settings.pyand entrypointsnorkelforecast/manage.py. - Main app:
conditions/(views, urls, templates). - Static assets in
static/(root, Tailwind output) andsnorkelforecast/static/(project-scoped assets). - Node/Tailwind config:
tailwind.config.mjs,package.json. Python config:pyproject.toml(uses uv + ruff).
- Install deps (uv):
uv sync(usespyproject.toml/uv.lock). - Run server:
uv run python snorkelforecast/manage.py runserver. - DB migrations:
uv run python snorkelforecast/manage.py makemigrations && uv run python snorkelforecast/manage.py migrate. - Tailwind (dev):
npm run tailwind:watch. - Tailwind (build):
npm run tailwind:build. - Lint:
uv run ruff check .| Format:uv run ruff format .. - Docker (prod-like):
docker build -t snorkelforecast . && docker run -p 8000:8000 snorkelforecast(runs Gunicorn).
- Python 3.12+, 4‑space indent, type hints encouraged.
- Keep Django app layout conventional:
views.py,urls.py,templates/<app>/. - Use snake_case for modules/functions, PascalCase for classes, kebab-case for static filenames when applicable.
- Run Ruff before PRs; keep diffs minimal and focused.
- Use Django’s test runner. Place tests in
conditions/tests/(e.g.,test_views.py). - Name tests descriptively (
test_<functionality>_...) and cover happy-path and edge cases. - Run tests:
uv run python snorkelforecast/manage.py test.
- Commit messages: prefix scope when helpful (e.g.,
fix: ...,feat: ...), imperative mood, concise subject, optional body. - Default workflow: commit changes directly to
mainand pushmainunless the user explicitly asks for a branch or PR. - PRs should include: clear description, linked issue (if any), screenshots for UI changes, and a brief testing checklist.
- Keep PRs small and cohesive; avoid unrelated refactors.
- Install tooling:
uv add --dev pre-committhenuv run pre-commit installanduv run pre-commit install --hook-type pre-push. - Hooks run Ruff lint/format, basic checks, Conventional Commit message lint, and run Django tests on pre-push.
- Run locally:
uv run pre-commit run --all-files.
- A background scheduler (
conditions/scheduler.py, started bystartup.sh) loops every 30 min fetching forecasts for allSnorkelLocationrows via Open-Meteo and persisting them toForecastHour. - Page views serve forecast data in this order: Django cache (6h TTL) →
ForecastHourDB (populated by scheduler) → Open-Meteo API (slow, only for locations never seen before). - Dedicated sea-temperature pages at
/<country>/<city>/sea-temperature/for SEO. Embeddable iframe widget at/<country>/<city>/embed/sea-temperature/with a dofollow backlink.
- For production, set
DEBUG=false, configureALLOWED_HOSTS, and provide a secureSECRET_KEYvia environment. - Static files are served by WhiteNoise; run
collectstaticin builds. - Avoid committing secrets; use
.env.exampleas a reference and load env vars in your runtime (container/orchestrator).