Inspiration:

Transportation is a major contributor to CO₂ emissions, and route choices can meaningfully change a trip’s footprint. We wanted a tool that makes the greener choice obvious—simple enough for everyday drivers, yet accurate and transparent about distance, time, and estimated emissions.

What it does:

GreenRoute lets users enter a start and destination, then fetches at least two driving routes via the OpenRouteService Directions API. For each route, it calculates:

Total distance

Estimated travel time

Estimated CO₂ emissions (≈ 0.192 kg CO₂/km for a gasoline car)

It visualizes all routes on an interactive Leaflet.js map, color-codes them (green = lowest emissions, yellow = moderate, red = highest), and highlights the most eco-friendly option. A summary panel/table lists the key metrics for quick comparison.

How we built it:

Backend: Production-ready Flask app (app.py) with a clean service layer to call OpenRouteService, parse alternatives, and compute emissions. Secrets handled with python-dotenv and environment variables.

Frontend: templates/index.html + static/style.css + Leaflet.js for map rendering, route polylines, and a responsive metrics panel.

Routing & Data: OpenRouteService Directions API (driving-car profile) requested with alternatives=true to obtain multiple candidate routes. Emissions computed as distance_km * 0.192.

Quality: Input validation, error handling for API failures/rate limits, clear comments, and a small utility module for unit conversion and formatting.

Challenges we ran into:

Consistent alternatives: Ensuring the API reliably returned ≥2 distinct routes across regions required careful parameter tuning and fallbacks.

Polyline decoding & styling: Rendering multiple polylines with distinct colors/legends while keeping the UI uncluttered.

Unit handling & rounding: Keeping distance/time consistent (meters → km, seconds → hh:mm) and rounding without hiding meaningful differences.

Accomplishments that we’re proud of

A clean, minimal UX where the greener route is unmistakably green (literally).

Solid backend structure with environment-based configuration and graceful error paths.

A compact, readable codebase that’s easy to extend (e.g., adding vehicle types or traffic).

What we learned:

Practical tradeoffs between “fastest” vs “lowest-emissions” routing and how to present those differences clearly.

Working with third-party routing APIs (rate limits, geometry formats) and mapping libraries in a production-style Flask app.

Why small UX choices (legends, badges, ordering) matter for sustainability nudges.

What’s next for GreenRoute:

Vehicle profiles: Add diesel/hybrid/EV factors and custom g/km rates.

Traffic-aware estimates: Incorporate live traffic where available.

Waypoints & constraints: Avoid tolls/hills, prefer bike-lanes or low-emission zones.

Share & compare: One-click share of the greener route and weekly CO₂ savings reports.

Built With

Share this project:

Updates