- Docs
- Architecture
- System context
System context¶
1. Surfaces and responsibilities¶
TyteRide is a B2B bus-reservation platform. The system is composed of five surfaces:
| Surface | Path / repo | Stack | Responsibility | On this host |
|---|---|---|---|---|
| API | api/ · tyteride-api |
Laravel 11, DDD, Sanctum, Reverb, Filament | Domain, auth, tenancy, realtime, Platform Admin | yes |
| Front Views | web/front/ · tyteride-front |
Astro + React islands, Tailwind | Public landing, pricing/tiers, company onboarding | yes |
| Fleet Dashboard | web/dashboard/ · tyteride-dashboard |
React + TypeScript + Vite, Tailwind, shadcn/ui, TanStack Query, @vis.gl/react-google-maps |
Company operations: overview, enrollment, trips, extra cars, D2D, live, analysis, reviews | yes |
| Passenger App | apps/passenger/ · tyteride-passenger |
Expo React Native | Join/blocked state, trip list with cars, booking (no payment), D2D points, live tracking, reviews | pointer only |
| Driver App | apps/driver/ · tyteride-driver |
Expo React Native | Company-scoped trips and manifest, tap/QR boarding, navigation (main + secondary routes), GPS publishing, status messages, offline sync | pointer only |
Notes:
- The two mobile apps are gitlinks in the parent repo and are not fetched on this server (developed on the owner’s machine).
scripts/bootstrap.shinitializes only checked-out web/API surfaces. - Filament is used only for Platform Admin (
administratorrole). Company operations live in the Fleet Dashboard.
2. Actors¶
- Platform Admin: Manages companies, tiers, and platform-level controls (via Filament at
/admin). - Manager: Runs company operations from the Fleet Dashboard (enrollment, trips/vehicles/drivers, extra cars, D2D settings, live operations, analysis, reviews).
- Driver: Uses the Driver App for assigned/company-scoped trips, boarding actions, navigation guidance, GPS publishing, and status messages.
- Passenger: Uses the Passenger App to join/enroll via company code, view trip options, book rides (no payment), set D2D points when eligible, follow live trip progress, and submit reviews.
3. External systems¶
- SMS/OTP provider: Delivers OTP codes for phone authentication. Current host config uses
SMS_DRIVER=logwithSMS_LOG_OTP_IN_PRODUCTION=true(temporary for testing); plaintext OTP logging must be disabled after testing. - Maps (Google Maps / Directions API): Powers map rendering and routing/D2D plan calculations (via
NavigationManager/ Directions API). Maps render LTR even when UI is RTL. - OpenLiteSpeed (CyberPanel,
lshttpd): Edge web server and TLS termination for public traffic, static hosting, API proxying, and WebSocket proxying. - Reverb (WebSocket server): Realtime broadcast backend used by the API, managed as
tyteride-reverb.service. - MariaDB 10.6.22 (primary database): Primary persistent data store for the API/domain (
tyteridedatabase). - Redis (cache/queue/broadcast support): Cache, queue, and broadcast-related infrastructure at
127.0.0.1:6379; API cache/queue use Redis.
4. Hosting topology (single host, beta)¶
flowchart LR
Browser["Browser / Clients"]
subgraph OLS["OpenLiteSpeed / CyberPanel (TLS)"]
R1["tyteride.drolez-apps.cloud -> Front Views static"]
R2["/dashboard/ -> Fleet Dashboard static SPA"]
R3["api.tyteride.drolez-apps.cloud -> API (PHP 8.3 lsphp/lsapi)"]
R4["/admin -> Filament (API app)"]
R5["/app/, /apps/ -> 127.0.0.1:8080 (Reverb)"]
R6["docs.tyteride.drolez-apps.cloud -> static MkDocs"]
end
Reverb["tyteride-reverb.service"]
MariaDB["MariaDB 10.6.22 (tyteride)"]
Redis["Redis 127.0.0.1:6379"]
Browser --> R1
Browser --> R2
Browser --> R3
Browser --> R4
Browser --> R5
Browser --> R6
R3 --> MariaDB
R3 --> Redis
R5 --> Reverb
Reverb --> Redis
Additional notes:
- One host runs Front Views, Fleet Dashboard, API, Docs, Reverb, MariaDB, and Redis (beta topology). Vhosts live under
/usr/local/lsws/conf/vhosts/{domain}/vhost.conf. - SSL uses Let's Encrypt certs under
/etc/letsencrypt/live/{tyteride,api.tyteride,docs.tyteride}.drolez-apps.cloud/, terminated by OpenLiteSpeedvhssl. - Reverb runs as
tyteride-reverb.service(/usr/bin/php artisan reverb:start --host=127.0.0.1 --port=8080); public WSS iswss://api.tyteride.drolez-apps.cloud:443/app/. - No TyteRide queue worker or scheduler systemd unit/cron runs on this host; only Reverb.
- Filament remains only for Platform Admin (
/admin). Company operations are handled in the Fleet Dashboard. - API deployment details:
api/docs/operations/deployment.md. Top-level operations: Environments and secrets.
5. Identity and tenancy¶
- Auth: phone → OTP → Sanctum token. No email/password anywhere. Token scopes differ by role (Passenger, Driver, Manager, Platform Admin).
- Tenant:
company. Status istrial,active, orsuspended. A suspended company is blocked on the Fleet Dashboard and in both apps with a clear message. - Membership (
company_members): role ismanager,driver, orpassenger; status ispending,approved,rejected, orsuspended. One company per user. - Seat: an approved Passenger member counts as a seat. Managers and Drivers are free. When a tier’s maximum seats is reached, new approvals are blocked with an upgrade message.
- Tenant isolation:
company_idis applied tonav_routes,vehicles, andtrips;bookingsare scoped bytrip.company_id. A globalCompanyScopeenforces isolation. Cross-tenant reads must be impossible by default.
6. Localization¶
- API:
Accept-Languagemiddleware,lang/enandlang/ar, Arabic fields (for examplename_ar, stoplabel_ar), andusers.localereturned to clients. - Dashboard and apps:
i18next+react-i18next, persisted locale, RTL layout, and language switch in settings. - Maps: remain LTR regardless of UI language/direction.
7. Core flow anchors (for context)¶
- Company onboarding (first slice): Front Views form → public onboarding endpoint (rate-limited) → company created as
trial, Manager membership + first company code created → Platform Admin reviews in Filament queue → approval activates company → Manager signs in via phone + OTP to the Fleet Dashboard. - Booking: Passenger enters company code + gender →
pendingmembership → Manager approves → Passenger selects from trip group options (one trip per car in a group) → books with no payment → optional D2D points if eligible → backend validates detour limits. - D2D route planning: main route is base; secondary legs computed per D2D point with constraints (for example max detour minutes). Directions API is used first; custom planner only if insufficient.
- Live + boarding: Driver publishes GPS periodically during active trip; Fleet Dashboard and Passenger live views consume updates; Driver marks boarding via tap/QR (
boarded_at) with broadcast updates. - Trip analysis: on completion, analytics are stored (including
d2d_detour_minutesreported separately).