01The problem
Weather apps tell you the forecast, not when to go. I wanted a tool that answers "when is the best time this week for this route?" and explains why, and I wanted its AI feature to be safe to leave running on the public internet.
02Setup
- Ranks every daylight window in the next five days using rain, wind and feels-like penalties, and shows the scoring math instead of hiding it.
- Parses GPX files in the browser and forecasts conditions at each checkpoint for the hour you'd reach it.
- Maps with Leaflet; forecasts from Open-Meteo.
- The AI trail briefing goes through a Cloudflare Worker with a server-side API key, a CORS allowlist, strict input validation, rate limiting, and a template fallback.
- Unit tests plus Playwright responsive checks at 390, 768 and 1280 px.
03Architecture
04What broke and how I fixed it
Threats the Worker is built against
- Leaked API key: the key is a server-side secret in the Worker, never shipped to the browser.
- Other sites using my endpoint: a CORS allowlist only accepts requests from the app's origin.
- Malformed or oversized input: strict validation rejects anything that isn't a well-formed briefing request.
- Abuse and runaway cost: rate limiting caps how often the endpoint can be called.
- Model outage: a template fallback still returns a useful briefing.
05What I'd do next
- Let people tune the penalty weights (some hikers don't mind wind) and save their preferences.
- Add Worker request logging and alerting so abuse shows up before the rate limit does.