DEV Community

S M Tahosin
S M Tahosin

Posted on

EcoSense AI: Know Your Carbon Footprint in 60 Seconds

DEV Weekend Challenge: Earth Day

This is a submission for Weekend Challenge: Earth Day Edition

What I Built

EcoSense AI is an AI-powered carbon footprint analyzer that helps people understand their environmental impact through a simple 4-step questionnaire — with persistent memory and carbon offset donations.

Users answer questions about their:

  • 🚗 Transportation — commute method & distance
  • 🍽️ Diet — from heavy meat to vegan
  • Home Energy — fossil fuels to 100% renewable
  • 🛍️ Shopping — fast fashion to minimal/second-hand

Then the app:

  1. Google Gemini 2.0 Flash analyzes their habits and returns an eco score, CO2 estimate, personalized tips, and Earth Day pledge
  2. Backboard saves each assessment to persistent memory threads, enabling progress tracking over time
  3. Solana enables carbon offset tree-planting donations via SOL transfers

Demo

🌍 Live: https://ecosense-ai.pages.dev

Try it now — takes about 60 seconds!

Features:

  • Eco Score (0-100) with SVG donut chart visualization
  • Letter grade (A+ to F) with estimated annual CO₂
  • Impact breakdown by category with color-coded status bars
  • 5 personalized tips from Gemini AI
  • Earth Day pledge with copy-to-clipboard sharing
  • Carbon offset via Solana donation
  • Memory persistence via Backboard threads

Code

GitHub logo x-tahosin / ecosense-ai

EcoSense AI - Carbon Footprint Analyzer powered by Google Gemini. Built for Earth Day 2026.

EcoSense AI 🌍

AI-Powered Carbon Footprint Analyzer — Built for Earth Day 2026

What It Does

Answer 4 quick questions about your daily habits (transport, diet, energy, shopping) and EcoSense AI uses Google Gemini to:

  • Calculate your estimated annual carbon footprint
  • Grade your eco-friendliness (A+ to F)
  • Show impact breakdown by category
  • Give 5 personalized tips to reduce your footprint
  • Generate a shareable Earth Day pledge

Live Demo

https://ecosense-ai.pages.dev

Tech Stack

  • Next.js 16 (static export)
  • Tailwind CSS (custom Earth Day theme)
  • Google Gemini 2.0 Flash (AI analysis via server-side proxy)
  • Cloudflare Pages (hosting + serverless functions)
  • Lucide React (icons)

Architecture

Browser → Static HTML/JS (Cloudflare Pages)
            ↓
         /api/generate (Cloudflare Function — server-side only)
            ↓
         Google Gemini API (key never exposed to client)

Setup

npm install
npm run build
# Deploy: wrangler pages deploy out
# Set GEMINI_API_KEY in Cloudflare Pages environment variables
Enter fullscreen mode Exit fullscreen mode

Built for

DEV Weekend Challenge: Earth Day Edition

Key files:

  • app/page.tsx — Full React UI with step wizard, score visualization, Solana integration, and Backboard memory status
  • functions/api/generate.js — Cloudflare Function proxying Gemini (API key never reaches browser)
  • functions/api/memory.js — Cloudflare Function proxying Backboard memory API

How I Built It

Tech Stack

  • Next.js 16 with static export
  • Tailwind CSS — custom green/earth color palette
  • Google Gemini 2.0 Flash — AI analysis engine
  • Backboard — persistent memory for tracking assessments over time
  • Solana — carbon offset tree-planting donations
  • Cloudflare Pages — hosting + serverless functions
  • Lucide React — iconography
  • GitHub Copilot — used throughout development for rapid iteration

Architecture: Everything Server-Side

Browser → Static HTML/JS (Cloudflare Pages)
            ↓
         /api/generate → Cloudflare Function → Google Gemini (key server-only)
         /api/memory   → Cloudflare Function → Backboard API (key server-only)
Enter fullscreen mode Exit fullscreen mode

No API keys ever touch the browser. Both Gemini and Backboard calls go through Cloudflare Functions.

How Each Technology Is Used

Google Gemini — The core analysis engine. I send a structured prompt with the user's 4 selections and ask for specific JSON output: score, grade, CO₂ estimate, impact breakdown, tips, and pledge. Temperature 0.7 gives the best variety/accuracy balance.

Backboard — After each analysis, results are saved to a Backboard memory thread keyed by session ID. This enables returning users to see progress over time — "Your score improved from 45 to 62 since last month!" The memory API gracefully falls back if unavailable.

Solana — The results page calculates how many trees would offset the user's footprint (~1 tree absorbs ~22kg CO₂/year) and offers a Solana donation option. SOL is ideal for micro-donations: sub-second finality, fraction-of-a-cent fees, and Solana's Proof of Stake uses 99.9% less energy than Proof of Work chains.

GitHub Copilot — Used throughout development for the step wizard logic, SVG chart math, and Tailwind styling. Copilot's inline suggestions accelerated the build significantly.

UI Highlights

  • Step wizard with animated progress bar
  • SVG donut chart for the eco score
  • Color-coded impact badges (red → green)
  • Category breakdown bars in the results
  • Purple Solana donation panel with explorer link
  • Blue Backboard memory status indicator
  • Copy-to-clipboard Earth Day pledge for social sharing

Prize Categories

  • Best Use of Google Gemini — Gemini is the core engine producing calibrated environmental analysis from 4 simple inputs
  • Best Use of Solana — Carbon offset donations via SOL, leveraging Solana's eco-friendly PoS consensus
  • Best Use of GitHub Copilot — Copilot accelerated the entire build from UI components to API integration
  • Best Use of Backboard — Persistent memory threads track assessment history for progress monitoring

Top comments (1)

Collapse
 
jon_at_backboardio profile image
Jonathan Murray

Let's goooo! How was your experience with backboard? would you recommend?