AI-powered carbon footprint analyzer using Google Gemini
Built for the DEV Weekend Challenge: Earth Day Edition
🔗 https://ecomind-gamma.vercel.app
EcoMind lets you describe your daily lifestyle in plain language and returns a personalised carbon footprint analysis powered by the Google Gemini API. No rigid forms — just describe your commute, diet, home heating, and travel habits, and get back:
- Estimated annual CO₂ in kg
- Sustainability score (1–10)
- Top 5 reduction actions ranked by impact with CO₂ savings per year
- Regional context — advice tailored to your location (Finland-aware by default)
- Next.js 14 (App Router) + TypeScript
- Google Gemini API (
gemini-1.5-flash) via@google/generative-ai - Structured JSON output using Gemini's
responseSchemafeature - Tailwind CSS for styling
- Vercel for deployment
# Clone the repo
git clone https://github.com/mzunain/ecomind.git
cd ecomind
# Install dependencies
npm install
# Add your Gemini API key
echo 'GEMINI_API_KEY=your_key_here' > .env.local
# Run development server
npm run devGet a free Gemini API key at https://aistudio.google.com
Instead of parsing free-form Gemini text responses, this project uses Gemini's responseSchema to enforce a strict JSON schema at the model level:
const model = genAI.getGenerativeModel({
model: 'gemini-1.5-flash',
generationConfig: {
responseMimeType: 'application/json',
responseSchema: ecoAnalysisSchema,
},
});This guarantees reliable, parseable responses without regex or prompt engineering hacks.
MIT