Skip to content

TyteRide — B2B Build Spec (preserved from Trippp)

Provenance. This is the original Trippp B2B build spec, preserved verbatim because the old repo is being archived and removed from the host.

Superseded by the TyteRide rework: - Brand is TyteRide (not Trippp). - There are five surfaces: API, Front Views (public onboarding + pricing), Fleet Dashboard, Passenger App, Driver App. - apps/coordinator becomes apps/driver; consumer becomes passenger; route prefix /coordinator/* becomes /driver/*. - Onboarding is self-serve on Front Views with manual platform-admin approval; billing stays invoice-only, no gateway.

Everything else below governs product and domain behavior.

Preserved source notice. This file is preserved for provenance. Where it conflicts with the current TyteRide docs, the docs in 00-method, 01-domain, 02-architecture, and 03-specs win.


1. Product

Trippp is a bus reservation platform for companies. A company subscribes, its employees ride company vehicles, and a fleet manager runs everything from a dashboard.

  • The company pays by seat count (approved passengers) through a subscription tier. Passengers pay nothing. Trips are not billed.
  • Onboarding is manual: the platform owner creates companies and bills by invoice. No payment gateway.
  • Four surfaces: API, Fleet Dashboard (web), Passenger App, Driver App.
  • Core problem solved: drivers cannot easily find a passenger's door, and passengers should not walk far to reach the main route. The system gives the driver a default main route plus automatic secondary routes to each passenger's door (D2D).

2. Existing codebase

  • API: Laravel 11, DDD structure (see api/AGENTS.md). Sanctum auth, Reverb WebSockets, Filament admin, Google Directions via NavigationManager.
  • Apps (Expo React Native): apps/consumer is the Passenger App. apps/coordinator is the Driver App (keep the folder name).
  • Existing global users.role: passenger, driver/coordinator, administrator. Keep it.
  • Existing models: User, Trip, Booking, NavRoute, Vehicle, Coordinator, TripTracking, and others.
  • Run php artisan test after each backend step. Responses go through JsonResource. Error shape is { message, errors? }.

3. Core rules

  • Tenant = company. Status: trial, active, suspended. A suspended company is blocked on the dashboard and in both apps with a clear message.
  • Membership (company_members): role manager, driver, passenger; status pending, approved, rejected, suspended. One company per user.
  • Seat = an approved passenger member. Drivers and managers are free. When the tier's max seats is reached, block new approvals with an upgrade message.
  • Passengers pay nothing. Bookings carry no charge. Remove wallet, top-up, split payment, and payment-method UI from the Passenger App. Keep old price/payment columns and wallet endpoints for history only.
  • Gender is required at enrollment and stored once on users. Managers use it for bulk selection.
  • Vehicles are virtual records the fleet manager creates and manages freely. The platform owns none.
  • Driver accounts are created by the fleet manager (name and phone). Drivers log in with phone and OTP.
  • Reservation deadline is optional per trip (nullable). When set, booking is rejected after it.
  • Languages: Arabic and English everywhere, with RTL in the apps and dashboard. Maps stay LTR.

4. Data model

New tables

Table Fields
companies name_en, name_ar, slug, status, tier_id, subscription_ends_at, d2d_enabled, d2d_max_detour_minutes (default 15)
subscription_tiers code, name_en, name_ar, min_users, max_users, monthly_price
company_members company_id, user_id, role, status, approved_by, d2d_enabled
company_codes company_id, code, expires_at, max_uses, uses_count, is_active
car_requests company_id, requested_by (manager), vehicle_id, driver_id, reason, status. Passengers linked via car_request_passengers
trip_analytics trip_id (unique), overall_delay_minutes, late_departure_minutes, unexpected_stops (json), slow_segments (json), d2d_detour_minutes, computed_at
trip_reviews trip_id, user_id, rating (1-5), comment

Changed tables

  • users: add locale (default en), gender.
  • nav_routes, vehicles, trips: add company_id. Backfill existing rows into one seed company. Add a global CompanyScope.
  • nav_routes: add name_ar; stop labels get label_ar.
  • trips: add reservation_deadline_at (nullable), trip_group_code (nullable).
  • bookings: add pickup_type (route_stop | d2d), d2d_pickup and d2d_dropoff (json: lat, lng, label), boarded_at. Scope by trip.company_id.

5. Features

5.1 Companies, tiers, platform admin

  • Platform admin (Filament, administrator role only): create companies, assign tier, tier CRUD, seat usage per company, suspend and activate companies and members.
  • Company dashboard shows seats used vs tier limit.

5.2 Enrollment

  • Manager generates, rotates, and disables company codes.
  • Passenger App: enter company code and gender, then wait. A pending request creates a company_members row. Until approved (or if suspended), the app shows a blocked state and no trips.
  • Dashboard: review queue with accept and reject, bulk actions including select by gender.

5.3 Trips and cars

  • Same route and departure time can be offered by several cars: one trip row per car, linked by trip_group_code. Passenger App lists the group with each car and its seats left. The passenger picks a car and books. No payment step.
  • Duplicate trip: clone route, vehicle, and seat setup with booked_seats = 0, status = scheduled, optional new departure time or vehicle.
  • Manager manages routes, vehicles, trips, and driver accounts in the dashboard, all company-scoped.

5.4 Extra cars

  • Manager-initiated. When all cars are full or already out and a passenger missed theirs (for example after overtime), the manager picks the passengers, a free vehicle and driver from the company's own, and creates a car request.
  • Passengers get a notification with the car and ETA. The driver sees it as a normal trip.

5.5 D2D (door to door)

  • Eligibility: companies.d2d_enabled plus per-member company_members.d2d_enabled. Manager toggles individuals or bulk-selects by gender.
  • Booking: an eligible passenger sets a pickup and/or drop-off point on a map. Backend estimates the detour and rejects the point if it exceeds d2d_max_detour_minutes.
  • Route plan: the main route is the default base. For each D2D point, compute (automatically, on booking) where to leave the main route, how to reach the door, and where to rejoin. Use the Directions API with waypoints. Only write a custom snap-and-rejoin planner if Directions proves insufficient.
  • Display: main route in one color, each D2D leg as a secondary route in another color with a label (passenger, detour minutes). The driver decides when to take it. The same plan appears in the dashboard Live tab and the passenger's live view.

Route-plan response (GET /coordinator/trips/{id}/route-plan):

{ "data": {
  "legs": [
    { "kind": "main", "polyline": "...", "color": "primary" },
    { "kind": "d2d", "polyline": "...", "color": "d2d-1", "label": "Pickup: Ola", "booking_id": 401, "detour_minutes": 8 }
  ],
  "next_stop": { "label": "...", "lat": 0, "lng": 0, "eta_minutes": 12 },
  "remaining_stops": []
} }

5.6 Live tracking and real-time

  • Driver App publishes GPS every 10 to 15 seconds during an active trip.
  • Driver App sends quick status messages (delay, incident, passenger absent) via POST /coordinator/trips/{id}/feedback.
  • Dashboard Live tab: vehicle positions, route plan with secondary routes, boarded counts, driver status feed.
  • Passenger App: vehicle position now, the route it is taking, and ETA to the passenger's pickup point.

5.7 Boarding

  • Driver taps or scans a QR code on the manifest to mark a passenger boarded (boarded_at). Broadcast the update.

5.8 Trip analysis

Run an AnalyzeTrip job when a trip completes and store in trip_analytics: - overall_delay_minutes: actual vs estimated arrival. - late_departure_minutes: actual vs scheduled departure. - unexpected_stops: stationary more than about 3 minutes away from any scheduled stop. - slow_segments: stretches well below expected speed. - d2d_detour_minutes: reported separately so detours are not blamed on the driver.

Dashboard shows a per-trip view with a map overlay and a one-line reason, for example: "Departed 12m late, 2 unexpected stops (+9m), D2D detour (+6m)".

5.9 Reviews

  • Passenger App: after a completed trip, rate 1 to 5 with a comment.
  • Dashboard: list with filters by rating and trip.

5.10 Localization

  • API: Accept-Language middleware, lang/en and lang/ar, Arabic fields as listed above, users.locale returned to clients.
  • Dashboard and apps: i18next + react-i18next, persisted locale, RTL layout, language switch in settings.

6. Surfaces

Fleet Dashboard: React + TypeScript SPA on Vite, new submodule beside api and apps, Sanctum token auth against the API.

Concern Choice
UI Tailwind + shadcn/ui, Teams-like look, RTL-friendly
Data TanStack Query
Real-time laravel-echo + pusher-js against Reverb
Maps @vis.gl/react-google-maps
Tables, forms TanStack Table, React Hook Form, Zod
i18n i18next + react-i18next

Pages: Overview, Enrollment, Trips (routes, vehicles, drivers), Extra cars, D2D settings, Live, Trip analysis, Reviews. Filament stays only for the platform admin.

Passenger App (apps/consumer): join, blocked state, trip list with cars, booking (no payment), optional D2D points, live tracking, reviews, notifications, Arabic and English.

Driver App (apps/coordinator): company-scoped trips and manifest, tap or QR boarding, navigation with main and secondary routes, GPS publishing, status messages, offline sync as today, Arabic and English.

7. API

Area Endpoints
Enrollment POST /auth/enroll-company (with gender), GET /company/enrollments, approve, reject, bulk approve
Codes GET/POST/DELETE /company/codes
Trips GET/POST /company/trips, POST /company/trips/{id}/duplicate, GET /company/trips/{id}/analysis
Extra cars POST /company/car-requests, GET /company/car-requests, POST /company/car-requests/{id}/cancel
Drivers POST /company/drivers, GET /company/drivers, POST /company/drivers/{id}/suspend
D2D Booking request accepts pickup_type, d2d_pickup, d2d_dropoff. GET /coordinator/trips/{id}/route-plan
Live GET /passenger/trips/{id}/live, GET /company/trips/{id}/live
Reviews POST /trips/{id}/review, GET /company/reviews
Driver feedback POST /coordinator/trips/{id}/feedback
Platform companies list, POST /platform/companies/{id}/status, tier CRUD

8. Real-time channels (Reverb)

  • private-company.{companyId}: managers only. Events: trip status, vehicle position, passenger boarded, extra car assigned, driver feedback.
  • trip.{tripId}: feeds the passenger's live view. Add a company membership check to the existing authorization.
  • Existing notification channels stay.

9. Build order

  1. Foundation: data model, CompanyScope and seed company backfill, membership, company codes, tiers with seat limits, suspension, i18n baseline, dashboard shell.
  2. Booking: enrollment flow in both apps, trip groups and car choice, optional deadlines, duplication, driver accounts, extra cars, reviews, Passenger App cleanup (remove payments).
  3. Live: GPS cadence, company channel, dashboard Live tab, passenger live view, driver status messages.
  4. D2D: eligibility, booking points, route plan, secondary routes on all surfaces.
  5. Analysis: AnalyzeTrip job and dashboard views.