DEV Community

Ivan Annovazzi
Ivan Annovazzi

Posted on

Moveet: Building a City-Agnostic Fleet Simulator with Real Road Networks and Live Traffic

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. Here is what went into it.

From OSM Data to a Routable Graph

A CLI pipeline (apps/network) handles the full OpenStreetMap ingestion:

npm run dev -- prepare nairobi
Enter fullscreen mode Exit fullscreen mode

This 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. Cached after 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 like 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, and an 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 a regular interval. The UI renders them with a Google Maps-style color ramp (green through red), with only roads carrying actual traffic colored.

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, and computes an admissible heuristic from the network's actual speed range rather than a hardcoded 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. Full REST CRUD, an alerts panel, and per-zone toggle are included.

Vehicle Types and Trails

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 also 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" } }
Enter fullscreen mode Exit fullscreen mode

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: a fleet analytics dashboard with sparkline KPIs, structured logging with correlation IDs, a health endpoint, and CI-enforced test coverage across all workspaces.

Try It

git clone https://github.com/ivannovazzi/moveet.git
cd moveet && npm install && npm run dev
Enter fullscreen mode Exit fullscreen mode

Dashboard at localhost:5012. MIT licensed. GitHub repo.

Top comments (0)