40227-vm/frontend/docs/object-router.md
Dmitri d4a5378adf Refactor: migrate frontend to Vite/React, add product backend modules
Frontend:
- Replace Next.js with Vite + React + TypeScript
- Add new component architecture (app-shell, sidebar, dashboard modules)
- Implement product modules: FRAME, safety protocols, walkthrough checkin,
  campus/staff attendance, personality quiz, sign language, classroom timer
- Add shadcn/ui component library with Tailwind CSS
- Remove legacy generated components, stores, and pages

Backend:
- Add product migrations: frame_entries, user_progress, safety_quiz_results,
  walkthrough_checkins, communication_events, personality_quiz_results,
  campus_attendance_config/summaries, staff_attendance_records, content_catalog
- Add corresponding models, services, and routes
- Implement cookie-based auth with refresh token rotation
- Add content catalog seeder with product content
- Migrate to ESLint flat config
- Switch from yarn to npm

Infrastructure:
- Update .gitignore for new tooling
- Add project documentation (CLAUDE.md, docs/)
- Remove deprecated config files and yarn.lock

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-06-09 15:18:23 +02:00

1.7 KiB

Object Router

Purpose

Top-level frontend URL routes are declared through React Router object configuration instead of inline JSX route declarations.

Files

  • frontend/src/app/appRoutes.tsx
  • frontend/src/app/ModuleRouteGuard.tsx
  • frontend/src/app/shellOutletContext.ts
  • frontend/src/app/AppRouter.tsx
  • frontend/src/app/AppProviders.tsx
  • frontend/src/shared/constants/routes.ts
  • frontend/src/shared/constants/moduleRoutes.ts
  • frontend/src/pages/modules/

Runtime Shape

  • App.tsx renders provider composition and the router only.
  • AppProviders owns global providers, including BrowserRouter.
  • AppRouter renders useRoutes(appRoutes).
  • appRoutes owns top-level route objects and nested product module routes.
  • APP_ROUTE_PATHS owns route path constants that are reused outside the router.
  • MODULES owns module metadata, including each module route path.
  • Product route pages are loaded with React.lazy.
  • AppLayout is the shared shell route element and passes shell props through outlet context.
  • Module navigation uses route navigation instead of local active-module state.

Rules

  • Do not add individual <Route> declarations to App.tsx.
  • Keep route elements thin; product behavior belongs in business hooks.
  • Reuse APP_ROUTE_PATHS.login for auth-expired redirects.
  • Add route-config and module-route metadata tests when routes change.
  • New product modules must define a route path and a lazy page adapter.
  • Restricted product routes should redirect to /dashboard unless a specific access-state UX is implemented and tested.
  • Use object routes as the default pattern unless React Router data APIs require a later move to createBrowserRouter.