Overview
FlexDrop is an adaptive delivery coordination engine. At checkout, a student can choose “deliver 10 minutes later and get ₹8 back”. FlexDrop prices that offer from the savings it expects, then uses only as much of each customer’s approved flexibility as it needs to combine compatible Food and Instamart orders onto fewer, shorter rider routes.
Every approved window, food-safety limit and rider earnings floor is still respected.
Problem and aim
Problem
Delivery apps dispatch most orders independently and as fast as possible, even when the customer would happily wait a few minutes. That means more trips, longer distances and higher cost per order.
Aim
Turn customer-approved flexibility into an explicit, bounded optimisation variable that lowers cost without hurting on-time delivery or food quality.
How it works
01 / 06
Offer
An acceptance model predicts how likely a customer is to accept each wait-for-reward option, and only explicit consent counts.
02 / 06
Price the reward
The incentive optimiser picks the reward that maximises expected savings minus what it pays out, within viability caps.
03 / 06
Check compatibility
Hard rules for temperature, contamination, leaks, fragility, capacity and timing decide which orders may ride together.
04 / 06
Optimise routes
Rolling-horizon column generation, exact branch-and-bound sequencing and CP-SAT set packing choose the batches and routes.
05 / 06
Spend flexibility carefully
Each order’s used flexibility stays between zero and what the customer approved, and the least needed is used.
06 / 06
Re-optimise
Plans adapt to prep delays, cancellations and rider drop-outs, without ever extending a window the customer did not approve.
Architecture
ACallers
- CheckoutAsks for a quote; records consent.
- Dispatch engineAsks for a plan every epoch.
- FlexDrop StudioBrowser UI: 3D campus (three.js), map (Leaflet).
BFastAPI service
- API + servicesOrders, preferences, optimise, plan events.
- EnginesIncentive, compatibility, optimiser, routing, re-optimiser.
- ML registryPrep, travel, acceptance, coordination models.
CData
- SQLAlchemySQLite in development, PostgreSQL in production.
- AlembicDatabase migrations.
- PrometheusMetrics and an audit log.
Request flow
- Checkout sends an order; FlexDrop predicts prep and travel time and quotes wait-for-reward offers.
- The customer accepts or declines; consent and the approved window are stored.
- Each dispatch epoch, the optimiser batches compatible orders and sequences routes.
- Dispatch executes the plan and reports events; the re-optimiser adapts to delays.
- If FlexDrop is off or slow, dispatch simply continues on its normal path.
Languages and code
- Python62.5%
- JavaScript33.2%
- CSS2.6%
- HTML1.2%
- Shell0.5%
Repository
.github/1 file
workflows/1 file
- 36 lines
data/2 files
sample/Sample campus and city data.
- 37 lines
- 37 lines
deploy/Production config (nginx, systemd) and database migrations.
nginx/1 file
- 43 lines
systemd/2 files
- 10 lines
- 31 lines
- 14 lines
docs/Architecture, maths model, algorithms, API, security, deployment.
- 143 lines
- 175 lines
- 143 lines
- 76 lines
- 83 lines
- 147 lines
- 185 lines
- 193 lines
- 27 lines
- 184 lines
- 161 lines
migrations/Production config (nginx, systemd) and database migrations.
versions/1 file
- 355 lines
- 42 lines
- 27 lines
reports/Simulation results, comparisons and robustness runs.
- 35 lines
- 237 lines
- 35 lines
- 237 lines
- 102 lines
- 20 lines
- 75 lines
scripts/5 files
- 50 lines
- 60 lines
- 50 lines
- 22 lines
- 113 lines
src/75 files
flexdrop/The Python package.
api/FastAPI app, routers, API-key roles, rate limits, idempotency, errors.
routers/7 files
- 1 line
- 67 lines
- 58 lines
- 53 lines
- 28 lines
- 102 lines
- 147 lines
- 1 line
- 98 lines
- 39 lines
- 52 lines
- 92 lines
- 100 lines
db/Database layer and core domain types.
- 1 line
- 46 lines
- 240 lines
- 67 lines
domain/Database layer and core domain types.
- 1 line
- 269 lines
engines/incentive, compatibility, optimizer, routing, flexibility, reoptimizer, promise, cost, travel.
- 1 line
- 140 lines
- 68 lines
- 85 lines
- 149 lines
- 461 lines
- 43 lines
- 130 lines
- 304 lines
- 66 lines
ml/Features, models, training and the model registry.
- 1 line
- 78 lines
- 227 lines
- 154 lines
- 244 lines
services/Use-cases between the API and the engines: orders, dispatch, metrics, privacy.
- 1 line
- 99 lines
- 265 lines
- 29 lines
- 461 lines
- 68 lines
- 80 lines
- 299 lines
- 74 lines
simulation/Scenarios, the five dispatch policies, the event simulator and metrics.
- 1 line
- 117 lines
- 85 lines
- 99 lines
- 87 lines
- 245 lines
- 406 lines
- 632 lines
web/FlexDrop Studio: checkout, operations dashboard, 3D campus and results.
css/1 file
- 267 lines
js/10 files
- 43 lines
- 2966 lines
- 343 lines
- 358 lines
- 276 lines
- 142 lines
- 99 lines
- 120 lines
- 736 lines
- 114 lines
- 153 lines
- 8 lines
- 6 lines
- 300 lines
- 36 lines
- 57 lines
- 219 lines
- 227 lines
- 50 lines
- 53 lines
- 51 lines
- 245 lines
- 421 lines
tests/Unit, optimisation and integration tests.
integration/4 files
- 1 line
- 450 lines
- 173 lines
- 178 lines
optimization/4 files
- 1 line
- 191 lines
- 58 lines
- 116 lines
unit/5 files
- 1 line
- 106 lines
- 97 lines
- 182 lines
- 157 lines
- 1 line
- 143 lines
- 10 lines
- 14 lines
- 39 lines
- 20 lines
- 48 lines
- 65 lines
- 185 lines
- 14 lines
- models/Trained model files and their metadata. on GitHub
Methodology
- Model the problem mathematically, then build each engine as its own tested module.
- Compare five dispatch policies in a discrete-event simulation of a campus and a city.
- Run an ablation (no flexibility) to separate the gain from flexibility from the gain from the optimiser.
- Repeat over five random seeds and report the spread, not just one good run.
Technology
Demo




