Files
road-compiler/.trellis/spec/frontend/directory-structure.md
T

1.3 KiB

Directory Structure

The Vite workbench lives in workbench/client/. Application code is under src/:

  • components/ contains typed React view components and form sections. Components receive domain data and commands through props; they do not own cross-page persistence.
  • hooks/ contains one stateful editing domain per hook (useOverrideDraft, useDirectEditSession, or useTrafficSignalDraft). Hooks may call the API boundary through injected commands, but must not share mutable module state.
  • edit/ contains pure direct-edit models, projections, sessions, preview arbitration and geometry-unit helpers.
  • map/ contains OpenLayers adapters. MapCanvas.tsx owns map lifecycle and map/layers.ts owns the layer registry and source updates.
  • lib/ is the browser HTTP boundary; types/ owns API and workbench contracts; ui/ contains shared primitives.

App.tsx is the composition root: it loads server state, owns selection and page-level commands, and connects editing domains to the map and inspector. It must not contain substantial form implementations or a second copy of an editing protocol.

Keep OpenLayers construction and source mutation outside page components. The map is constructed once per mounted canvas; React re-renders and inspector extraction must not rebuild it or reset its view.