Skip to content

Mobile Porting Plan

This document is the executable plan for porting the TyteRide Passenger App and Driver App on the owner's machine. It is a documentation/spec artifact only: it does not initialize, fetch, populate, build, or run the app submodules on this host.

1. Host constraint

Rule Detail
Pointer-only on this host apps/passenger and apps/driver are gitlinks in the parent repo and must stay unfetched on this server.
No recursive submodule init Never run git submodule update --init --recursive or git clone --recurse-submodules on this host.
Bootstrap boundary ./scripts/bootstrap.sh initializes only api, web/front, and web/dashboard; app submodule update is set to none.
Where execution happens Actual dependency install, code porting, typecheck, tests, Expo start, and EAS builds happen on the owner's machine where the app repos are available.
What this host can do Read/write docs, plan, review API contracts, and run docs verification (mkdocs build --strict).

Do not do on this host: git submodule update --init apps/passenger, git submodule update --init apps/driver, any command that fetches/populates app repos, or any app install/build/test command that requires those working trees.

2. Source specs and contracts

Read these before porting:

3. Target stack

The stack below is grounded in current specs. Items marked confirm on owner's machine are implementation choices not fully pinned in current docs; confirm against the archived app repos before changing them.

Area Target Source / note
Mobile framework Expo React Native Passenger App, Driver App, System context. Exact Expo SDK / React Native version: confirm on owner's machine from existing app package.json / app.json.
Language TypeScript Align with repo convention: TypeScript mirrors API snake_case fields exactly.
Navigation React Navigation (native stack/tabs as needed) Confirm on owner's machine from archived apps; preserve existing navigation shell unless current specs require change.
State Zustand stores for local/client state Reuse pattern from archived apps; keep server state concerns separate.
Server state TanStack Query or existing app data pattern Confirm on owner's machine. Dashboard uses TanStack Query; apps may already have a pattern—prefer the existing app pattern unless it conflicts with contract rules.
HTTP client axios client with interceptors Reuse existing client wiring; enforce Authorization: Bearer <token>, Accept-Language, base /api, error-shape handling.
Realtime laravel-echo + pusher-js against Reverb Client-service contract, Build spec. Confirm current package versions on owner's machine.
Maps Google Maps React Native SDK / Expo-compatible maps package Confirm on owner's machine from archived apps. Maps stay LTR even in Arabic/RTL UI.
Background location Expo Location / existing background task setup Driver publishes GPS every 10-15s during active trip; confirm foreground/background permissions and task registration on owner's machine.
Secure storage expo-secure-store or equivalent secure token storage Store Sanctum bearer token securely; avoid plaintext token persistence. Confirm exact package on owner's machine.
Local persistence AsyncStorage/MMKV for non-sensitive persisted state Locale, lightweight UI state, offline queue metadata as needed. Confirm exact package on owner's machine.
i18n / RTL i18next + react-i18next, persisted locale, language switch in settings Localization spec. Arabic/English everywhere; RTL layout; maps LTR.
Forms/validation React Hook Form + Zod or existing app pattern Confirm on owner's machine. Keep request payloads aligned with API contract.
Testing Jest + React Native Testing Library Testing strategy. Detox/E2E later.
Build/distribution Expo/EAS Build Confirm EAS project config on owner's machine; do not run on this host.

4. Reuse and drop rules

4.1 Keep and adapt

