How abdurrahimcs50/fuel-route-optimizer works
Fuel route optimizer is a Django API that accepts distinct US start and finish locations and returns driving-route geometry, cost-optimized fuel stops for a 500-mile-range vehicle, and total fuel cost. The request flow validates locations, geocodes both endpoints, obtains a driving route, finds nearby fuel-station candidates, and selects stops. Station data is loaded and geocoded separately by an offline management command. The README documents a browsable API as well. Source excerpts show the principal calls; relationships for the browsable interface and framework-level URL mounting are not expanded.
Main entry points: views.py Request orchestration · geocode_stations.py Station loading and geocoding · candidates.py Station candidate search · services.py Geocode and routing
Components 13
API
- Route endpoint
routing/urls.py - Request orchestration
routing/views.py - Request validation
routing/serializers.py - API error mapping
routing/exceptions.py
Route planning
- Station candidate search
routing/candidates.py - Fuel-stop selection
routing/algorithm.py
Station data
- Fuel station store
stations/models.py - Station loading and geocoding
stations/management/commands/geocode_stations.py - Fuel price dataset
data/fuel-prices-for-be-assessment.csv
External services
- Geocode and routing
routing/services.py - Nominatim
- OSRM
Other components
- API client
Connections 14
- API client → Route endpoint: submits route
README.md - Route endpoint → Request orchestration: dispatches to
routing/urls.py - Request orchestration → Request validation: validates with
routing/views.py - Request orchestration → Geocode and routing: geocodes and routes
routing/views.py - Geocode and routing → Nominatim: geocodes via
routing/services.py - Geocode and routing → OSRM: fetches route
routing/services.py - Request orchestration → Station candidate search: finds stops
routing/views.py - Station candidate search → Fuel station store: queries stations
routing/candidates.py - Station candidate search → Fuel-stop selection: selects candidates
routing/candidates.py - Request orchestration → API error mapping: raises API errors
routing/views.py - Station loading and geocoding → Fuel price dataset: loads rows
stations/management/commands/geocode_stations.py - Station loading and geocoding → Fuel station store: loads and updates
stations/management/commands/geocode_stations.py - Station loading and geocoding → Nominatim: geocodes places
stations/management/commands/geocode_stations.py - Request orchestration → API client: returns route and cost
routing/views.py