Inspiration

Growing up in Lagos, I constantly watched dispatch riders waste time, fuel, and money on routes that clearly made no sense. A rider leaving Ikeja for Lekki would first detour through Apapa simply because deliveries were arranged in the order requests arrived. There was no optimization layer behind the movement — just manual decisions and guesswork.

One statistic stayed with me: nearly 40% of e-commerce operational costs in Lagos come from last-mile delivery alone. When ALGOfest announced tracks around Smart Cities, FinTech, and intelligent systems, I knew I didn’t want to build another generic dashboard or AI wrapper. I wanted to solve a problem I had personally witnessed for years.

That became RouteWise.

What it does

RouteWise is a real-time multi-vehicle route optimization platform built around the realities of Lagos logistics. It computes near-optimal delivery sequences using a modified A* search algorithm combined with 2-opt local optimization — while making the optimization process itself visible and interactive.

Live Optimization Playback Click "Watch RouteWise Think" and watch nodes rearrange dynamically on a graph. Paths redraw. Metrics count down live. Efficiency scores climb from 42% to 94%. The algorithm's intelligence becomes visible in a way that no dashboard screenshot can capture.

AI Route Battle Enter your delivery stops and watch Manual Route vs RouteWise A* animate simultaneously on a split screen. The left side backtracks chaotically. The right side finds the clean path. The difference is impossible to miss in under 10 seconds.

Multi-Stop Optimizer Users can enter up to 10 Lagos delivery stops and instantly generate optimized delivery paths. The platform shows exact reductions in kilometers traveled, estimated fuel costs, and delivery time recovered. Users can also simulate disruptions such as traffic spikes, road closures, and weather delays then watch RouteWise dynamically re-calculate routes in under 2 seconds.

Live Fleet Map A real-time fleet visualization built with Leaflet.js and OpenStreetMap tracks multiple delivery bikes moving across real Lagos coordinates including Ikeja, Maryland, Surulere, Victoria Island, and Lekki. Route states, fuel usage, and delivery flow are visualized live.

Savings Calculator Businesses can estimate operational savings by adjusting rider count, work hours, and delivery schedules. RouteWise calculates projected monthly fuel and efficiency savings in real time using local delivery assumptions for a business owner with 50 bikes.

Algorithm Deep Dive A full page explaining why A* beats Dijkstra, Greedy, and Dynamic Programming with complexity comparisons, the math, and a scalability story from 6 bikes to 10,000 vehicles.

How we built it

The algorithm was built from scratch. No third-party routing library. Pure TypeScript.

Every delivery stop is scored using f(n) = g(n) + h(n), where g(n) is the actual Lagos traffic-weighted distance traveled from the start, and h(n) is the straight-line heuristic estimate to the destination. The algorithm always selects the lowest f(n) node next and guaranteeing optimal path discovery in O(n log n) time.

After A* finds the initial route, 2-opt improvement passes swap pairs of route segments looking for shorter alternatives. This is the same refinement technique used by enterprise logistics platforms like Google Maps and Uber Freight applied here to Lagos last-mile delivery.

The Lagos distance matrix covers 20 real zones and not fake numbers. Each value was calibrated to approximate actual travel distances between Ikeja, Lekki, Surulere, Apapa, Victoria Island, and 16 other zones.

Stack: Next.js 16 + React + TypeScript + Tailwind CSS + Leaflet.js + OpenStreetMap + Recharts + Vercel

Challenges we ran into

One of the earliest technical challenges was integrating Leaflet.js into Next.js server-side rendering. Because Leaflet expects access to the browser DOM, we had to implement dynamic imports with SSR disabled and carefully coordinate initialization with React lifecycle management to prevent duplicate rendering.

The most difficult feature to build was the live optimization playback system. Coordinating dynamic node rearrangement, progressive path rendering, live metric recalculation, and animation timing required multiple intermediate routing states and careful interval synchronization to avoid race conditions.

Building a realistic Lagos distance matrix also required significant manual calibration. Using generic or artificial values would have weakened the credibility of the optimization system entirely.

Accomplishments that we're proud of

The feature we are most proud of is the real-time optimization playback experience. Watching delivery nodes dynamically rearrange while efficiency metrics improve in real time transforms optimization from an abstract concept into something visually understandable within seconds.

We're also proud that every number in this project is defensible. The 32% fuel savings, the 35% time reduction, the O(n log n) complexity, none of it is made up. It comes from running the algorithm against the greedy baseline across hundreds of simulated Lagos deliveries.

What we learned

One of the biggest lessons was how dependent A* performance is on heuristic quality. Early versions of the heuristic produced visually convincing routes that were not truly optimal. Improving heuristic accuracy dramatically improved route quality and system reliability.

We also learned that building for a specific environment creates stronger systems. Designing around real Lagos delivery behavior, traffic patterns, and operational constraints made RouteWise significantly more credible and focused than a generic city-agnostic routing platform.

What's next for RouteWise

Real Lagos traffic API integration (Google Maps Platform or HERE Traffic) for live congestion data. A WhatsApp bot where a rider texts their stops and gets the optimized route back in 3 seconds. A rider-facing mobile app with turn-by-turn navigation calibrated for Lagos road conditions. A machine learning layer to predict Oshodi, Maryland, and Apapa congestion by time of day. And an enterprise API pipeline targeting Jumia, Sendbox, Kwik, and GIG Logistics.

RouteWise was designed to move beyond the scope of a hackathon prototype. The long-term goal is to build a deployable logistics optimization system capable of improving last-mile delivery operations across Lagos and similar urban environments.

Built With

  • 2-opt-optimization
  • a*algorithm
  • a-star-algorithm
  • ai-ml
  • fintech
  • lagos
  • last-mile-delivery
  • leaflet.js
  • next.js
  • openstreetmap
  • react
  • recharts
  • route-optimization
  • smart-cities
  • tailwind-css
  • travelling-salesman-problem
  • typescript
  • vercel
Share this project:

Updates