Moveet: Building a City-Agnostic Fleet Simulator with Real Road Networks and Live Traffic
Source: Dev.to
Overview
Moveet is an open‑source, real‑time vehicle fleet simulator built in TypeScript. It runs vehicles on actual road networks with A* pathfinding, realistic traffic modeling, and a custom D3‑based map renderer — no Leaflet, no Mapbox, no tile provider.
The latest release makes the simulator fully city‑agnostic. Point it at any city, and it builds a routable graph from OpenStreetMap data, complete with congestion modeling, geofencing, and a live traffic overlay.
From OSM Data to a Routable Graph
A CLI pipeline (apps/network) handles the full OpenStreetMap ingestion:
npm run dev -- prepare nairobi
- Downloads a country PBF from Geofabrik.
- Clips a bounding box with osmium (via Docker).
- Filters to drivable road classes, exports GeoJSON, and validates the topology.
- Caches the result after the first run.
A regions.json manifest covers major cities globally — switching cities is a one‑argument change.
The builder prunes disconnected components, parses OSM tags like lane counts, surface quality, roundabouts, access restrictions, and traffic signals, and handles edge cases such as reversed one‑ways and near‑duplicate nodes.
Traffic Realism
The A* engine applies a BPR (Bureau of Public Roads) congestion function when computing route costs. Road capacity is derived from OSM lane data. As vehicles accumulate on a segment, the routing cost grows and traffic naturally shifts to alternative corridors — the same principle used in professional traffic assignment models.
Additional realism layers include:
- Surface quality speed factors
- Traffic signal intersection delays
- Incident‑aware route cache keyed by active incident state
A simulation clock drives time‑varying demand (rush hour amplification, night reduction), and the server broadcasts per‑edge congestion snapshots at regular intervals. The UI renders them with a Google‑Maps‑style color ramp (green through red), coloring only roads that carry actual traffic.
Routing Quality
The A* router now:
- Handles OSM turn restrictions
- Enforces forward‑only roundabout traversal with speed reduction
- Filters out private and restricted‑access roads
- Computes an admissible heuristic from the network’s actual speed range rather than a hard‑coded constant
Geofencing
Draw polygons on the map, name them, assign types and colors. The server runs ray‑casting checks every tick and broadcasts enter/exit events over WebSocket. Features include full REST CRUD, an alerts panel, and per‑zone toggle.
Vehicle Types and Trails
Supported vehicle types: car, truck, motorcycle, ambulance, and bus — each with distinct speed profiles, acceleration curves, road restrictions, and special behaviors. Fleet composition is configurable at start time.
Each vehicle leaves a fading breadcrumb trail on the map, stored in a circular buffer and rendered as an opacity gradient. Trail length is adjustable.
WebSocket Subscribe Filters
Clients can filter their WebSocket feed by fleet, vehicle type, or geographic bounding box:
{
"type": "subscribe",
"filter": {
"fleetId": "fleet-1",
"vehicleType": "truck"
}
}
The system is backwards‑compatible — clients without a filter receive everything.
UI Overhaul
All interactive components were migrated to React Aria for proper accessibility. The visual layer received a glassmorphism theme with tiered depth, a custom fuzzy search with match highlighting, and tighter panel proportions.
Under the hood:
- Fleet analytics dashboard with sparkline KPIs
- Structured logging with correlation IDs
- Health endpoint
- CI‑enforced test coverage across all workspaces
Try It
git clone https://github.com/ivannovazzi/moveet.git
cd moveet && npm install && npm run dev
Dashboard available at localhost:5012. MIT licensed. GitHub repo.