Skip to content

Design Decisions

hasnaina955 edited this page Sep 3, 2026 · 1 revision

Design Decisions

The load-bearing choices, and why they hold the system up.


The engine is pure functions

src/lib/engine.ts (and friends: impact.ts, ridePlan.ts, vehicleProfile.ts) contain no React and no I/O. Every estimate — schedule, budget, warnings — is a deterministic function of (trip data, assumptions). That's what makes the numbers transparent (the UI can cite its assumptions), testable (259 unit tests, node env, no DOM), and safe to memoize.

The store is cache-first with write-through

Every mutation updates the in-memory cache synchronously (instant UI) and fires the Supabase write in the background — and checks its result: on error it toasts and rolls back the optimistic write, so the UI never disagrees with the server. Authorization is enforced by Postgres Row Level Security, not UI checks. A fire-and-forget write is the bug class that made a published itinerary "vanish" (v0.23.0) and seeded ~2,100 junk trips (Sep 2026); the write-through rule is law (AGENTS §4).

Data model: strings and numbers, not magic

Times are stored as 24h "HH:MM" strings and formatted at render (12h/24h is a user preference); coordinates are plain lat/lng numbers so any map provider can consume them; optional fields are string | undefined and helpers type for the real shape.

Providers are facades with graceful fallback

Google Places/Routes are opt-in keys with quota guards; on absence, exhaustion, or failure the app silently falls back to the open stack (OSM, Wikipedia, Mappls, OSRM, Open-Meteo). The basemap is OpenFreeMap — keyless, commercial-OK, attribution carried by its TileJSON. Data-only usage: Google results render as suggestions, never persisted.

Glass is one recipe, not per-component art

Surfaces share tokenized glass (--yf-nav-glass, border, blur tokens). Hard-won: a backdrop-filter ancestor becomes the blur root, so nested panels' frost silently does nothing — floating panels must portal outside it (Sep 2026).

View Transitions only without backdrop-filter

The theme radiate transition suppresses backdrop-filter for its duration — Chromium renders glass inside VT snapshots without its backdrop, turning the page into a gray veil (AGENTS §4).


Related: Architecture Overview · Release Process

Canonical doc: docs/ARCHITECTURE.md · AGENTS.md

Clone this wiki locally