Architecture
State management
Zustand stores, persistence, and undo/redo.
routess uses Zustand for client state. Stores live in packages/core/src/stores/ so the web and (future) mobile app can share them.
Stores
- routingStore: current route waypoints, derived stats, undo/redo history
- authStore: current user, OAuth state
- uiStore: map style, sidebar open state, language
Why Zustand (not Redux/Jotai)
- Tiny API, no actions/reducers boilerplate
- Works outside React (so packages can use it)
- Built-in middleware:
persist,subscribeWithSelector
Persistence
The web app wraps routingStore and uiStore with the persist middleware backed by localStorage. The mobile app will swap that for AsyncStorage (see Phase 5 of the mobile plan).
Undo / redo
The routing store keeps a bounded history of past states. Each mutation pushes the current state onto the undo stack before applying. Redo restores from the redo stack on each undo. Stacks reset on auth change.