Results
| Scenario | Policy | Cost per order | Distance per order | On-time |
|---|---|---|---|---|
| Campus (470 orders) | Independent dispatch | ₹78.56 | 4.56 km | 90.2% |
| Conventional batching | ₹73.78 | 4.16 km | 92.1% | |
| FlexDrop | ₹66.21 (−15.7%) | 3.30 km | 92.8% | |
| City (404 orders) | Independent dispatch | ₹83.14 | 5.00 km | 95.8% |
| Conventional batching | ₹79.76 | 4.67 km | 95.3% | |
| FlexDrop | ₹72.84 (−12.4%) | 3.92 km | 95.0% |
Over five seeds FlexDrop cut cost by 15.5% ± 1.5 (campus) and 10.8% ± 1.3 (city), with on-time rate unchanged within noise, zero food-quality violations and about 50 ms optimisation latency (P95).
Concepts
01What is the vehicle routing problem?
Choosing which vehicle serves which stops, and in what order, to minimise cost under constraints like time windows and capacity. It gets hard very quickly as orders grow.
02What is column generation?
Instead of listing every possible route (far too many), the solver starts with a few and keeps adding only the routes that could improve the answer.
03What is a rolling horizon?
Plan for the next short window with the orders you know, commit only what must leave now, and re-plan as new orders arrive.
04What is an ablation study?
Remove one part of the system and measure again. The difference shows how much that part contributes.
Team
- Sujal NegiCo-founder, Nexara9PortfolioLinkedIn
- Made NavyaCo-founder, Nexara9LinkedInGitHub