AI Carbon Footprint Analyzer with On-Chain Pledges
Snap a photo of your lunch, describe your commute, or upload a receipt — EcoLens uses Google Gemini Vision to instantly reveal the hidden CO₂ cost of your daily choices. Then pledge to do better on the Solana blockchain — a permanent, public, verifiable commitment.
| Feature | Description |
|---|---|
| 📸 Vision Analysis | Upload any photo — Gemini Vision identifies items and calculates CO₂ |
| ✍️ Text Analysis | Describe any activity and get an accurate, sourced emission estimate |
| 🎙️ Voice Input | Speak your description using the browser's Speech API |
| ⚖️ Compare Mode | Race two options side by side — see the greener choice with a winner crown |
| ◎ Solana Pledges | Sign an on-chain pledge with Phantom — permanent, immutable, verifiable |
| 🤖 Streaming AI Chat | Gemini-powered eco-agent that streams responses token-by-token |
| 📊 Carbon Budget | Set a weekly CO₂ goal and track it against a live circular meter |
| 📋 Analysis History | Every scan saved locally — expandable, searchable, clearable |
| 🎉 Confetti | Green confetti fires when your result comes back Low Impact |
| 📤 Shareable Cards | Download your result as a PNG image to share on social media |
📸 Photo / 📝 Text / 🎙️ Voice
↓
Gemini 2.0 Flash
(vision + emissions data)
↓
CO₂ breakdown + alternatives
↓
◎ Sign pledge on Solana
(Phantom wallet + Memo Program)
↓
Permanent on-chain record
verifiable on Solana Explorer
git clone https://github.com/aryakoste/ecolens
cd ecolens
npm installcp .env.local.example .env.localOpen .env.local and fill in:
Google Gemini
- Go to Google AI Studio → Create API key
- Set
GEMINI_API_KEY=your_key
Auth0
- Create a Regular Web Application
- Set Allowed Callback URLs →
http://localhost:3000/api/auth/callback - Set Allowed Logout URLs →
http://localhost:3000 - Fill in
AUTH0_ISSUER_BASE_URL,AUTH0_CLIENT_ID,AUTH0_CLIENT_SECRET - Generate a secret:
openssl rand -hex 32→ set asAUTH0_SECRET
Solana — no API key needed. Uses Phantom wallet (browser extension) on Devnet. Install Phantom, open Settings → Developer Settings → Switch to Devnet.
npm run dev| Layer | Technology |
|---|---|
| Framework | Next.js 15 (App Router, server components) |
| AI | Google Gemini 2.0 Flash (@google/generative-ai) |
| Auth | Auth0 for Agents (@auth0/nextjs-auth0 v3) |
| Blockchain | Solana Devnet (@solana/web3.js + Phantom) |
| Styling | Tailwind CSS + custom CSS animations |
| Animation | Framer Motion |
| Confetti | canvas-confetti |
| Share cards | html-to-image |
| Language | TypeScript (strict) |
| Deployment | Vercel |
app/
page.tsx ← Landing page with animated Earth globe
dashboard/
page.tsx ← Server component — Auth0 session guard
dashboard-client.tsx ← Client dashboard (Analyze / Compare / History / Chat tabs)
api/
analyze/route.ts ← Gemini vision + text analysis (Auth0 protected)
chat/route.ts ← Streaming Gemini chat (Auth0 protected)
compare/route.ts ← Side-by-side carbon comparison (Auth0 protected)
auth/[auth0]/route.ts ← Auth0 login / callback / logout handler
components/
earth-globe.tsx ← CSS animated globe (no Three.js)
carbon-analyzer.tsx ← Text + image upload + voice input + confetti
impact-result.tsx ← Result card with share button + Solana pledge
solana-pledge.tsx ← Phantom wallet connection + Memo Program transaction
compare-analyzer.tsx ← Side-by-side comparison UI
eco-chat.tsx ← Streaming AI chat interface
carbon-history.tsx ← Expandable localStorage history list
budget-meter.tsx ← Circular weekly CO₂ budget tracker
navigation.tsx ← Top nav with Auth0 user avatar
lib/
gemini.ts ← Gemini client, analysis prompt, streaming generator
history.ts ← useAnalysisHistory hook (localStorage)
After each analysis, EcoLens suggests a greener alternative and offers a Sign pledge with Phantom button.
Clicking it:
- Connects to the user's Phantom wallet via
window.solana.connect() - Builds a
Transactionusing the Solana Memo Program (MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr) - Encodes the pledge text, CO₂ saved, and timestamp as UTF-8 memo data
- Sends it to Solana Devnet — confirmed in ~400ms, costs < $0.001
- Returns a transaction signature linkable on Solana Explorer
The pledge is permanent, public, and tied to the user's wallet address.
const tx = new Transaction().add(
new TransactionInstruction({
keys: [{ pubkey: publicKey, isSigner: true, isWritable: false }],
programId: MEMO_PROGRAM_ID,
data: Buffer.from(JSON.stringify({
app: "EcoLens",
pledge: "I pledge to cycle instead of drive this week",
carbonKg: 2.4,
ts: new Date().toISOString(),
}), "utf-8"),
})
);
const { signature } = await window.solana.signAndSendTransaction(tx);- Solana Mainnet pledges with SOL micro-transactions
- On-chain pledge leaderboard — public wallet rankings
- NFT certificates when weekly carbon goal is hit
- Snowflake analytics — anonymized community emissions trends
- Verified offset recommendations linked to on-chain pledges
Built with 💚 for Earth Day 2025