A smart, AI-powered web app that helps individuals understand, track, and meaningfully reduce their carbon footprint β one action at a time.
Environmental Sustainability / Personal Climate Action
The app targets one of the most critical challenges of our era: translating awareness of climate change into concrete, measurable individual action. While many people want to reduce their environmental impact, they lack the tools to understand where their emissions come from and what to do about it.
π Live Demo
On first load, the app seeds realistic demo data so you can immediately explore all features.
| Feature | Description |
|---|---|
| π€ AI Eco-Coach | Rule-based recommendation engine with 20+ pattern-aware tips + chat interface |
| π Live Dashboard | Real-time carbon score, 7-day trend, category breakdown |
| π Activity Logger | Log transport, food, energy & shopping with instant COβ preview |
| π Analytics | 30-day trends, stacked charts, global average comparison |
| π Achievements | 16 badges, streak tracking, weekly/daily goal rings |
| π‘ Impact Equivalencies | Translate kg COβe into trees, car km, flights, phone charges |
| π± Fully Responsive | Desktop sidebar + mobile bottom navigation |
| βΏ Accessible | WCAG AA, ARIA labels, keyboard navigation, skip link |
The core formula follows the GHG Protocol standard:
Emissions (kg COβe) = Activity Data Γ Emission Factor
Emission factors are sourced from EPA (2023) and DEFRA (2023):
| Category | Examples | Data Unit |
|---|---|---|
| Transport | Car (petrol: 0.192), Train (0.041), Bus (0.089) | kg COβe per km |
| Food | Beef (6.61), Vegan meal (0.24), Chicken (0.69) | kg COβe per meal |
| Energy | Grid electricity (0.233), Natural gas (0.202) | kg COβe per kWh |
| Shopping | Electronics (12.0), Clothing (3.0), Delivery (0.5) | kg COβe per item |
The AI engine uses a priority-weighted scoring system β no external API required:
1. Build Context β aggregate last 7 days of user logs
2. Pattern Match β run each tip's condition() against context
3. Score & Rank β HIGH (3pts), MEDIUM (2pts), LOW (1pt)
4. Deduplicate β deprioritize recently seen tips
5. Output β top 3 personalized, actionable insights
Example decision rules:
- If
transport > 2Γ food emissionsβ push transit/cycling alternatives - If
beef meals β₯ 4/weekβ suggest plant-based swaps with exact savings - If
trend = worsening (+20%)β show improvement-focused tips - If
streak β₯ 5 daysβ encourage with gamification messaging
The chat system parses natural language with keyword matching and maps queries to context-aware response templates that reference the user's actual data.
User logs activity
β
calculator.js β applies emission factor β kg COβe
β
storage.js β persists to localStorage with date/category tagging
β
ai-engine.js β re-evaluates all tips against updated context
β
gamification.js β checks badge conditions, updates streaks
β
UI re-renders β charts, scores, tips refresh in real time
[User Input] βββΊ [Calculator] βββΊ [Storage (localStorage)]
β
ββββββββββββββββββββββ€
βΌ βΌ
[AI Engine] [Gamification]
β β
βΌ βΌ
[Insights/Tips] [Badges/Goals]
β β
ββββββββββ¬ββββββββββββ
βΌ
[UI / Charts]
ecotrace/
βββ index.html # SPA shell: layout, navigation, accessibility
βββ css/
β βββ style.css # Design system: tokens, components, animations
βββ js/
β βββ calculator.js # Emission factors & COβ calculation engine
β βββ storage.js # localStorage abstraction (type-safe read/write)
β βββ ai-engine.js # Rule-based AI: pattern detection, tip ranking, chat
β βββ gamification.js # Badges (16), streaks, goal progress
β βββ charts.js # Chart.js wrappers (donut, line, bar, sparkline)
β βββ ui.js # DOM helpers, toast notifications, animations
β βββ app.js # View routing, all 5 page renderers, bootstrap
βββ tests/
β βββ test.js # Unit tests for calculator, storage, AI engine
βββ README.md
| Technology | Purpose | Why |
|---|---|---|
| Vanilla HTML/CSS/JS | Core | Zero dependencies = maximum readability & instant load |
| Chart.js 4.4 (CDN) | Data visualization | Industry-standard, lightweight, beautiful charts |
| localStorage | Data persistence | No backend = no security risk, works offline |
| Google Fonts | Typography | Plus Jakarta Sans for modern, premium feel |
No build tools. No npm. Open index.html directly.
-
Emission factors use global averages from EPA/DEFRA 2023. Location-specific factors (e.g., regional electricity grids) are a future enhancement.
-
Food quantities are measured in "meals/servings" rather than exact grams, to minimize user friction and keep logging fast.
-
Energy data requires the user to know their approximate kWh usage. A future version could integrate with smart meter APIs.
-
No user authentication β data lives in the browser. This is intentional: zero security surface area, no data privacy concerns.
-
AI insights are deterministic and rule-based. They do not call any external API, ensuring the app works fully offline and poses no key exposure risk.
-
Demo data is seeded on first load so evaluators can immediately see all features without manual data entry.
Open tests/test.js in a browser console or run with Node.js:
node tests/test.jsTests cover:
- β Emission factor calculations (all 4 categories)
- β COβe equivalency conversions
- β Daily rating classification
- β Storage read/write/delete operations
- β AI engine tip matching logic
- β Goal progress calculations
- β Streak update logic
- WCAG 2.1 AA color contrast ratios throughout
- ARIA labels on all interactive elements, charts, and live regions
- Keyboard navigation β full tab order, Enter/Space triggers
- Skip link for screen reader users
aria-live="polite"on main content area for dynamic updates- Focus-visible outlines on all focusable elements
roleattributes βmain,navigation,list,listitem,log,img,article- Semantic HTML β
<header>,<main>,<nav>,<h1>β<h2>,<form>,<button>
- No external API calls (no API keys)
- No
eval()or dynamicFunction()usage - All user data stays on the user's device (localStorage)
- Input sanitization via
textContent(notinnerHTML) for user data novalidate+ JS validation to prevent native browser form exploits- CSP-compatible (no inline event attributes except framework-level onclick)
Option 1: Direct browser (simplest)
1. Download or clone this repository
2. Open index.html in any modern browser
3. That's it β no server needed!
Option 2: Local server (avoids CORS for font loading)
# Python
python -m http.server 8080
# Node.js
npx serve .
# Then visit http://localhost:8080Option 3: Vercel (live deployment)
1. Import repository on vercel.com
2. Deploy
3. Visit https://eco-trace-six-sepia.vercel.app/
- Tradeoff: We opted for a pure client-side architecture using
localStorageinstead of building a traditional REST API + Database server. - Why:
- Data Sovereignty / Absolute Privacy: Carbon footprint data details daily personal habits (diet, commute routes, purchases). Keeping data strictly on the user's device eliminates data liability under GDPR/CCPA.
- Zero Maintenance & Operational Costs: Serving a static SPA via CDN means the application is infinitely scalable at near-zero hosting cost.
- Offline capability: The application requires no network connectivity, offering sub-millisecond interaction times.
- Mitigations: Multi-device sync is a limitation. In a production roadmap, this would be addressed using a cryptographic sync protocol (like CRDTs over WebRTC or local storage synchronization with private end-to-end encrypted backup files).
- Tradeoff: The AI Eco-Coach leverages a local priority-weighted rule engine instead of calling remote Generative AI APIs (e.g. OpenAI GPT-4).
- Why:
- Resource Efficiency: Zero network overhead, zero latency, and zero token costs.
- Security: Zero danger of exposing sensitive user logs to third-party APIs.
- Reliability: No possibility of LLM hallucinations; recommendations are scientifically validated against local calculations.
If EcoTrace achieved 1 million active users who each reduced their footprint by just 5%:
- Average footprint: ~4 tonnes COβe/year
- 5% reduction: 200 kg COβe/user/year
- Total: 200,000 tonnes COβe avoided per year
- Equivalent to taking ~43,000 cars off the road
MIT License β see LICENSE for details.
Built for the Prompt War Hackathon 2024 β Vertical: Environmental Sustainability