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