- Docs
- Domain
- Invariants and naming
Invariants & Naming¶
This page captures rules that must always hold and the naming conventions that keep code, APIs, UI, and docs consistent.
1. Invariants¶
- One company per user. A user belongs to a single company context/membership; do not model or implement multi-company user access.
- Seat = approved Passenger membership. A seat exists only for an
approvedPassenger membership. Pending, rejected, or suspended passenger memberships do not count as active seats. - Tier max users blocks approvals. Approving a Passenger beyond the tier's
max_usersmust be rejected with an upgrade message. Managers and Drivers are free and do not consume passenger seats. - 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.
- No Passenger payment path. Bookings carry no charge. Do not add payment, wallet, top-up, split-payment, or payment-method UI/flows for Passengers.
- Reservation deadline is optional and enforced when present. A booking after
reservation_deadline_atis rejected. If the deadline is null, the deadline check does not apply. - D2D detour limit enforced. A D2D point whose detour exceeds
d2d_max_detour_minutesis rejected. - Driver visibility is company- and assignment-scoped. A Driver sees only trips for their company and assignment.
- Passenger visibility is self- and company-scoped. A Passenger sees only their own bookings and company trips they are permitted to view.
- Gender required at enrollment. Gender is required at enrollment and stored once on
users. - Company scope is mandatory for tenant data. Company-owned records must be isolated by company; cross-tenant reads/writes must be impossible by default.
- D2D eligibility requires company enablement and an approved Booking. D2D is available only when the Company's
d2d_settings.enabledandper_trip_enabledare 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. - No Trip overbooking. Only approved Bookings occupy Trip seats; approval serializes on the Trip row and fails when approved count reaches
seat_capacity. - One active Booking per Passenger per Trip. Active means
pendingorapproved; a new request is allowed only after rejection/cancellation. - 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. - 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.
- 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.
- Bookings carry no price or charge. Do not add Passenger payment, wallet, top-up, split-payment, or price fields to Trips/Bookings.
- 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.
- One active D2D request per Booking. At most one
pendingorapprovedD2D request exists per Booking; a new request is allowed only after rejection/cancellation. - 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.
- 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.
- 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
_arsuffix. 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.