Delivered remotely for a business based in Singapore, Singapore. Names withheld by agreement.
Project Overview
In dense metropolitan corridors like Singapore—where multi-story residential estates, underground expressways, and towering commercial districts compress thousands of simultaneous deliveries into tight districts—a sluggish tracking map destroys customer confidence fast. Recipients watching a stalled courier icon call support desks repeatedly, while riders forced to run aggressive GPS polling apps watch their phones overheat and shut down mid-afternoon.
We architected a real-time delivery tracking system powered by React Native, Go, and Redis. The platform delivers adaptive, battery-conscious courier telemetry from mobile devices, smooths noisy urban coordinates on the fly, and fans out sub-second WebSocket updates to both dispatchers and end-customer tracking links.
Urban Telemetry Challenges
Building live tracking for high-density multi-drop couriers exposed four subtle engineering bottlenecks:
- Urban canyon GPS scatter: Signals bouncing off glass towers and expressway overpasses placed riders inside neighboring blocks or across water channels, causing erratic pin jumps and premature arrival alerts.
- Broadcast fan-out storms: When popular merchant windows triggered thousands of concurrent recipients opening live map links, naive database-backed polling saturated API connections immediately.
- Mobile battery exhaustion: Constant high-accuracy GPS locking combined with chatty HTTP requests drained courier handsets long before evening shifts finished.
- Out-of-order tunnel reconnects: Riders emerging from subterranean parking garages or tunnels flushed buffered coordinates out of order, making map markers briefly snap backward.
Architectural Strategy
We treated live location as an ephemeral, high-velocity stream separate from durable order transactions. The React Native courier app buffers coordinates locally in a compact ring queue and batches uploads over persistent connections via native Android foreground services and iOS significant-motion bridges.
On the backend, stateless Go services sit directly behind the load balancer. Go goroutines validate incoming batches, discard physically impossible GPS spikes, update Redis Geo indexes and hot hash state, publish coordinates to NATS and Redis Pub/Sub channels, and push delta frames down thousands of open customer WebSockets. PostgreSQL stays insulated from high-frequency coordinate writes, receiving only milestone state transitions and downsampled trip summaries asynchronously.
Core Capabilities
- Adaptive Courier Telemetry: Modulates GPS accuracy and batching frequency using accelerometer motion detection, battery state, and proximity to the active drop-off pin.
- Coordinate Smoothing & Road Snapping: Filters multipath GPS outliers and snaps active trajectories cleanly onto road segments so customer maps animate smoothly along streets.
- Proximity Geofence Triggers: Evaluates approaching-stop rings in Go against Redis Geo state to fire "courier arriving nearby" alerts without polling overhead.
- Scoped Live Customer Tracking: Serves zero-install TypeScript React tracking URLs with live marker interpolation, real-time traffic ETA recalculation, and masked rider privacy.
- Tamper-Evident Proof of Delivery: Captures offline-capable signature pads, timestamped doorstep photos, and exact drop-off coordinates inside React Native before syncing to PostgreSQL.
Technical Architecture
Courier devices emit compressed JSON/Protobuf location batches to a Go ingestion service. After sequence verification and Kalman/plausibility smoothing, Go updates the rider's active coordinate in Redis and emits a stream event onto NATS JetStream. Dedicated Go WebSocket gateway nodes subscribe only to active order channels requested by connected browsers and dispatch consoles, keeping fan-out traffic tightly bounded.
Flow: React Native Courier App (Native Background GPS) → Go Telemetry Ingestion & Smoothing → Redis Geo & Hot State + NATS JetStream → Go WebSocket Fan-Out Hub + Geofence Worker → TypeScript Customer Map & PostgreSQL Archive
Downstream workers consume NATS streams at their own pace to archive breadcrumb trails in PostgreSQL and trigger push/SMS milestone notifications, ensuring slow third-party SMS providers never backpressure live map streaming.
Technology Stack
| Category | Technology detail |
|---|---|
| Courier Mobile App | React Native client with native background location modules, proof-of-delivery capture, and offline buffer |
| Telemetry & Socket Core | Go microservices ingesting courier GPS pings, running map-matching, and fanning out WebSocket frames |
| Hot Geo & Stream Bus | Redis Geo, Hashes, and Streams tracking live rider coordinates and triggering geofence transitions |
| Internal Event Mesh | NATS JetStream decoupling telemetry ingestion from notification dispatch and analytics archiving |
| Persistent Order Store | PostgreSQL recording delivery tasks, chain-of-custody timestamps, POD signatures, and breadcrumb archives |
| Customer Tracking Web App | TypeScript React live map portal interpolating smooth courier motion and live countdown ETAs |
| Map & Routing SDK | Google Maps SDK providing road-snapped polylines, traffic-aware ETA refreshes, and geocoded pins |
| Push & SMS Alerts | Worker consumers sending milestone notifications on pickup, approaching-stop, and drop-off events |
Engineering Trade-offs & Solutions
| Engineering Challenge | Solution & Trade-off |
|---|---|
| React Native JS bridge stalls under continuous native GPS callbacks | Moved location buffering and motion-state throttling into native Swift/Kotlin modules that wake JavaScript only for batched syncs or UI updates, trading modest native code upkeep for high battery efficiency. |
| Calling commercial Directions APIs on every 5-second ping creates steep cost spikes | Recomputed full traffic-aware ETAs only when distance moved, remaining stops, or deviation thresholds exceed bounds, interpolating countdowns locally between refreshes. |
| Raw GPS pings replayed after tunnel exits cause markers to jump backward | Enforced monotonic device sequence timestamps in Go so stale buffered points archive to historical trails without overwriting newer live Redis coordinates. |
| Thousands of idle WebSocket viewers magnify broadcast CPU load | Sharded WebSocket room subscriptions per active order token in Go and sent compact coordinate/bearing deltas only when displacement exceeds a few meters. |
Privacy & Telemetry Security
Real-time location streams carry strict personal privacy requirements for both couriers and recipients. Customer tracking URLs rely on unguessable cryptographic tokens with automatic expiration shortly after delivery completion; once an order closes, the WebSocket room terminates immediately and historical rider paths become inaccessible to the recipient.
Courier mobile sessions authenticate via short-lived JWTs paired with device-bound refresh tokens. Inside the tracking portal, exact home addresses and recipient phone numbers stay masked unless explicitly authorized for support supervisors, while all telemetry transit enforces TLS 1.3 encryption.
Concurrency & Burst Resilience
Lunchtime food surges and evening e-commerce waves multiply active socket counts sharply within minutes. Because Go multiplexes each WebSocket connection onto minimal-stack goroutines managed by epoll/kqueue, individual gateway nodes sustain tens of thousands of concurrent viewers cleanly behind horizontal autoscaling.
If a WebSocket pod restarts during deployment, the TypeScript client applies jittered exponential backoff on reconnect and immediately hydrates the latest coordinate from Redis Hash state—preventing thundering-herd reconnect spikes against PostgreSQL.
Operational Outcomes
Moving live tracking onto an event-driven Go and Redis core elevated reliability across courier and consumer touchpoints:
- Smooth urban map accuracy: Road-aware outlier filtering eliminates jarring cross-building marker jumps in dense high-rise zones.
- Full-shift mobile endurance: Adaptive sensor batching inside React Native preserves courier phone battery across long multi-stop runs without sacrificing arrival precision.
- Quiet customer support queues: Reliable live tracking links and timely approaching-stop alerts give recipients clear visibility without needing "where is my order" calls.
- Isolated failure domains: Decoupling NATS archiving and SMS workers from Go streaming gateways keeps live maps fluid even during external notification slowdowns.