Vite + Lit Web Component Workflow
Scope & Directory Boundary
- STRICT BOUNDARY: Operate ONLY inside
frontend/. Never modifybackend/source code. - Source of Truth: The backend API contract is read-only from
../backend/target/generated/openapi/openapi.yaml.
Execution Steps
Step 1: Sync OpenAPI Contract & Component Header (STOP FOR HUMAN REVIEW)
- Run
npm run sync-apiinfrontend/to regeneratesrc/api/schema.d.tsfrom the backend OpenAPI spec. - Create or update the target Lit
.tscomponent files with ONLY the top contract header (first ~30 lines):@customElement('...')- Typed
@property()declarations (referencing OpenAPI generated types, neverany). - Dispatched
CustomEventdetail type definitions. declare global { interface HTMLElementTagNameMap { ... } }
- PAUSE: If creating a new view or changing component contracts, let the user verify the
@property()header before writing heavy DOM/CSS. (Skip pause for pure CSS/visual tweaks).
Step 2: Black-Box Implementation
- Implement
render()andstatic styles = cssinside the Lit component. - Encapsulation Rules:
- Properties Down, Events Up.
- Never use
document.querySelectoror pierce another component'sshadowRoot. - Never hand-write raw
fetch()calls with untyped JSON; use the typed API client. - Keep each component file under 250 lines.
Step 3: Mechanical Verification & Static Bundle Build
Run inside frontend/ and fix any errors before reporting completion:
npm run verify && npm run build