Surfaces & Auth
How admin routes are split between bearer JSON endpoints and the cookie-authenticated Inertia dashboard.
Admin has two route trees, and they are not interchangeable.
Route families
| Family | Prefix | Auth | Render/response | Where documented |
|---|---|---|---|---|
| Admin JSON API | /api/v1/admin/* | Authorization: Bearer <oat_...> + requireAdmin() | JSON envelope | API reference, grouped under Admin tags. |
| Domain admin JSON API | /api/v1/admin/... in domain modules | Bearer + requireAdmin() plus per-action abilities | JSON envelope | API reference. |
| Admin SPA pages/actions | /admin/* | /admin/login web session + requireAdmin() | Inertia HTML/redirects | This Admin section. |
| Public admin login | /admin/login | Anonymous | Inertia login page / session mutation | This page. |
/admin redirects to /admin/login. After login, page visits and mutations use the web session. The React dashboard does not bridge a Bearer token into useForm; it submits to /admin/* web routes.
Shared Inertia props
Every admin Inertia render receives:
| Prop | Meaning |
|---|---|
errors | Flashed validation errors from the previous redirect. |
flash | Success/error toasts and temporary admin-password reveal payloads. |
user | Minimal admin user: id, fullName, email, roles, isSuperAdmin. |
locale / direction | en/ar and ltr/rtl. |
t | Flat admin translation dictionary for the active locale. |
navCounts | Role-scoped sidebar counts: reports, support, or null when the operator's roles cannot see that queue. |
Role names come from active memberships on the authenticated user. The admin shell filters navigation using those roles before the user sees a link, but backend abilities still enforce every action.
JSON API coverage
The generated API reference includes admin JSON for:
| Domain | Examples |
|---|---|
| Dashboard and metrics | /api/v1/admin/dashboard/snapshot, metrics, user growth, order volume, revenue, queue stats. |
| Users and operators | /api/v1/admin/users, user detail/activity, suspend/anonymize/restore, clear OTP, /api/v1/admin/admins. |
| Content and ops | countries, cities, categories, FAQs, legal documents, about content, announcements, settings, activity log, security events. |
| Moderation | reports, reviews, food trucks, menu moderation, jobs, marketplace listings and ads. |
| Commerce | pricing, payment orders, invoices, refunds, cancellations, financial reports, orders. |
| Support | support tickets, ticket detail, replies, status updates. |
The /admin/* HTML routes are excluded from OpenAPI by app/lib/openapi/bootstrap.ts; use Pages & actions for those.
Countries and cities have dedicated CRUD pages at /admin/countries and /admin/cities, with matching JSON CRUD at /api/v1/admin/countries and /api/v1/admin/cities. Super admins, admins and content managers can edit bilingual names, activation, and display order. Cities can be filtered by countryCode; their value is the canonical registration and community-room identifier. Deactivating a country hides all its cities from the public catalog. Catalog edits immediately affect /api/v1/locations/*; rooms derive from active catalog entries. Renaming a country code or city value preserves existing profile and post references.
Admin-only helpers
The SPA also has cookie-authenticated helper routes:
| Route | Purpose |
|---|---|
GET /admin/lookups/trucks | Async-select truck search for admin forms. |
GET /admin/lookups/users | Async-select user search for admin forms. |
POST /admin/uploads | Admin file upload mirror used by dashboard forms. |
These helpers are not normal mobile APIs. They exist for the React dashboard.