1. phases
Itinera API
  • ✈ Itinera API Documentation
  • Docs
    • legacy
      • Itinera — System Overview
      • Technology Stack & Architecture
      • Getting Started Guide
      • Infrastructure
      • Frontend Application
      • Architecture Overview
      • API Reference
      • Backend Services
      • Development Guidelines
    • phases
      • 01. Architecture Overview & Checkout Idempotency
      • Phase 2: Commerce & Checkout Engine
      • Phase 3: Webhooks & Asynchronous Fulfillment
      • Phase 4: Security Perimeter & Authentication
      • Phase 5: Database Schema & Entity Relationships
      • Phase 6: AI Quota & Telemetry Subsystems
      • Phase 7: API Route Matrix & FormRequests
      • Phase 8: Global Exception & Error Handling
      • Phase 9: Frontend Ecosystem & State Management
      • Phase 10: Design System & Component Library
      • Phase 11: Interactive GSAP Animations
      • Phase 12: Deployment & CI/CD Pipeline
      • Phase 13: Testing Strategies
      • Phase 14: Performance & Optimization
      • Phase 15: Developer Onboarding & Runbooks
      • 15-Phase Comprehensive Wiki & Documentation Plan
  • APIs
    • Auth
      • Register a new user
      • Log in a user
      • Log out user
      • Refresh JWT token
      • Forgot password request
      • Reset password verification
      • Get current user profile
      • Update user profile
      • Redirect to Google OAuth
      • Google OAuth Callback
      • Verify email via signed URL
    • Catalog
      • List all countries
      • Get country details
      • List all cities
      • List all regions
      • List all destinations
      • Get destination details
      • Get hotels by destination
      • List all hotels
      • Get hotel details
      • Get reviews for a hotel
      • List all flights
      • Get flight details
      • List all restaurants
      • Get restaurant details
      • List all attractions
      • Get current weather
      • Submit review for an entity
      • Delete review
      • Toggle favourite status for entity
      • List my submitted reviews
    • Bookings
      • Book a tour destination
    • V1 Aliases
      • V1 List all countries
      • V1 Get country details
      • V1 List all cities
      • V1 List all destinations
      • V1 Get destination details
      • V1 Get hotels by destination
      • V1 List all hotels
      • V1 Get hotel details
      • V1 Get reviews for a hotel
      • V1 List all flights
      • V1 Get flight details
      • V1 List all restaurants
      • V1 Get restaurant details
      • V1 List all attractions
      • V1 Get attraction details
      • V1 List all regions
      • V1 Get weather details
    • Trips
      • List user trips
      • Create a new trip
      • Get trip details
      • Update trip details
      • Delete a trip
      • Get creation metadata
      • Attach items to a trip
      • Update trip item
      • Detach items from a trip
      • Fork a trip
    • Conversations
      • List user conversations
      • Start a new conversation
      • Get conversation details
      • List messages in conversation
      • Send message to conversation
      • Mark conversation as read
    • Commerce Plans
      • List public plans
      • Get public plan details
    • Commerce Subscriptions
      • Subscribe to a plan
      • Upgrade active plan
      • Get active subscription info
      • Cancel active subscription
    • Commerce Checkout
      • Initiate Paymob payment checkout
    • Integrations
      • Paymob status webhook callback
      • Paymob redirect return callback
    • System Settings & Support
      • Submit public contact message
      • Subscribe to system newsletter
      • Get list of my reports
      • List all notifications
      • Mark single notification as read
      • List available surveys
      • Submit answers for survey
      • Get survey details
      • Update survey details
      • Delete survey response
    • AI Tools
      • Enhance itinerary details using AI
      • Request AI review of itinerary
      • Plan route using AI assistance
      • Get AI quota remaining details
      • Chat with AI Concierge assistant
      • Get AI Review progress by ID
    • Agency Integration
      • Request agency assignment
      • List agency active tasks
      • List agency managed trips
      • Get agency total earnings
      • Get agency profile details
      • Update agency profile details
    • Admin User Management
      • List users inside admin dashboard
      • Get user profile
      • Set user active status
      • Block user profile
    • Admin Catalog Moderation
      • Create new catalog category
      • Create new catalog destination
      • Create new hotel catalog record
      • Create new flight catalog record
      • Create new restaurant catalog record
      • Create new attraction catalog record
  • Schemas
    • User
    • ErrorResponse
    • Trip
    • Destination
    • Hotel
    • Flight
    • Restaurant
    • Attraction
    • Booking
    • Review
    • Agency
    • Survey
  1. phases

Phase 9: Frontend Ecosystem & State Management

