Back to projects
iOS & Android API

Ride-Hailing Rider App — Mobile API

Fare Estimates, Ride Booking, Driver Matching & Live Trip Tracking

Node.jsExpressMySQLRedisSocket.IOJWTFCM
Platforms
iOS + Android
Auth
JWTaccess + refresh
Real-time
Socket.IO
Matching
Nearest driver
iOS & Android · REST APIUI concept
Ride-Hailing Rider App — Mobile API — screenshot

Rider-side API for a ride-hailing service. Riders set pickup and drop-off, compare fare estimates for each vehicle type, request a ride, watch the assigned driver approach in real time, and pay at the end of the trip. Trip history and receipts are available in the app.

Architecture & System Design

A Node.js and Express API with JWT authentication. Ride requests are matched to nearby online drivers using driver locations cached in Redis. Once a driver accepts, trip events and driver positions are pushed to the rider through a Socket.IO room for that trip, with push notifications as a fallback when the app is in the background.

Request Flow
Rider App
Fare Estimate
Ride Request
Driver Matching (Redis)
Driver Accepts
Live Tracking (Socket.IO)
Trip Complete & Payment
  • Fare estimates calculated server-side from distance, time and vehicle type
  • Driver positions held in Redis geo sets for fast nearest-driver lookups
  • One Socket.IO room per trip, joined only after JWT verification, so riders only see their own trip
  • Explicit trip state machine: requested → accepted → arrived → in progress → completed

Engineering Challenges

Finding Nearby Drivers Quickly

Problem

Querying the main database for every online driver's latest position on each request would not scale with frequent location updates.

Solution

Kept live driver locations in Redis geo sets updated by the driver app, and queried them by radius to build a shortlist before touching MySQL.

Result

Matching reads from memory, and the database only stores trips, not every location ping.

Consistent Trip State

Problem

Riders and drivers can tap buttons at the same time (e.g. cancel vs. accept), leading to conflicting trip states.

Solution

Implemented a trip state machine with allowed transitions enforced in one service, using conditional SQL updates so only one transition can win.

Result

Every trip follows a valid path and both apps always show the same status.

Core Features

Fare Estimates

Upfront prices per vehicle type before the rider confirms.

Clean Code

driverLocator.js
1// Nearest available drivers of a vehicle type, closest first
2"color:#c792ea">export "color:#c792ea">async "color:#c792ea">function nearestDrivers(redis, db, { lat, lng, type, limit = 5 }) {
3 "color:#c792ea">const ids = "color:#c792ea">await redis.geosearch(
4 `drivers:online:${type}`,
5 "FROMLONLAT", lng, lat,
6 "BYRADIUS", 5, "km",
7 "ASC", "COUNT", limit
8 );
9 "color:#c792ea">if (ids.length === 0) "color:#c792ea">return [];
10
11 "color:#c792ea">const [rows] = "color:#c792ea">await db.query(
12 "SELECT * FROM drivers WHERE id IN (?) AND status = 'available'",
13 [ids]
14 );
15
16 "color:#c792ea">return rows.sort((a, b) => ids.indexOf(String(a.id)) - ids.indexOf(String(b.id)));
17}

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.