Guide · Frontend structure

Component inventory and split plan for site scripts

Use this page before splitting a site script. It inventories every component in pack app-chauffeur.site.1, names the oversized components that mix data fetching, business logic and presentation, and states the proposed components, their props, and their client and server boundaries. No server endpoint, storage key, field id, or route changes in this plan.

Scope and how to read the inventory

Scope is the site files in this pack only. App view code and server code are not in this pack, so a component that calls an app route is listed by that route name only and no app internals are assumed. A prop is a value passed in, a DOM root, or a callback. A boundary states whether work happens in the browser, on the server, or in both. A component with no prop and no fetch is static markup.

Static pages

Marketing pages and guides are server served static HTML. The browser only binds menus, forms, tables, and search on the pages that contain them. No page component fetches workspace data.

Client components

Scripts in the browser own local state, local storage, and rendering. They call public endpoints only. Signed in app data stays behind sign in and is not read by these components.

Inventory of every component in the site source

Read the props column first. It is the contract a split must keep.

ComponentFileResponsibilitiesProps and stateBoundary
Marketing pagespublic/index.html, about, airport, features, fleet, for-business, integrations, schedule, security, accessibility, request-demo, passenger-book, onboarding-checklist, 404, offlineStatic content, header and footer, hero and section markup, forms with data-request on request-demo, quote estimator form on indexProps: none. State: DOM only, plus inline script state on index, passenger-book, onboarding, 404 and offlineServer: static file. Client: site.js binding only
Guidespublic/guides/*.html, about 55 filesStatic guide content, and search plus filter on guides/index.htmlProps per card: data-keywords, data-who, data-audience, data-stage, link href. State: search text and checked filter boxes, address query q, sections, who, audience, stageServer: static file. Client: index search script only
App shellpublic/app/index.html, public/app/passenger-book.htmlBoot fallback, nav drawer, table scroll and data labels, dialog focus trap, skip link, plus a second copy of the passenger booking form in app/passenger-book.htmlProps: DOM roots aside, header nav, main, tables. State: nav-open class, dialog opener, boot timer. Form props as in passenger-book belowServer: static shell, app code at /app/app.js not in pack. Client: shell scripts only
Site scriptpublic/site.jsError boundary, injected styles, in memory analytics, mobile nav with focus trap, skip links, public form outbox with retry and validation, responsive tables, service worker register, public page prefetch, canonical and social metadata injection, JSON-LD injection, aria-current in header and footer, funnel listenersProps: .nav-btn, .site-nav, form[data-request], location.pathname, document head, tables. State: outbox entries in local storage under chauffeurdesk:public-request:outbox:v1, analytics array in memory only, prefetched set, service worker registrationClient only, except POST /api/public/request and /sw.js register. No server change in split
Passenger booking formpublic/passenger-book.html, inline script. Duplicate at public/app/passenger-book.html with divergent validationRequest validation, quote preview fetch with cache and abort, draft save and restore in local storage, outbox post with retry and idempotency key, status view by token, update, reschedule and cancel posts, calendar .ics generation and downloadProps: form fields service_type, pickup, dropoff, pickup_at, estimated_hours, passengers, passenger_name, passenger_phone, booker fields, airline, flight_number, meet_point, sign_text, requests, and hash token. State: currentBooking, quote cache map, draft timers, outbox entries chauffeurdesk:passenger-book:outbox:v1Client only. Server routes unchanged: /api/publicbook/public/quote, /request, token status, /live, /submit, /reschedule, /cancel
Home quote estimatorpublic/index.html, inline script at endQuote preview fetch, session cache with 5 minute TTL, render quote line, validate estimator fields, store quote form values in local storage, redirect to /passenger-bookProps: e-service-type, e-estimated-hours, e-pickup, e-dropoff, e-pickup-at, e-passengers. State: cache map, session key chauffeurdesk:quote-cache:v1, local key chauffeurdesk:passenger-book:quote-form:v1Client only. Server: same quote route as passenger-book, duplicated in a second copy
Onboarding checklistpublic/onboarding-checklist.html, inline scriptRole step list, progress bar, dismiss, complete and reset, per workspace and per person storage on this device, role landing textProps: ws-name, person-name, role-select, join-mode. State: checked map, dismissed, completed, keys chauffeurdesk:onboarding:prefs:v1 and chauffeurdesk:onboarding:v1Client only, local storage only. No server call
Site stylepublic/site.cssLayout, header and nav, hero, grids, features, steps, bands, forms, tables, call to action system, accessibility contrast and focus, responsive breakpoints at 1100, 900, 640 and 380Props: none. State: none, cascade order is the contractStatic file only
Not found and offline pagespublic/404.html, public/offline.htmlReturn path handling, copy address, page search on 404, retry and offline status, asset error noticeProps: location pathname, search, hash, referrer. State: session key chauffeurdesk:return-path, scroll position on 404Client only

Oversized components to split first

A component is oversized here when it has more than three responsibilities, mixes fetching with logic and rendering, or is duplicated in a second copy. Four components meet that test.

1. public/site.js

Twelve responsibilities in one deferred file loaded on every marketing page, including form outbox and retry code that only request-demo needs. Fetching, validation, rendering, analytics, and metadata injection share one scope, so a change to one part risks the others and every page pays the parse cost for all of it.

2. Passenger booking inline script, in two copies

Validation, fetching with retry, quote cache, draft storage, calendar generation, and status rendering in one script, copied at /passenger-book and /app/passenger-book with different validation. The app copy lacks the drop off and airline required checks and uses a looser phone check, as stated in the operations inventory guide. One logic change must be made in two places and the copies have already diverged.

3. Home quote estimator in public/index.html

A third copy of quote fetching, caching, and rendering, with a different cache key and TTL from passenger-book. The same quote rule can drift a third time.

4. App shell inline styles and script in public/app/index.html

Nav drawer, table handling, dialog focus, boot fallback, and several style blocks in one file. Lower priority than the three above because it only loads in the signed in app, but the same split pattern applies.

  • Site style is large but single responsibility by cascade. Split it last, after scripts, and keep cascade order or add a regression check for call to action and focus styles.
  • Onboarding, 404, and offline are single page components with one state owner each. Keep them as page modules in phase 3, do not merge them.

Split plan, phase 1: public/site.js

Extract in this order. Each module is a plain script or ES module with no build step, loaded with defer in the same order as today. No endpoint, key, or id changes.

Proposed moduleProps inProps out and eventsBoundary
site/nav.js.nav-btn, .site-nav, header elementToggles .open and aria-expanded, moves focus into the nav on open, restores focus on Esc and on close, closes on outside click and on resize above 900Client DOM only. No fetch
site/forms.js, loaded only on pages with form[data-request]Form element, form dataset request, location pathname, submit buttonPOST /api/public/request with the same Idempotency-Key across retries, same 15000 millisecond timeout, same retry statuses 429, 408, 502, 503, 504, same outbox key, shows .form-status and .form-done, emits demo_form_submit_success and demo_form_submit_error through the analytics moduleClient to server on the existing route only. Server code unchanged
site/analytics.jsDo Not Track flag, location pathnamewindow.__cdEmit and window.__chauffeurdeskAnalytics, in memory only, no network send, no cookie, no storageClient only. No server call
site/metadata.jsDocument head, document title, meta description, location pathnameAdds canonical, Open Graph, Twitter, and JSON-LD only when absent, skips pages with robots noindexClient DOM only
site/tables.jsTable elementsWraps each table in .table-scroll with tabindex, role region, and aria-label, copies thead labels onto cells as data-labelClient DOM only
site/register.jsnavigator.serviceWorker, window load eventRegisters /sw.js at scope / with updateViaCache none, idle timeout 3000 where available, update on online, focus, and visibleClient to /sw.js only
site/prefetch.js and site/nav-current.jsAnchor hrefs, navigator connection saveData and effectiveType, location pathnamePrefetches public pages only, never /app/ or /api/, at most 12 pages. Sets aria-current page in header and footer from the actual path and adds Schedule, For business, Integrations, and Book a ride to the footer when missingClient only

Bundle target for phase 1: pages without a data-request form do not load the form outbox module at all. The remaining modules are each under one responsibility, so a nav change does not re-test form retry, and a metadata change does not re-test the service worker.

Split plan, phase 2: passenger booking and quote preview

Build one shared client module set and use it from both passenger-book copies and from the home estimator. Keep every field id, storage key, and endpoint the same, so saved drafts and outbox entries keep working.

Proposed moduleProps inProps out and eventsBoundary
passenger/api-client.jsURL, fetch options, allowNetworkRetry flagResponse after retry on 408, 429, 502, 503, 504 honoring Retry-After, timeout 15000, AbortController chaining. No renderingClient to /api/publicbook/public/* only
passenger/validation.js, pureForm values as an object, service typeReturns body and errors as id plus message pairs. Implements the api-validation guide table once, including drop off required except hourly and event, airline and flight required for airport_arrival, phone digits 10 to 15, estimated hours 0.25 to 24 in quarter hour steps, passengers 1 to 7Pure client logic. Server remains the authority with the same rules. No fetch, no DOM
passenger/quote-preview.jsService type, estimated hours, cache map, render callback, error callbackFetches the quote route, aborts the prior request, renders rate, gratuity, and total on separate lines, or the exact pricing sentence when amounts are missing. Used by passenger-book and by the home estimator with the same cache shapeClient to quote route only
passenger/calendar.js, pureBooking object with pickup_at, estimated_hours, service, pickup, drop off, flight, meet point, sign text, passengers, quote amounts, status, chauffeur and vehicle when Driver confirmedReturns .ics text with CRLF, stable UID from reference code, DTSTART from pickup_at, DTEND from estimated hours when valid, chauffeur detail only from Driver confirmed, or null when pickup time or reference is missingPure client logic. No fetch, no DOM, no server call
passenger/draft-store.jsForm id, form element, draft prefix chauffeurdesk:passenger-bookSaves and restores form values in local storage with savedAt, clears after a confirmed submit, schedules save on input and change with 250 millisecond debounceClient local storage only
passenger/status-render.jsBooking object, live stage object or null, render callbackReturns status markup with company timezone times beside device times, hides chauffeur detail before Driver confirmed, shows Add to calendar only for Confirmed through Passenger on boardClient rendering only. Data comes from the status route
  • Fix in the same phase: align the app copy validation with the public copy, as stated in the operations inventory guide, by using the one validation module for both copies. Do not add a new field name, since any other field name fails the request under the api-validation guide.
  • Keep the outbox post module with the same Idempotency-Key on retry, the same fingerprint check, and the same clear only after a confirmed ok response.
  • Keep the calendar gating rule: no chauffeur name, colour, type, plate, or line before Driver confirmed, in the file and on the status page.

Split plan, phase 3: style, shell, and page modules

Do these after phases 1 and 2 pass. Each step keeps the same rendered output.

  1. Split site.css by component in cascade order

    Layout and header, nav, buttons and call to action, forms, tables, guides and cards, then accessibility and responsive blocks last so they keep winning the cascade as today. Props: none. Boundary: static files only. Check: no long lived caching on unhashed files, per the standing rules.

  2. Move app shell inline styles into app.css

    Keep the boot fallback markup and its retry and sign in links. Props: DOM roots aside, header nav, main, dialog elements. Boundary: client only, app code at /app/app.js unchanged.

  3. Move page inline scripts into page modules

    Onboarding checklist becomes onboarding.js with props ws-name, person-name, role-select, join-mode and local storage keys unchanged. Not found and offline become page modules with props location pathname and session return path. Boundary: client only, no server call except the existing public routes.

  4. Remove the duplicated estimator

    The home estimator uses passenger/quote-preview.js and passenger/validation.js. Props: service type and estimated hours only. Boundary: client to the quote route only. The estimator keeps its session cache key or migrates it once with a fallback read of the old key.

Acceptance checks before a split ships

Run each check after the matching phase. A failed check means the split does not ship.

  • Nav: Menu opens and closes by keyboard, Esc returns focus to Menu, focus stays inside the open nav and inside an open dialog, and aria-current marks the current page in header and footer.
  • Forms: a demo submit that fails on 429 or 503 retries with the same Idempotency-Key, a 400 clears the outbox entry, a timeout keeps the entry for one manual retry, and no duplicate pending entry is created.
  • Quote: changing service or hours renders the quote or the exact pricing sentence, stale responses are discarded, and the cache never changes a saved quote.
  • Booking: an MCI arrival without airline or flight, and a point to point ride without drop off, fail in both copies with the field named and no booking saved. Draft entries restore after reload and clear after a confirmed submit.
  • Calendar: a Confirmed booking before Driver confirmed lists no chauffeur detail, the same booking after Driver confirmed lists chauffeur and vehicle from the assigned records, and a missing pickup time produces no file.
  • Bundle: a page with no data-request form loads no form module, a page with no quote form loads no quote module, and no page loads app code from a marketing page script.
  • No endpoint, storage key, field id, or route name changes in any phase. Server validation stays the authority for every write.

Split by responsibility, keep every contract

Read this inventory with the operations inventory guide, then extract phase 1 site modules first.