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)