Skip to content

Routing model

The React SPA is a client-side router on Cloudflare Pages. There is no Next.js file-based router — the map is explicit TypeScript.

Related: Permissions · Domains · Features.


Source of truth

FileRole
apps/web/src/router/AppRoutes.tsxCanonical route tree
apps/web/src/router/config/routeConfig.tsPermission / access per path
apps/web/src/router/guards/PermissionGuard.tsxEnforces access around page elements

Access is permission-based, not “which folder the page file lives in.”


Path conventions

AreaPaths
Auth/login, register / verify flows as defined in AppRoutes
Account / meShared account surfaces under agreed /me or settings paths
Users/users, /users/new, /users/:id, activities as nested routes
Maintenance/maintenance, create / detail under the same shared prefix
Departments/departments, detail
System/system/monitor, /system/logs, /system/audit, /system/settings
Role dashboardsRole-unique home/dashboard routes (not used for shared CRUD)

Do not prefix shared CRUD with /admin or /hod — that duplicates pages and fights the permission model.


How a route is wired

  1. Page component lives under domains/shared/pages/... or a role folder
  2. AppRoutes mounts it at a path
  3. getRouteAccess(path) supplies the access config
  4. Element is wrapped: <PermissionGuard access={access}>{element}</PermissionGuard>

SPA hosting notes

  • Pages serves the SPA; unknown paths fall through to index.html for client routing
  • API calls go to api.cepatedge.com (or local Worker), not to the Pages origin
  • Auth cookies must cover app + API hosts — see Domains

Maintainer checklist

  • [ ] Path added to AppRoutes
  • [ ] Access entry in routeConfig
  • [ ] Page placed under shared vs role per domains
  • [ ] Nav / sidebar entries only if the user can actually open the route