Last night, I challenged myself to solve a very practical problem:
How do you find the cheapest fuel stops along a driving route between two cities?
At first, it sounded simple.
Until I opened the fuel station dataset and realizedβ¦
It had no coordinates. π
Thatβs when this turned from a simple API into a deep dive into:
- Routing
- Geocoding
- Spatial matching
- Caching
- Performance engineering
π§ The Core Idea
Given:
Start Address β End Address as a string or list of coordinates
The system should:
- Geocode both addresses using OpenRouteService
- Fetch the driving route polyline
- Build a route corridor using bounding boxes along the path
- Match fuel stations from a CSV dataset that fall inside this corridor
- Return the cheapest stations along the trip
No coordinates in the dataset? No problem. We make the map logic do the work.
β‘ The Performance Problem
Geocoding and routing APIs are expensive and slow.
So I introduced Redis caching:
- Addresses are geocoded once and cached forever
- Routes are cached
- Fuel stations are loaded into memory using Pandas
And hereβs the fun part:
β No database
β No GIS server
β
Pure spatial computation in memory
After the first request, response times drop to under 150ms.
π οΈ Stack Used
- Django + DRF
- Redis
- Pandas
- GeoPandas
- OpenRouteService API
- Spatial math (without PostGIS)
π‘ Key Engineering Lessons
- Normalize messy data instead of bending your logic around it
- Cache aggressively when dealing with external APIs
- You donβt always need a database for spatial problems
- Bounding boxes + in-memory data can be incredibly fast
This project genuinely felt like building a mini map engine from scratch.


Top comments (0)