Back to projects
iOS & Android API

Ride-Hailing Driver App — Mobile API

Driver Availability, Trip Dispatch, Navigation Events & Earnings

Node.jsExpressMySQLRedisSocket.IOBullMQFCM
Platforms
iOS + Android
Auth
JWTaccess + refresh
Real-time
Socket.IO
Dispatch
Timed offers
iOS & Android · REST APIUI concept
Ride-Hailing Driver App — Mobile API — screenshot

Driver-side API for the same ride-hailing platform. Drivers go online, stream their location, receive trip offers with a short response window, move the trip through pickup and drop-off, and track their earnings and ratings for the day and week.

Architecture & System Design

Built with Node.js and Express. Location updates arrive over Socket.IO, are written to Redis and relayed to the rider's trip room during active trips. Trip offers are sent to one driver at a time with a timeout; if a driver declines or doesn't answer, a delayed BullMQ job offers the trip to the next nearest driver.

Request Flow
Driver App
Go Online
Location Stream (Redis)
Timed Trip Offer
Accept / Decline
Trip Lifecycle
Earnings Ledger
  • Sequential trip offers with timeouts handled by delayed BullMQ jobs
  • Location updates throttled and batched to save battery and bandwidth
  • Earnings recorded as ledger entries per trip for accurate daily and weekly summaries
  • Driver ratings and acceptance rate computed from trip history

Engineering Challenges

Offer Timeouts

Problem

A trip offer needs to move to the next driver if the first one doesn't respond within seconds, without blocking any request.

Solution

Dispatched each offer with a delayed job that re-checks the offer state when the window expires and escalates to the next candidate if it's still pending.

Result

Riders are not left waiting on unresponsive drivers, and the API stays non-blocking.

Accurate Earnings

Problem

Earnings had to reflect fares, platform commission, cancellations and adjustments in a way drivers could trust.

Solution

Recorded every money movement as an immutable ledger entry tied to a trip, and derived summaries from the ledger.

Result

Drivers see a clear breakdown, and totals can always be traced back to individual trips.

Core Features

Online / Offline

Drivers control availability; only online drivers receive offers.

Clean Code

offerWorker.js
1// BullMQ worker: offer a trip to the "color:#ffcb6b">next driver, re-check after 15s
2"color:#c792ea">const worker = "color:#c792ea">new Worker("trip-offers", "color:#c792ea">async (job) => {
3 "color:#c792ea">const trip = "color:#c792ea">await trips.findById(job.data.tripId);
4 "color:#c792ea">if (trip.status !== "requested") "color:#c792ea">return; // accepted or cancelled
5
6 "color:#c792ea">const driver = "color:#c792ea">await locator.nextCandidate(trip);
7 "color:#c792ea">if (!driver) {
8 "color:#c792ea">await trips.update(trip.id, { status: "no_drivers" });
9 "color:#c792ea">return;
10 }
11
12 "color:#c792ea">await offers.create({ tripId: trip.id, driverId: driver.id });
13 io.to(`driver:${driver.id}`).emit("trip:offer", serializeTrip(trip));
14
15 "color:#c792ea">await offerQueue.add("offer", { tripId: trip.id }, { delay: 15_000 });
16}, { connection: redis });

Want something like this for your business?

I design and build full stack products end to end. Tell me about your idea and I'll get back to you with a plan.