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).
Regions: rules for a state or a city
Most ride-hailing rules are set by a state or a city, not by the country: India's states adopt the 2025 aggregator guidelines with their own surge caps, Brazil's cities license drivers, and US cities set driver pay. Draw the state or city as a zone of type Region (state or city) and fill in only the rules that differ there. A blank field keeps the country's rule (Markets → country → Pricing).
| Field | What it does |
|---|---|
| Region code | The authority's short code (KA, SP, NYC), shown in the zone list |
| Lowest / highest surge (×) | Surge band for pickups in the region |
| Highest commission (%) | Cap on the platform's commission for trips that start here |
| Driver's minimum share (%) | The driver's guaranteed share; commission is capped at the rest |
| Riders offering their own fare | Allowed here, not allowed here, or as in the country |
| Lowest / highest offer (× estimate) | Band a rider's offer and a driver's counter must stay inside |
| Operator licence | Licensing authority, licence number and expiry for this region |
| Ride types not offered here | Switch a ride type off for pickups in the region, with a reason riders see and an optional start date |
Every region covering the pickup applies, largest first, so a city's rule wins over its state's and both win over the country's. Rules are checked when they are saved: a misspelt or impossible value is refused, not silently ignored.
Where it applies: the surge clamp on every fare quote, "raise your fare", the
commission taken at settlement, and every rider offer and driver counter. The
rider app asks GET /api/pricing/rules-at?lat=&lng= for the pickup, shows
"Offer your fare" only where offers are allowed, and stops the offer stepper at
the band.
Switching a ride type off (a state's bike-taxi ban, a court order against
moto rides): the type disappears from the rider's fare list with the reason
("Bike isn't available here: State ban on bike taxis"), a booking for it is
refused with service_unavailable_here, and rides already under way finish. An
order dated in the future takes effect at midnight on that date, market time.
Unlike pricing, switches add up: a city cannot lift its state's ban by leaving
the type on. Every change is in the audit log (zone.update, with the rules
before and after).
India ships with an offer band of 0.5×–2× of the estimate (Motor Vehicle Aggregator Guidelines 2025). Confirm every number with your regulator: they are yours to keep current.
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.