Keep Adapt to TyteRide
Navigation shell, screen layout, and component structure where still useful. Rename user-facing labels, routes, and identifiers to TyteRide terminology.
Zustand stores and local UI state patterns. Remove payment/wallet state; add company/membership, booking, live trip, and locale state as needed.
Axios client and auth interceptors. Point to TyteRide /api; use Sanctum bearer token; handle {message, errors?}; send Accept-Language.
Reverb/pusher/echo wiring. Authorize and subscribe to private-company.{companyId} and trip.{tripId} per contract. Re-check membership on stale tokens.
Background location/GPS publishing plumbing. Driver only, active trip only, 10-15s cadence, /driver/* endpoints.
Existing offline-sync scaffolding. Driver App retains offline sync "as today" per spec; clarify and document actual behavior before changing.
i18n setup and RTL support. Ensure Arabic/English coverage, persisted locale, settings switch, and maps LTR.

4.2 Drop or replace

Drop Replacement / rule
Wallet, Paymob, top-up, split payment, payment methods, checkout, fare collection. No passenger payment UI or flow. Passengers pay nothing. Bookings carry no charge.
Email/password, 2FA, Google auth, or any non-OTP auth. Phone + OTP only (POST /auth/otp/send, POST /auth/otp/verify).
Coordinator/consumer naming in code, routes, UI, file names, and analytics events. Driver/Passenger terminology. Use /driver/*, never /coordinator/*; use Passenger, never consumer.
Legacy endpoints that conflict with current TyteRide contract. Follow Client-service contract and current spec docs.
Any assumption that app submodules can be fetched on this host. Owner-machine only.

5. Porting sequence

Execute in order on the owner's machine. Each step should end with a green check (test/typecheck/lint/build as applicable) before moving on.

5.1 Passenger App (apps/passenger)

Step Work Archive-informed mapping (confirm on owner's machine) Exit check
P1. Bootstrap workspace Clone/init apps/passenger on owner's machine; install dependencies; confirm Expo config, EAS config, env files. package.json, app.json/app.config.*, eas.json, .env.example, tsconfig.json, babel.config.*, metro.config.*. App installs; Expo starts.
P2. Foundation cleanup Remove wallet/payment/split-payment screens, stores, API calls, and nav entries. Remove email/password/2FA/Google auth. Rename consumer -> passenger. src/screens/**/wallet*, payment*, topup*, split*; src/stores/*wallet*; src/api/*payment*; auth screens; navigation route names. No payment/auth legacy routes; typecheck passes.
P3. Auth and session Implement phone+OTP send/verify, token storage, /auth/me bootstrap, logout/expired-token handling, company enrollment context. src/api/auth.ts, src/api/client.ts, src/stores/authStore.ts, src/hooks/useAuth*, src/screens/auth/*, secure storage wrapper. OTP login works against API contract; token restored on launch.
P4. Enrollment/blocking Company code + gender enrollment, pending/approved/rejected/suspended blocked states, clear company-suspended message. src/screens/enrollment/* or join/company screens; membership store/selectors; guarded navigation. Blocked state shows no trips until approved; suspended company blocked.
P5. Trips and booking Trip groups by route/departure, seats left per car, car selection, booking without payment, reservation deadline handling. src/screens/trips/*, src/screens/bookings/*, src/stores/tripStore.ts, src/api/trips.ts, src/api/bookings.ts. Booking creates reservation with no payment step; deadline errors handled.
P6. D2D Eligibility checks, pickup/drop-off map selection, detour rejection feedback, booking payload with pickup_type, d2d_pickup, d2d_dropoff. src/screens/booking/D2D*, map components, location picker, booking API payload builders. Eligible users can set D2D points; ineligible users see no D2D flow.
P7. Live tracking Trip live view with vehicle position, route, ETA to pickup point; Reverb trip.{tripId} subscription. src/screens/live/*, src/hooks/useTripChannel.ts, src/api/live.ts, map overlays. Live updates render; stale token/channel auth failure handled.
P8. Reviews/notifications Post-trip 1-5 rating/comment, notifications including extra-car assignment. src/screens/reviews/*, src/screens/notifications/*, src/api/reviews.ts, notification handlers. Review submit/list works; notification deep links confirmed.
P9. i18n/RTL/polish Arabic/English strings, RTL layout, persisted locale, settings switch, maps LTR. src/i18n/*, locales/en*.json, locales/ar*.json, settings screen, RTL bootstrap. Arabic RTL and English LTR render correctly; maps remain LTR.
P10. Tests and release checks Unit/component/contract tests, manual device checks, EAS build profiles. __tests__/**, jest.config.*, eas.json, CI workflow in app repo. Tests/typecheck pass; EAS build succeeds on owner's machine.

5.2 Driver App (apps/driver)

Step Work Archive-informed mapping (confirm on owner's machine) Exit check
D1. Bootstrap workspace Clone/init apps/driver on owner's machine; install dependencies; confirm Expo/EAS/env config. package.json, app.json/app.config.*, eas.json, .env.example, tsconfig.json. App installs; Expo starts.
D2. Foundation cleanup Rename coordinator -> driver everywhere. Remove legacy/non-OTP auth. Ensure route prefix is /driver/*. src/api/*coordinator*, src/screens/*coordinator*, navigation labels, store names, analytics/event names. No coordinator naming in UI/API paths; typecheck passes.
D3. Auth and session Phone+OTP login, secure token storage, /auth/me bootstrap, driver role/company context. src/api/auth.ts, src/api/client.ts, src/stores/authStore.ts, src/screens/auth/*. Driver can authenticate and restore session.
D4. Trips and manifest Company-scoped assigned trips, manifest view, Passenger privacy-aware fields. src/screens/trips/*, src/screens/manifest/*, src/api/driverTrips.ts. Only assigned company trips visible; manifest loads.
D5. Boarding Tap/QR boarding, boarded_at update, broadcast-aware UI refresh. src/screens/manifest/*, QR scanner component, src/api/boarding.ts. Boarding action updates manifest and handles errors.
D6. Route plan and navigation Main route + D2D secondary legs from GET /driver/trips/{id}/route-plan; labels and detour minutes; driver chooses when to take D2D leg. src/screens/navigation/*, src/components/map/*, src/api/routePlan.ts. Route plan renders main and secondary legs; maps LTR.
D7. GPS and status feedback Background/foreground location permission flow; publish GPS every 10-15s during active trip; quick status feedback. src/hooks/useLocationTracking.ts, background task registration, src/api/tracking.ts, src/api/feedback.ts. GPS publishes on cadence; feedback endpoint accepts quick status.
D8. Realtime and extra cars Company/trip realtime updates; extra car appears as normal trip; driver status feed updates. src/hooks/useCompanyChannel.ts, src/hooks/useTripChannel.ts, notifications/store updates. Realtime events refresh UI; extra car visible in trip list.
D9. Offline sync Preserve "offline sync as today"; document current behavior, queue scope, conflict handling, and limitations. src/offline/*, sync queue/storage, network status hooks. Offline actions queue and replay per documented behavior; no silent data loss.
D10. i18n/RTL/tests/release Arabic/English, RTL, persisted locale, settings switch, maps LTR; tests and EAS build. src/i18n/*, locales, settings, tests, eas.json. Tests/typecheck pass; Arabic RTL OK; EAS build succeeds on owner's machine.

6. Auth and session contract

Both apps use the same auth baseline:

Concern Rule
Auth method Phone + OTP only. No email/password, no social auth.
Endpoints POST /auth/otp/send, POST /auth/otp/verify; rate-limited public endpoints.
Token Sanctum bearer token in Authorization: Bearer <token>.
Session bootstrap On app launch/resume, call /auth/me (or equivalent current user endpoint defined by API slice) to restore user, role, locale, and membership/company context. Confirm exact endpoint/path on owner's machine against implemented API.
Storage Store token in secure storage; persist non-sensitive locale/settings separately. Clear token on logout, revoked token, or invalid session.
Company context company_id is never sent from client as authority; server derives it from membership. Passenger enrollment uses company code flow; Driver is company-assigned.
Error handling Handle 401 by clearing session and returning to auth; handle 403 suspended-company state with clear message; preserve {message, errors?}.
Localization Send Accept-Language: en|ar; persist users.locale when returned.

7. Domain flows

7.1 Passenger App

Flow Contract
Enrollment Enter company code + gender; create pending membership. Pending/rejected/suspended states block trip access.
Trip discovery List trip groups: same route and departure time, one trip per car, linked by trip_group_code; show seats left.
Booking Pick a car and book. No payment step. Respect reservation_deadline_at when set.
D2D If companies.d2d_enabled and company_members.d2d_enabled, allow pickup/drop-off map points. Backend rejects detour above d2d_max_detour_minutes.
Live tracking Show vehicle position, route, and ETA to Passenger pickup point over trip realtime channel.
Reviews After completed trip, submit rating 1-5 with optional comment.
Notifications Receive notifications, including extra-car assignment; exact catalog/deep links remain to be confirmed.

7.2 Driver App

Flow Contract
Driver access Driver account created by Manager (name/phone). Driver logs in with phone+OTP. Sees only company-assigned trips.
Manifest View trip manifest before/during trip; fields/privacy constraints to be confirmed by API slice.
Boarding Tap or scan QR to mark Passenger boarded (boarded_at); broadcast update to live consumers.
Navigation GET /driver/trips/{id}/route-plan returns main route and D2D secondary legs with labels/detour minutes. Driver decides when to take a D2D leg.
GPS publishing Publish GPS every 10-15 seconds during active trip.
Status feedback Send quick status via POST /driver/trips/{id}/feedback (delay, incident, Passenger absent; canonical enum TBD).
Extra cars Extra-car requests created by Manager appear as normal trips.
Offline sync Preserve current offline sync behavior; document scope/conflicts before changing.

8. i18n, RTL, and maps

  • Arabic and English everywhere. Default en unless persisted/user locale is known.
  • Use i18next + react-i18next; persist locale locally; provide language switch in settings.
  • Arabic uses RTL layout; English uses LTR layout.
  • Maps stay LTR in all locales.
  • Handle mixed bidi content safely: phone numbers, codes, IDs, route codes, coordinates.
  • User-facing strings must not use "coordinator" or "consumer".
  • Validation/API message values should be displayed as localized server messages; client-owned labels need en and ar coverage before release.

9. Testing and verification

9.1 Automated tests (owner's machine)

Layer Required coverage
Unit/store tests Zustand stores, selectors, payload builders, date/deadline helpers, eligibility rules.
Component tests Jest + React Native Testing Library for auth screens, blocked states, trip list/booking, D2D picker guards, manifest/boarding, feedback forms.
Contract tests Mock/fixture tests against documented API request/response shapes; assert snake_case fields and {message, errors?} error handling.
Realtime tests Channel auth/subscription handlers for company and trip channels; stale-token/reconnect behavior.
i18n/RTL tests Locale switch, persisted locale, RTL layout smoke checks, map container remains LTR.

9.2 Manual device checks (owner's machine)

  • Phone+OTP login, logout, token restore, expired token.
  • Pending/rejected/suspended/approved enrollment states.
  • Booking with no payment step; reservation deadline rejection.
  • D2D eligible/ineligible behavior; detour rejection message.
  • Live trip map updates, route, ETA, reconnect.
  • Driver GPS cadence in active trip; background/foreground behavior per platform permissions.
  • Boarding tap/QR flow and feedback messages.
  • Arabic RTL screens and English LTR screens; maps LTR in both.
  • Offline sync queue/replay for Driver App.

10. Verification commands (owner's machine)

Run these in the app repo on the owner's machine. Exact script names may differ; confirm in package.json before running.

# Passenger App
cd apps/passenger
cp .env.example .env   # fill local values; never commit secrets
npm install            # or yarn/pnpm, per repo lockfile
npm run typecheck      # or tsc --noEmit
npm run lint
npm test
npx expo start
# EAS (after eas-cli auth/config):
npx eas build --profile development --platform android
npx eas build --profile development --platform ios
# Driver App
cd apps/driver
cp .env.example .env   # fill local values; never commit secrets
npm install            # or yarn/pnpm, per repo lockfile
npm run typecheck      # or tsc --noEmit
npm run lint
npm test
npx expo start
# EAS (after eas-cli auth/config):
npx eas build --profile development --platform android
npx eas build --profile development --platform ios

Do not do on this host: do not run the commands above in /home/TyteRide unless the app submodules are present and explicitly authorized by the owner. They are pointer-only here.

11. Execution checklist

  • Confirm owner machine has access to tyteride-passenger and tyteride-driver repos.
  • Initialize/fetch app submodules only on owner's machine.
  • Read all source specs in §2 before changing code.
  • Capture baseline app state: Expo SDK, RN version, navigation, state, storage, map, location, notification packages.
  • Remove payment/wallet/top-up/split-payment flows from Passenger App.
  • Remove email/password/2FA/Google auth from both apps.
  • Rename coordinator/consumer naming to Driver/Passenger across code, routes, UI, tests, and assets.
  • Implement phone+OTP auth, secure token storage, and /auth/me bootstrap.
  • Implement Passenger enrollment/blocked states and company suspension handling.
  • Implement Passenger trip groups, booking without payment, deadline handling.
  • Implement Passenger D2D eligibility, map selection, and detour error handling.
  • Implement Passenger live tracking and reviews.
  • Implement Driver manifest, boarding tap/QR, route plan, GPS publishing, status feedback.
  • Implement Driver realtime handling and extra-car-as-normal-trip behavior.
  • Preserve/document Driver offline sync behavior.
  • Complete Arabic/English i18n, RTL layout, persisted locale, settings switch; keep maps LTR.
  • Add/update Jest + RN Testing Library tests and API contract fixtures.
  • Run typecheck, lint, tests, Expo start, and EAS development builds on owner's machine.
  • Update docs/specs if implementation reveals contract gaps (endpoint fields, QR payload, feedback enum, offline sync contract).

12. Open questions / confirm before implementation

  • Archived app structure: Actual file tree, package manager, Expo SDK, and module names must be confirmed on the owner's machine; this host cannot inspect app contents.
  • /auth/me endpoint: Contract uses /auth/* and bearer tokens; exact current-user bootstrap endpoint name/payload must be confirmed against implemented API.
  • Server state library: Dashboard uses TanStack Query; apps may use Zustand+axios only or another pattern. Confirm before introducing a second pattern.
  • Manifest fields and Passenger privacy: Exact manifest payload and visible Passenger fields are not fully specified.
  • QR payload format: Boarding QR encoding/validation rules are not specified.
  • Driver feedback taxonomy: Quick status examples exist (delay, incident, Passenger absent), but canonical enum/list is open.
  • Offline sync contract: "Offline sync as today" is specified but not documented in detail; preserve behavior and document before refactor.
  • Notification catalog/deep links: Exact notification types and deep-link routes are not fully specified.
  • Push notifications: Token registration, provider, and localization workflow are not fully specified.
  • Idempotency keys: Booking/car-request duplicate-tap protection key format is source-silent; confirm before client implementation.