CommunityFarm order rerouting
A driver-reassignment recommender for a farm-to-home delivery startup: K-means clusters orders by location, and when a driver is overloaded, it recommends which nearby driver should absorb each order. Hours of manual Excel work became minutes.
The brief
CommunityFarm is a Bangalore organic-produce marketplace. Orders arrived in an Excel sheet and were assigned to drivers by pincode. When a driver got overloaded or dropped out, their orders had to be rerouted to someone already delivering nearby. The existing process was manual: upload routes to a mapping tool two drivers at a time and eyeball the intersections. Slow, and it needed someone who knew the roads. Google’s distance-matrix API was priced out at their scale.
How it works
- Load and geocode the orders, assign by pincode, and flag any driver past the load threshold.
- K-means clusters orders by latitude and longitude, so each driver serves one or more geographic clusters.
- To shift an order: find its cluster, rank nearby clusters by centroid distance (Haversine, because the earth is not flat), and recommend the drivers whose routes already pass close. Bulk reassignment handles a driver dropping out entirely.
- Results write back to Excel and serve over a Flask API to a React UI, so dispatch staff never touch Python.
The design lesson
The original ask was full automation. Through mentor reviews it became a recommendation system instead: do all the computation, surface the options, let the dispatcher choose. That human-in-the-loop call was deliberate, and it is why the tool got adopted rather than resisted. Clustering first also solved the cost problem: group the geography, then compute distances between a handful of centroids instead of every pair of orders.
Credit
Internship guided by Revathy Murugesh, COO, CommunityFarm.