Files
skipredictor/CLAUDE.md
T
2026-10-18 15:02:48 +02:00

2.6 KiB

CLAUDE.md

Overview

SkiPredictor forecasts next-day status (open probability, km open, crowd level) for three Northern Spain ski stations, combining a rules engine with ML models (scikit-learn, LightGBM) and YOLO-based webcam crowd detection. Delivered via a FastAPI backend and a Telegram bot. See AGENTS.md for the full product/architecture spec.

Commands

  • Setup: ./setup.sh (creates .venv, installs requirements.txt, downloads historical data, trains initial models).
  • Run backend + bot + scheduler: ./start.sh --cron --collect-now --bot.
  • Run API only: .venv/bin/python -m uvicorn app.main:app --host 0.0.0.0 --port 8000.
  • Test: .venv/bin/python -m pytest (or python3 -m pytest if no venv).
  • Lint/format: none configured for the Python codebase (no ruff/black/flake8 in requirements.txt). The mobile/ subproject has its own npm run lint (ESLint).
  • Retrain models: .venv/bin/python scripts/retrain_model.py.

Architecture

data_sources/ (weather + station scraping + webcams) -> pipeline/ (dataset build + feature engineering) -> ml/ + predictor/ (rules engine, ML models, hybrid combiner) -> app/ (FastAPI backend, scheduler) and bot/ (Telegram bot). storage/ wraps the SQLite database. mobile/ is an independent Capacitor/React app, not wired into the Python pipeline. Full details: docs/DEPLOYMENT.md, docs/OPERATIONS.md, docs/API_SPEC.md.

Conventions

  • Station/feature parameters live in config/stations.yaml and config/features.yaml; never hardcode station thresholds in code.
  • Rules always take priority over ML output when physical conditions are deterministic (e.g. extreme wind closes a station regardless of the ML prediction).
  • SQLite (storage/sqlite_store.py) is the single source of truth; no CSV/JSON fallback paths for data the DB already owns.

Workflow quirks

  • Use git worktrees under .tmp/ for parallel feature work (see AGENTS.md), not directories outside the repo.
  • Production is assumed to run on the server unless told otherwise, even when iterating locally.

Deployment

Runs on a VPS/LXC under systemd (no Docker), serving the FastAPI app with an internal APScheduler for forecast cycles and weekly retraining. See docs/DEPLOYMENT.md for the systemd unit and docs/OPERATIONS.md for day-to-day tasks.

Gotchas

  • requirements.txt pulls in ultralytics/opencv-python-headless (YOLO) and lightgbm; installs are heavy (~2 GB) and the first run downloads the YOLO weights.
  • Historical webcam downloads must resolve the real image URL (see LESSONS.md) or you silently save HTML instead of JPEGs.