This document maps the itinera-showcase-react SPA: Vite + React 19 + React Router 7 + Tailwind 4 + GSAP. It is a static, content-driven showcase with zero runtime API calls to the Laravel backend — all content lives in src/lib/*.ts and is rendered client-side.

1. Toolchain & Boot#

Stack: vite@8, @vitejs/plugin-react, @tailwindcss/vite@4, typescript@6, vitest@4 (happy-dom), oxlint.
Boot sequence — src/main.tsx:1-13:
import { initTheme } from './lib/theme-store'
initTheme() // 1. set html.light + colorScheme from localStorage BEFORE React mounts — prevents flash
createRoot(...).render(<StrictMode><App /></StrictMode>) // 2. double-invoke effects in dev
vite.config.ts registers react() and tailwindcss() plugins; test.environment = 'happy-dom', globals: true for Vitest.

2. Routing: src/App.tsx:23-36#

No data router (createBrowserRouter), flat BrowserRouter + Routes:
PathElementNotes
/Home9 sections: Hero, Orbit (§01), Bins (§02), Frontend flip-cards (§03), Bento vault (§04), Ops (§05), etc.
/lifecycleLifecyclePage12 sections pinned via GSAP scrub (see Phase 11)
/docsDocsStatic explorer
/wiki, /wiki/:guideIdWikiuseGuide fetches markdown under /wiki/
*Homecatch-all
Global overlay: GlobalPalette lives outside Routes but inside BrowserRouter, reads useLocation(). entries = GUIDES.map(...) only when pathname.startsWith("/wiki") — route-aware palette index.

3. State Model: No Global Store#

There is no Redux/Zustand/Context. State is local or module-level external store.
Theme — src/lib/theme-store.ts:1-47: Module variable theme: Theme + Set<() => void> listeners + useSyncExternalStore(subscribe, getTheme). apply() toggles document.documentElement.classList.toggle("light", ...) and style.colorScheme. initTheme() called before React; setTheme() persists to localStorage and notifies listeners. Every useTheme() instance syncs without a Provider.
Page-local: Home.tsx — dialogIdx, activeDefense, useState for flip is-flipped via pointerenter; LifecyclePage.tsx — imperative currentIdx, startOffset Map, stInstances[] (not React state). GSAP owns the scroll state, not React.
Data-fetch cache — src/lib/use-guide.ts:6,23: Module cache = new Map<string,string>(), fetch(/wiki/${guide.file}) with cancelled guard and cache.set. Mount checks cache.get synchronously for instant hit.

4. Content Layer: Static Data as CMS#

All copy is typed arrays in src/lib/:
home-content.ts — HARDENING[], TELEMETRY[], TERM_LINES[]
lifecycle-content.ts — LifecycleStage[] (10 stages + hero/outro)
wiki-data.ts / docs-data.ts / explorer-data.ts / kpi.ts — guides, explorer nodes
security-data.ts — RBAC matrix
lifecycle-content.ts → ChapterScene.tsx scene prop
No fetch to api.php at runtime; fetch() appears only as textual content (LifecyclePage.tsx:56 chips ["fetch()",...]) except useGuide static markdown fetch.

5. Component Taxonomy#

src/components/
  layout/        Topbar, Shell
  sections/      FeMotifs, SecurityMotifs, HardCircle, etc. — §03 flip backs, §04 vault
  lifecycle/     ChapterScene.tsx — SVG scenes per stage
  palette/       command-palette.tsx — cmdk + Radix Dialog
  explorer/      Explorer tree for /docs
  wiki/          Markdown render (react-markdown)
  docs/          Docs shell
  ui/            cta-circle, sheet, dialog, command — Radix + cva + tailwind-merge
src/pages/
  Home.tsx       688 lines: orbit, bento, flip-cards, ops
  LifecyclePage.tsx 817 lines: GSAP scrub engine
  Wiki.tsx / Docs.tsx
src/lib/
  gsap.ts        register ScrollTrigger + MotionPathPlugin once
  fuzzy.ts       palette fuzzy search
  utils.ts       cn() = clsx + twMerge
  barcode.ts     bwip-js helper
src/hooks/
  useIsReducedMotion, useScrollTo, useCountUp

6. Rendering & Data-Fetch Lifecycles#

Wiki guide load — useGuide:15-38:
Theme toggle: toggleTheme() → setTheme(next) → localStorage + apply() → listeners.forEach(l=>l()) → useSyncExternalStore re-render — no Context propagation, minimal re-renders (only useTheme subscribers).

7. Architectural Principles#

1.
Content is code. src/lib/*.ts is the CMS; adding a stage is a data entry in lifecycle-content.ts, not a migration. No backend coupling in prod showcase.
2.
External store > Context for theme. useSyncExternalStore avoids a ThemeProvider wrapping the whole tree and works before React mounts (initTheme()).
3.
GSAP owns scroll, React owns DOM. LifecyclePage keeps timelines in stInstances[] and tl locals, useRef for DOM, startOffset Map for nav — React state is not the source of truth for scrub position (see Phase 11).
4.
Fail-safe fetch. useGuide has module cache + cancelled flag for StrictMode double-mount — no memory leak, no duplicate network on remount.
5.
One build, two themes. html.light class flips CSS vars; JS only toggles the class (Phase 10).
Modified at 2026-08-25 22:41:45
Previous
Phase 8: Global Exception &amp; Error Handling
Next
Phase 10: Design System &amp; Component Library
Built with