Ride-Sharing
Overview
Ride-sharing and mobility services require robust real-time coordination between drivers, riders, and operational teams. De. provides the essential infrastructure to build flexible, scalable ride-sharing platforms with features like driver dispatch, real-time tracking, dynamic pricing, and rider notifications.
Key Capabilities
Driver Management
Register, verify, and manage drivers with comprehensive profiles:
// Register a new driver
const driver = await de.lsp.agents.create({
type: 'driver',
user: {
firstName: 'Jane',
lastName: 'Smith',
email: '[email protected]',
phone: '+12025550182'
},
verification: {
requireDocuments: true,
requiredDocuments: ['drivers_license', 'vehicle_registration', 'insurance']
},
vehicle: {
make: 'Toyota',
model: 'Prius',
year: 2023,
licensePlate: 'ABC123',
color: 'Blue'
}
})
// Set driver availability
await de.lsp.agents.setStatus({
agentId: driver.id,
status: 'available',
location: {
latitude: 37.7749,
longitude: -122.4194
}
})Ride Requests
Process ride requests and match with nearby available drivers:
// Create a ride request
const ride = await de.lsp.trips.create({
type: 'ride_request',
passenger: {
id: 'usr_123',
name: 'Alex Johnson'
},
pickup: {
address: '123 Market St, San Francisco, CA',
coordinates: {
latitude: 37.7935,
longitude: -122.3958
},
instructions: 'Front entrance'
},
dropoff: {
address: 'SFO International Airport',
coordinates: {
latitude: 37.6213,
longitude: -122.3790
}
},
serviceLevel: 'standard', // or 'premium', 'shared', etc.
scheduledTime: null // null for immediate, or ISO string for future
})
// Find nearby drivers
const nearbyDrivers = await de.lsp.agents.findNearby({
location: ride.pickup.coordinates,
radius: 5000, // meters
type: 'driver',
status: 'available',
limit: 10
})
// Dispatch to best driver
const dispatch = await de.lsp.trips.assign({
tripId: ride.id,
agentId: nearbyDrivers[0].id,
autoNotify: true
})Real-Time Tracking
Provide riders with accurate ETAs and live driver location:
// Subscribe to trip updates via WebSocket
de.realtime.subscribe(`trip.${ride.id}`, (update) => {
// Update UI with driver location and ETA
console.log('Driver location updated:', update.location)
console.log('Current ETA:', update.eta)
})
// Get current trip status
const status = await de.lsp.trips.getStatus({
tripId: ride.id,
includeLocation: true,
includeEta: true
})
// Current trip timeline
console.log('Trip timeline:', status.timeline)Dynamic Pricing
Implement surge pricing based on demand, time, and location:
// Get current pricing for a route
const pricing = await de.lsp.pricing.calculate({
origin: ride.pickup.coordinates,
destination: ride.dropoff.coordinates,
serviceLevel: ride.serviceLevel,
time: new Date().toISOString()
})
// Apply pricing rules
const finalPrice = await de.lsp.pricing.applyRules({
basePrice: pricing.basePrice,
route: pricing.route,
rules: [
{ type: 'time_multiplier', factor: 1.2 }, // Rush hour
{ type: 'demand_multiplier', factor: 1.5 }, // High demand
{ type: 'location_multiplier', factor: 1.1 } // Airport zone
]
})
console.log('Base price:', pricing.basePrice)
console.log('Final price:', finalPrice.total)
console.log('Applied multipliers:', finalPrice.appliedRules)Ride Completion
Handle ride completion, payments, and ratings:
// Complete a ride
const completion = await de.lsp.trips.complete({
tripId: ride.id,
finalLocation: {
latitude: 37.6213,
longitude: -122.3790
},
metrics: {
distance: 23.7, // kilometers
duration: 37, // minutes
waitTime: 3 // minutes
},
payment: {
amount: finalPrice.total,
method: 'card',
paymentIntentId: 'pi_123456'
}
})
// Submit ratings
await de.lsp.trips.submitRating({
tripId: ride.id,
raterType: 'passenger',
raterId: 'usr_123',
targetType: 'driver',
targetId: nearbyDrivers[0].id,
rating: 5,
comments: 'Great service, very friendly driver!'
})Integration Points
Driver App Integration
For driver-facing mobile applications:
Authentication & Identity
- Use de.auth for driver onboarding and identity verification
- Manage credentials and session tokens
Location Services
- Implement background location tracking
- Optimize for battery usage with de.sdk-rn's power management
Trip Management
- Display incoming ride requests
- Provide turn-by-turn navigation
- Handle ride status updates
Earnings & Analytics
- Track earnings and tips
- Provide performance metrics and opportunities
Passenger App Integration
For rider-facing mobile applications:
Booking Flow
- Implement location search and address selection
- Display service options and pricing
- Process payment methods
Ride Tracking
- Show live driver location on map
- Provide accurate ETA updates
- Enable driver-passenger communication
Safety Features
- Share ride details with trusted contacts
- Implement emergency assistance features
- Record ride telemetry
Operations Dashboard
For platform administrators:
Fleet Overview
- Monitor active drivers and rides
- Track key metrics and performance
Demand Management
- Visualize heat maps of demand
- Configure dynamic pricing rules
- Implement driver incentives
Customer Support
- Access ride history and details
- Resolve disputes and issues
- Process refunds and adjustments
Benefits
- Reduced Development Time - Build with pre-integrated components
- Scalable Infrastructure - Handles millions of concurrent rides
- Flexible Implementation - Customize for specific mobility models
- Enhanced User Experience - Reliable, real-time tracking and updates
- Data-Driven Decisions - Analytics for operational optimization
API Reference
For detailed API documentation including endpoints, schemas, and examples:

