Panels, Dispatch & Zones (Phase 3)
Multi-entity panels (admin, dispatcher, fleet, corporate, franchise) and geofencing. Admin UI is a Next.js app (
/admin); the rest are API-level for now, with UIs layered on as they're built.
Admin panel
/admin (Next.js, runs on :3200) — login (OTP), live dashboard (stats +
trips, auto-refresh), drivers, riders, reports, and dispatch. Requires an
account with super_admin or report.view.
Dispatcher
Operator-side dispatch (ride.assign permission):
| Action | Endpoint |
|---|---|
| Manual booking (for a rider) | POST /api/dispatcher/book |
| Candidate drivers | GET /api/dispatcher/rides/:id/candidates |
| Force-assign a driver | POST /api/dispatcher/rides/:id/assign |
| Change the driver | POST /api/dispatcher/rides/:id/change-driver |
Force-assign skips driver acceptance; change-driver frees the previous driver and reassigns before the trip starts.
Geofencing / zones
PostGIS polygon zones (settings.manage to create):
| Action | Endpoint |
|---|---|
| Create a zone (GeoJSON Polygon) | POST /api/geo/zones |
| Zones containing a point | GET /api/geo/zones/at?lat=&lng= |
| Is a point serviceable? | GET /api/geo/serviceable?lat=&lng= |
| List zones | GET /api/geo/zones |
Zone types: service (operating area), restricted (no service),
airport and surge (own multiplier + surcharge). Membership uses
ST_Covers over a GIST-indexed boundary. Serviceability = inside a
service zone AND not inside a restricted zone (if no service zones exist,
service is allowed everywhere).
Fleet / Corporate / Franchise
One organizations model, differentiated by type. The owner manages
only their own org (ownership-enforced, 403 otherwise):
| Action | Endpoint |
|---|---|
| Create org | POST /api/orgs { type: fleet|corporate|franchise } |
| List my orgs | GET /api/orgs?type= |
| Add member | POST /api/orgs/:id/members { userId, role } |
| Remove member | DELETE /api/orgs/:id/members/:userId |
| Scoped report | GET /api/orgs/:id/report |
- Fleet — members are drivers; report shows completed trips + gross earnings.
- Corporate — members are employees; report shows billable spend vs
creditLimitMinor(monthly billing). - Franchise — members are city managers/drivers; report is scoped to the org's
city.