Build EcoRoute: A smart City Waste and Circular Economy Engine.

python dev.to

Build a full-stack, production-grade project during a hackathon
When our team set out to compete in the Smart Cities and Route Optimization track, we didn't want to build just another static mapping app that plots static points. Municipal waste managment in fast-growing urban centers faces major operational challenges:

  1. Inefficient truck that burn unnecessary fuel
  2. Zero real-time visibility into bin fill levels
  3. Poor integration with post-collection recycling economies.

we decided to build EcoRoute an end-to-end platform that:

  • Combines real-time waste monitoring
  • AI fill prediction
  • Go-powered route optimization
  • Crowd-sourced citizen reporting
  • A circular marketplace that traces recycled waste directly to retail products. The Problem Urban waste collection in many developing cities suffers from three core issues:
  • Static, Inefficient Routes:Refuse trucks follow rigid, predetermined routes regardless of whether bins are empty or overflowing. This waste driver time , spikes municipal fuel expenses and increases carbon emissions. 2.Reactive Collection and Poor Citizen Feedback: Bins overflow before cities notice. Citizens have no direct channel to report illegal dumping or missed pickups, leading to dalayed escalations. 3.Disconnected Recycled Lifecycles: Waste collection is treated as an endpoint rather than the start of a supply chain. Recyclers and consumers lack transparency regarding where recycled raw materials come from. The solution
    1. Waste monitoring and AI predictions Live Interactive Map: Color-coded status markers show full bin locations in real-time. AI Fill Forecasting: A lightweight microservice predicts tomorrows fill level per point so logistics teams can plan ahead proactively. EcoMarket Circular Economy:* A closed-loop marketplace where products made from recovered waste are traced back to the specific waste collection batch they originated from.

Key Features

  1. Waste Monitoring & AI Predictions

Live Interactive Map: Color-coded status markers show full bin locations in real time.

  • AI Fill Forecasting: A lightweight microservice predicts tomorrow's fill level per point so logistics teams can plan ahead proactively.
  • Resilient Architecture: If the AI service drops, the backend gracefully degrades to historical baselines to prevent dashboard crashes (500 errors).
  1. Route Optimization & Driver Workflows
  • Nearest-Neighbor + 2-Opt Reordering: Instantly re-sequences stops to cut total transit distance.
  • Savings Delta: Computes and saves before/after comparative metrics for distance (km), fuel (L), and time saved per collection run.
  • Driver Execution UI: Step-by-step mobile driver interface to log collections, mark completion, or flag failed pickups.
  1. *Community Reporting *
  • Citizens upload geotagged photos of illegal dumping or overflowing bins.
  • Submitting a report automatically escalates the linked waste point to critical status, forcing immediate route re-calculation.
  1. EcoMarket & Provenance Ledger
  • Waste collected is weighed (kg) and broken down by category (PET plastics, metals, paper).
  • Manufacturers convert these Recycling Material Batches into commercial products sold on EcoMarket.
  • Buyers click Trace Material Origin to view the full lineage: Waste PointCollection RunRecycling BatchFinished Product, with simulated M-Pesa automated seller payouts.

How It Was Built & Tech Stack

We organized the project into a clean monorepo structure to accelerate parallel development:

text
├── backend/     Go API (cmd/server, internal/{handlers,services,repositories,models,middleware,routes})
├── frontend/    React 19 + Vite (src/{components,pages,layouts,services,hooks,utils,types})
├── ai/          Python prediction service (services/api.py)
├── database/    PostgreSQL 16 schema + seed SQL
├── docs/        ARCHITECTURE.md, API.md, MVP.md
└── docker-compose.yml
Enter fullscreen mode Exit fullscreen mode

The Backend (Go 1.26 + PostgreSQL 16)

The API core was built in** Go 1.26** using standard library routing (net/http) and pgx/v5 for PostgreSQL connectivity.

**Authentication**: **JWT** with **bcrypt ** password hashing.
Enter fullscreen mode Exit fullscreen mode

** Algorithms**: We implemented a local Nearest-Neighbor heuristic combined with 2-Opt edge swapping directly in Go to reorder stop arrays deterministically.

func Optimize2Opt(route []models.WastePoint) []models.WastePoint {
    bestRoute := make([]models.WastePoint, len(route))
    copy(bestRoute, route)
    improved := true

    for improved {
        improved = false
        for i := 1; i < len(route)-2; i++ {
            for j := i + 1; j < len(route)-1; j++ {
                if TwoOptDistance(bestRoute, i, j) < TotalDistance(bestRoute) {
                    ReverseSubRoute(bestRoute, i, j)
                    improved = true
                }
            }
        }
    }
    return bestRoute
}
Enter fullscreen mode Exit fullscreen mode

The Frontend (React 19 + Leaflet)

Built using React 19, Vite, react-router 7, and Leaflet / react-leaflet.

  • Dynamic map layer rendering color-coded pins based on real-time fill percentages.
  • Separate, role-tailored interface views for Admins, Drivers, Community Members, and Marketplace Seller s.

The AI Prediction Service (Python)

A lightweight Python service exposing a simple HTTP contract (POST /predict) that calculates expected fill trajectories based on recent historical fill velocity.

Building a full-stack monorepo with AI prediction, real-time map rendering, custom algorithms, and circular economic ledgers in 72 hours required deep trust and domain ownership:

Frontend Development:@emma_jane and @Ashley_Adhiambo

Backend Engineering:@Evans_Juma

Database Architecture: @sospeter 

UI Design & Integration: @frihk_ian 
Enter fullscreen mode Exit fullscreen mode

Any comment and suggestion on the platform

Source: dev.to

arrow_back Back to Tutorials