Skip to content

Invariants & Naming

This page captures rules that must always hold and the naming conventions that keep code, APIs, UI, and docs consistent.

1. Invariants

  1. One company per user. A user belongs to a single company context/membership; do not model or implement multi-company user access.
  2. Seat = approved Passenger membership. A seat exists only for an approved Passenger membership. Pending, rejected, or suspended passenger memberships do not count as active seats.
  3. Tier max users blocks approvals. Approving a Passenger beyond the tier's max_users must be rejected with an upgrade message. Managers and Drivers are free and do not consume passenger seats.
  4. Suspended company blocked everywhere. A suspended company is blocked on every surface, including Front Views onboarding-adjacent flows where applicable, Fleet Dashboard, Passenger App, and Driver App, with a clear message.
  5. No Passenger payment path. Bookings carry no charge. Do not add payment, wallet, top-up, split-payment, or payment-method UI/flows for Passengers.
  6. Reservation deadline is optional and enforced when present. A booking after reservation_deadline_at is rejected. If the deadline is null, the deadline check does not apply.
  7. D2D detour limit enforced. A D2D point whose detour exceeds d2d_max_detour_minutes is rejected.
  8. Driver visibility is company- and assignment-scoped. A Driver sees only trips for their company and assignment.
  9. Passenger visibility is self- and company-scoped. A Passenger sees only their own bookings and company trips they are permitted to view.
  10. Gender required at enrollment. Gender is required at enrollment and stored once on users.
  11. Company scope is mandatory for tenant data. Company-owned records must be isolated by company; cross-tenant reads/writes must be impossible by default.
  12. D2D eligibility requires company enablement and an approved Booking. D2D is available only when the Company's d2d_settings.enabled and per_trip_enabled are true, the pickup/drop-off rules allow the requested points, and the Passenger holds an approved Booking on a scheduled, future Trip. Per-member D2D toggles remain future work.
  13. No Trip overbooking. Only approved Bookings occupy Trip seats; approval serializes on the Trip row and fails when approved count reaches seat_capacity.
  14. One active Booking per Passenger per Trip. Active means pending or approved; a new request is allowed only after rejection/cancellation.
  15. Trip lifecycle is Driver-only. Only the assigned active Driver may start (scheduled → in_transit) or complete (in_transit → completed) a Trip. Managers may cancel scheduled/in-transit Trips.
  16. Booking approval is Manager-only. Only a Manager of the Trip's Company may approve/reject a pending Booking; only an active Passenger Membership may hold an approved Booking.
  17. Reservation deadline is inclusive. Requests and approvals at the deadline are allowed; requests/approvals after it are rejected. No Manager override exists in Slice 4.
  18. Bookings carry no price or charge. Do not add Passenger payment, wallet, top-up, split-payment, or price fields to Trips/Bookings.
  19. D2D points are valid and inside the service zone. Pickup and drop-off each require an address and valid coordinate pair; when the Company configures a service zone centre and radius, every point must fall within that radius.
  20. One active D2D request per Booking. At most one pending or approved D2D request exists per Booking; a new request is allowed only after rejection/cancellation.
  21. D2D approval is Manager-only and company-scoped. Only a Manager of the request's Company may approve/reject a pending D2D request; cross-tenant requests return 404.
  22. D2D does not change seat or Tier accounting. A D2D request neither creates a subscription Seat nor occupies a Trip seat; the approved Booking already holds its seat.
  23. D2D resources leak no PII. Driver D2D views expose only pickup/drop-off points and status; no Passenger identity, phone, email, licence, documents, or other-Passenger data.

API status vocabulary (Slice 3): Company status is pending | active | suspended. Membership status is pending | active | rejected | suspended; enrollment endpoints expose pending | approved | rejected where approved maps to membership active. A pending Company/Membership is created by onboarding/enrollment and becomes usable only after the relevant approval flow.

2. Naming rules

2.1 Domain terminology

Use Do not use Notes
Driver coordinator Route prefix /driver/*; role value driver; app path apps/driver.
Passenger consumer Role value passenger; app path apps/passenger.
Manager admin (company operator) Fleet operator in Fleet Dashboard.
Company tenant (in UI/docs unless technical) Primary business term for the subscribing business.
Fleet Dashboard dashboard (ambiguous) Company-facing operations web app.
Front Views website/landing app (ambiguous) Public landing, pricing, and onboarding surface.
Platform Admin admin panel (ambiguous) Platform owner area in Filament, administrator role only.

2.2 API and field naming

  • JSON uses snake_case. API request/response fields should use snake_case.
  • TypeScript mirrors the API exactly. Client types should match API field names and shapes; do not rename wire fields into camelCase in API contracts.
  • Arabic fields use _ar suffix. Examples: name_ar, label_ar.
  • Use explicit route prefixes. Driver-facing routes use /driver/*; do not introduce /coordinator/*.
  • Error shape is stable. API errors use { "message": string, "errors"?: Record<string, string[]> }.

2.3 Localization and UI naming

  • Arabic and English everywhere. User-facing surfaces support Arabic and English.
  • RTL in UI; maps stay LTR. Layout direction follows locale, but map rendering remains LTR.
  • Do not guess domain terms. If a term is unclear, add it to the glossary before using it.