Overview
The trip lifecycle in Rodando Backend follows a well-defined state machine, ensuring data consistency and proper event tracking throughout the journey.Trip States
State Definitions
PENDING
PENDING
Initial state when a passenger creates a trip request.Characteristics:
- Fare estimate calculated
- Pickup and destination stored
- No driver assigned
- Waiting for assignment to begin
ASSIGNING
ASSIGNING
System is actively searching for and offering trip to available drivers.Characteristics:
- Sequential driver offers with TTL
- Real-time matching algorithm running
- Trip can timeout to NO_DRIVERS_FOUND
ACCEPTED
ACCEPTED
Driver has accepted the trip assignment.Characteristics:
- Driver and vehicle assigned
- Waiting for driver to start navigation
- Driver can cancel (with penalties)
ARRIVING
ARRIVING
Driver is en route to pickup location.Characteristics:
- ETA tracking active
- Real-time location updates
- Passenger can see driver approaching
IN_PROGRESS
IN_PROGRESS
Trip is actively in progress (passenger on board).Characteristics:
- Route tracking active
- Distance/time accumulating
- Final fare being calculated
COMPLETED
COMPLETED
Trip successfully finished.Characteristics:
- Final fare calculated
- Payment processed
- Driver availability restored
CANCELLED
CANCELLED
Trip cancelled by passenger or system.
NO_DRIVERS_FOUND
NO_DRIVERS_FOUND
No drivers available or accepted within timeout period.
Phase 1: Trip Request
Creating a Trip
The system supports idempotency keys to prevent duplicate trip creation from network retries.
Fare Estimation
Before creating a trip, clients can request a fare estimate:src/modules/trip/services/trip.service.ts:359-377
Phase 2: Driver Assignment
Start Assignment Process
src/modules/trip/services/trip.service.ts:378-517
Assignment Entity
Trip Assignment Structure
Driver Accept Assignment
src/modules/trip/services/trip.service.ts:519-627
Phase 3: Driver En Route
Start Arriving
src/modules/trip/services/trip.service.ts:881-989
Mark Arrived at Pickup
src/modules/trip/services/trip.service.ts:991-1073
Phase 4: Trip in Progress
Start Trip
src/modules/trip/services/trip.service.ts:1075-1147
Phase 5: Trip Completion
Complete Trip
src/modules/trip/services/trip.service.ts:1149-1323
Event Sourcing
Every significant trip event is stored in thetrip_events table:
Event Types
Related Resources
Driver Matching
Learn how drivers are matched to trips
Real-Time Updates
See how status updates are broadcasted
API Reference
Explore trip endpoints
