DEV Community

jantoine2
jantoine2

Posted on

EcoLens 🌍 β€” Scan Any Object, Discover Its Carbon Impact (Built for Haiti & Resource-Limited Environments)

DEV Weekend Challenge: Earth Day

What I Built

EcoLens is a web app that lets you photograph any object β€” a meal, a product, a vehicle, an electronic device β€” and instantly discover its carbon footprint, with eco-friendly alternatives and advice adapted to your real local context.

What makes EcoLens unique: it's built specifically for resource-limited environments like Haiti, where most "green" apps suggest solutions that simply don't exist locally (electric cars, composting services, organic supermarkets...). EcoLens gives realistic, actionable advice for where you actually live.

Demo

The Problem I'm Solving

Most carbon footprint tools are built for Western contexts. They suggest:

  • "Buy an electric vehicle" ❌ not available in Haiti
  • "Use your composting service" ❌ doesn't exist
  • "Shop at the organic supermarket" ❌ not accessible

EcoLens gives advice that actually works where you live.

How It Works

  1. πŸ“Έ User uploads a photo of any object
  2. βš™οΈ React frontend sends it to the ASP.NET Core backend
  3. πŸ€– Backend calls Google AI models via OpenRouter API
  4. πŸ“Š AI identifies the object and calculates its environmental impact
  5. βœ… Results displayed with carbon score, CO2 estimate, eco alternatives, and local context tips

Special Feature: Haitian Dish Recognition

EcoLens recognizes Haitian dishes by name and gives culturally relevant advice:

  • 🍚 Diri djon djon (black mushroom rice)
  • πŸ₯© Griot (Haitian fried pork)
  • πŸŽƒ Soup joumou (pumpkin soup)
  • 🍌 Bannann peze (twice-fried plantain)
  • 🌽 MaΓ―s moulu ak legim (ground corn with vegetables)

Tech Stack

Layer Technology
Frontend React 19 + Vite + Axios
Backend ASP.NET Core 9 (C#)
AI Google Gemma via OpenRouter API
Dev Assistant GitHub Copilot

Why OpenRouter instead of Gemini API directly?

The Google Gemini API has geographic restrictions that block free tier access from Haiti and many Global South countries. I solved this by routing through OpenRouter, which provides access to Google's Gemma models without geographic restrictions β€” keeping Google AI at the core while making it accessible from anywhere in the world.

The system uses automatic fallback across 5 models for maximum reliability:

  1. google/gemma-3-27b-it:free
  2. google/gemma-3-12b-it:free
  3. google/gemma-4-31b-it:free
  4. nvidia/nemotron-nano-12b-v2-vl:free
  5. google/gemma-3-4b-it:free

AI-Assisted Development with GitHub Copilot

GitHub Copilot was used throughout the development of EcoLens to:

  • Generate ASP.NET Core boilerplate and controller structure
  • Debug the OpenRouter API integrations
  • Suggest improvements to the JSON parsing logic
  • Speed up React component development

Challenges I Ran Into

1. Google Gemini API geographic restrictions
The biggest challenge was discovering that Gemini's free tier is blocked from Haiti. The solution was OpenRouter with Google Gemma models.

2. Free models deprecated without warning
Built an automatic fallback system that tries 5 different models in sequence so the app never goes down.

3. Getting consistent JSON from AI
Gemma sometimes returns text before or after the JSON. Fixed with a robust extraction that finds the first { and last } in the response.

What I Learned

  • How to integrate multimodal AI APIs (image + text) in ASP.NET Core
  • The reality of geographic API restrictions affecting developers in the Global South
  • How to build a reliable fallback system across multiple free AI models
  • The importance of building for your actual local context

What's Next

  • [ ] Mobile-optimized camera capture
  • [ ] History of past analyses per user
  • [ ] Offline mode for low-connectivity environments
  • [ ] Support for more Caribbean and African contexts

Source Code

πŸ”— GitHub Repository


Built with ❀️ from Haiti for the DEV Weekend Challenge β€” Earth Day 2026 🌱
Powered by OpenRouter + Google Gemma AI + GitHub Copilot

Top comments (0)