A delivery web app still ships its route-optimizer heuristic to every driver
Delivery and field-service web apps love to show an optimized stop list the moment a driver opens the shift. That snappy UX usually means the scoring heuristic — distance, time windows, vehicle capacity, priority flags, and the little penalties that decide who gets visited first — is running in the browser. If it runs in the browser, every driver (and every competitor) can download it. This post…
Modern delivery and field-service web apps often display an optimized stop list as soon as a driver opens their shift. This snappy user experience relies on a scoring heuristic that calculates travel time estimates, traffic multipliers, parking/delay constants, and various constraints for each stop. This heuristic, which determines route orders and priorities, is typically run in the browser, making it accessible to every driver and potential competitor.
When you open Develop Tools on a modern dispatch Progressive Web App (PWA), you'll usually find several key components in the driver bundle, including cost functions, constraint checks, time-window scoring, local search moves, and tie-breakers. These elements reflect the promises made to enterprise customers regarding Service Level Agreements (SLAs).
The specific numbers used in these functions are not theoretical; they are directly tied to the SLAs promised to enterprise clients. For instance, variables like cfg.wLate, cfg.vipBonus, and others represent the product's revenue. Searching for these variables will help you locate them within the code.
While it's true that the Vehicle Routing Problem (VRP) is NP-hard and the heuristic used is approximate, this does not mean the heuristic is worthless to competitors. A rival logistics software-as-a-service (SaaS) can copy the weights from your bundle, reverse-engineer priorities using historical stop lists, or even modify the scoring function to give their test driver an easy route during debugging. Obfuscation may make this process more difficult, but it does not ensure trustworthy decision-making.
If a shipment's final committed route, driver pay calculations, or VIP must-be-first business rules are affected, these critical components must be computed or re-validated on the server side. For the client heuristic, it's recommended to bundle the optimizer separately from the map UI and apply VM-based obfuscation to critical functions like scoreInsert and weight tables.
This makes copied code bytecode rather than readable JavaScript. Additionally, leaving pure distance lookups or using a Wasm matrix for lighter computations on low-end phones can help maintain performance.
To protect the client heuristic, bundle it separately from the map UI, apply VM-based obfuscation, and strip source maps from the public driver Progressive Web App. Include a hash of the heuristic version with each accepted route so the server can reject unknown builds. Ensure that money and SLA-related logic is computed on the server, and label client scoring as advisory in product documentation and code comments. Finally, make sure performance on mid-range Android devices is measured after implementing these protections.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to