Mobility & Real-Time Systems8 min read•March 28, 2026•Akubrecah

Engineering SwiftBoda: Real-Time Motorcycle Dispatch, Geospatial Telemetry & M-Pesa Splitting in Nairobi

How we architected a triple-persona real-time mobility platform for East Africa's motorcycle transport sector using React Native, WebSocket telemetry, 4-digit safety PIN handshakes, and automated Safaricom Daraja STK Push fee splits.

Engineering SwiftBoda: Real-Time Motorcycle Dispatch, Geospatial Telemetry & M-Pesa Splitting in Nairobi

Engineering SwiftBoda: Real-Time Mobility Dispatch & Telemetry Across Kenya

The two-wheeler motorcycle ("boda boda") economy powers millions of daily transit journeys and micro-deliveries across East Africa. Yet most ride-hailing platforms struggle with high mobile latency, GPS jitter in urban corridors, and driver cash friction.

In building SwiftBoda, we engineered a mission-critical, full-stack mobility ecosystem designed specifically for the low-bandwidth, high-frequency transport environment of Kenyan cities.


🏗️ System Architecture & State Machine

The core challenge of hyper-local dispatch is maintaining deterministic state across unreliable cellular networks. When a rider requests a pickup in congested areas like Nairobi CBD or Eastleigh, a split-second network dropout must not orphan the dispatch transaction.

[Rider App]               [Node.js WebSocket Gateway]             [Driver App]
     │                                 │                                │
     ├─── 1. POST /api/rides/quote ────>│                                │
     │    (Origin, Dest, Serply Maps)  │                                │
     │<── 2. Fare & Route Geometry ────┤                                │
     │                                 │                                │
     ├─── 3. WS: REQUEST_RIDE ─────────>│                                │
     │                                 ├─── 4. WS: DRIVER_DISPATCH ─────>│
     │                                 │    (Geospatial Radius 2.5km)   │
     │                                 │<── 5. WS: ACCEPT_RIDE ─────────┤
     │<── 6. WS: RIDE_MATCHED ─────────┤                                │
     │    (Driver Coords & 4-Digit PIN)│                                │

🔐 Cryptographic 4-Digit Safety PIN Handshake

In traditional motorcycle operations, passenger misidentification is a persistent hazard. SwiftBoda eliminates passenger fraud through an enforced cryptographic PIN verification:

  1. PIN Generation: When a dispatch request is accepted by a driver partner, the backend gateway generates a pseudo-random 4-digit PIN tied to the rider's session token.
  2. Offline Resilience: The PIN is cached in local SQLite on both devices.
  3. Trip Ignition: The driver app cannot trigger the START_TRIP state machine transition until the passenger verbally delivers the PIN and the driver inputs it into their terminal.
  4. Audit Trail: Every PIN handshake is logged with hardware GPS coordinates, timestamp, and battery telemetry.

💰 Automated M-Pesa Ledger & Fee Splitting

Cash collection creates safety vulnerabilities for motorcycle riders at night. SwiftBoda routes fares through an automated Safaricom Daraja STK Push workflow:

Stakeholder Percentage Allocation Purpose Settlement Timing
Driver Partner 85.0% Fuel, maintenance & driver earnings Instant B2C Payout
Platform Ledger 15.0% Infrastructure, SMS OTPs & Serply Maps Platform Float
// Automated Split Calculation
export function calculateRideLedger(grossFareKsh: number) {
  const platformFee = Math.round(grossFareKsh * 0.15);
  const driverPayout = grossFareKsh - platformFee;

  return {
    grossFare: grossFareKsh,
    platformFee,
    driverPayout,
    currency: 'KES',
  };
}

📱 Triple-Persona Architecture in a Single Binary

Rather than forcing operators to maintain three separate codebases in Google Play and iOS App Store, SwiftBoda incorporates a Unified Persona Switcher:

  • Passenger Mode: Rapid 2-tap pickup, fare transparency, and live driver tracking.
  • Driver Partner Mode: High-contrast daylight HUD, audio chimes for new dispatches, and daily net revenue analytics.
  • Fleet Admin Desk: Real-time fleet heatmaps, SOS alerts, and driver document verification.

🚀 Key Takeaways & Production Metrics

  • Sub-500ms location broadcasting latency achieved using lightweight binary WebSocket payloads.
  • Zero dropped rides during sudden cellular reconnects using idempotent client transaction IDs.
  • 100% automated M-Pesa reconciliation with dual webhook and polling fallback checks.
#React Native#WebSockets#M-Pesa#TypeScript#Node.js#Geospatial
Back to All Articles
A

Akubrecah Software Architecture

Full-stack software engineering & systems architecture studio specializing in high-load web platforms, real-time mobility dispatch, and statutory compliance automation across Kenya.

Work With Us