Skip to content

PranshuBasak/carbon_footprint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Carbon Companion AI

Tagline: Your friendly climate coach for understanding, tracking, and reducing your daily carbon footprint.


1. Challenge Vertical & Project Overview

  • Vertical: Sustainability / Climate Tech
  • Problem Statement: Most carbon footprint calculators are either overly complex, require extensive user input, or feel judgmental. This creates friction, causing users to abandon the assessment before taking any actionable steps.
  • Solution Overview: Carbon Companion AI is a lightweight, interactive web app that functions as an AI-style sustainability coach. It calculates daily-life carbon footprints (Home Energy, Transport, Food, Flights, Waste, and Shopping) through a friendly 5-minute assessment, identifies the user's primary emission contributor, generates personalized recommendations, tracks weekly progress, and features Terra, a rule-based AI companion to guide users on their journey.

2. Key Features

  • Interactive Assessment: Grouped, highly accessible questionnaire focusing on lifestyle inputs.
  • Results Dashboard: Custom visual representations of emissions via an SVG Donut Eco Score and CSS breakdown bars.
  • AI Companion (Terra): A rule-based companion with built-in intent detection (using natural keywords) to answer lifestyle questions and provide support without external server calls.
  • Personalized Recommendations: Custom suggestions sorted dynamically based on the user's highest emission category, budget preferences, and effort level.
  • Action Tracker: A checklist allowing users to mark tasks complete and track their weekly progress. Saved to browser localStorage.
  • What-if Simulator: Sliders and toggles to instantly visualize the impact of lifestyle modifications on monthly and yearly footprints.
  • Methodology Transparency: Displays all emission factors and calculation parameters in a structured table.

3. Tech Stack & Constraints

  • Core Technologies: HTML5 (semantic elements), CSS3 (custom properties/variables, responsive flexbox/grid), Vanilla JavaScript (deferred browser scripts).
  • Asset Strategy: Strictly inline SVG vectors. No external icon libraries or image assets.
  • Libraries/APIs: None. Built entirely with raw vanilla components (no React, Chart.js, Tailwind, or external LLM API).
  • Storage: Browser localStorage (runs completely locally).
  • Security/Privacy: Fully client-side. No logins, no analytics tracking, no personal information sent to servers.

4. Calculation Methodology & Demo Assumptions

The app uses a simplified activity × emission factor model.

Important

Demo Assumptions Notice: The factors listed below are educational averages and simplified for demo purposes. A production application would utilize region-specific, verified databases (like those from DEFRA, EPA, or IPCC).

Emission Factors Table

Category Activity Metric Factor (kg CO2e) Assumption Detail
Electricity Per kWh (monthly) 0.7 kg / kWh Divided by household size to find individual share
Transport Car (per km) 0.18 kg / km Average passenger car emissions
Transport Bike / Scooter 0.08 kg / km Medium-sized motorbike
Transport Bus 0.06 kg / km Transit bus passenger average
Transport Train 0.04 kg / km Electric/diesel commuter rail average
Transport Walk / Cycle 0.00 kg / km Zero emissions
Food Vegan (monthly) 80 kg Plant-based lifestyle baseline
Food Vegetarian (monthly) 100 kg Dairy and eggs included
Food Mixed Diet (monthly) 150 kg Average meat and vegetable consumption
Food High Meat (monthly) 220 kg Daily meat consumption heavy baseline
Waste Low recycling (monthly) 30 kg Mostly landfill waste
Waste Medium recycling (monthly) 18 kg Some sorting and composting
Waste High recycling (monthly) 10 kg Advanced composting and recycling
Shopping Low (monthly) 20 kg Minimal consumer goods and clothes
Shopping Medium (monthly) 45 kg Regular purchases
Shopping High (monthly) 90 kg Frequent new clothes, gadgets, and deliveries
Flights Flights taken (yearly) 250 kg / flight Short/medium haul flight average per passenger

Formulas

$$\text{Electricity Monthly } (kg) = \frac{\text{kWh} \times 0.7}{\text{Household Size}}$$ $$\text{Transport Monthly } (kg) = \text{Commute Distance (km)} \times \text{Commute Factor} \times 4.33$$ $$\text{Flights Monthly Average } (kg) = \frac{\text{Flights Per Year} \times 250}{12}$$ $$\text{Total Monthly Footprint } (kg) = \text{Electricity} + \text{Transport} + \text{Food} + \text{Waste} + \text{Shopping} + \text{Flights Monthly Average}$$ $$\text{Total Yearly Footprint } (kg) = \text{Total Monthly Footprint} \times 12$$


5. How to Run Locally

  1. Clone or download this repository.
  2. Open index.html directly in any web browser (no local server or compiler needed).
  3. Alternatively, host the root folder using a simple HTTP server (e.g. npx serve or Python's python -m http.server 8000).

6. Testing & Quality Evidence

The project includes a no-dependency Node.js test suite so evaluators can verify the core logic without installing a framework.

npm test

The test runner validates:

  • Calculator math for the demo profile, yearly/monthly totals, highest category, and Eco Score.
  • Edge cases such as invalid numeric input, unknown commute modes, zero totals, and high emissions.
  • Terra assistant intent detection across common user prompts and context-aware replies.
  • Personalized recommendation ordering by highest category, budget, and effort preference.
  • localStorage save/load/clear behavior, including corrupt JSON fallback.
  • Static accessibility checks for labels, heading order, and accessible-name alignment.

The code is intentionally split by responsibility:

  • js/namespace.js creates the single window.CarbonCompanion namespace.
  • js/data.js keeps emission factors, actions, and assistant copy.
  • js/calculator.js contains pure footprint calculations.
  • js/assistant.js contains rule-based intent and reply logic.
  • js/storage.js isolates browser storage.
  • js/dashboard.js, js/actions.js, and js/chat.js split rendering by feature.
  • js/simulator.js contains pure simulator math plus simulator rendering.
  • js/utils.js centralizes formatting, numeric coercion, and DOM helpers.

7. Challenge Compliance Checklist

  • Public GitHub Repository: Intended for public submission at https://github.com/PranshuBasak/carbon_footprint.
  • Single Branch: Work is kept on main.
  • Repository Size: Source files are lightweight static assets and no large media files are included.
  • No Dependencies: No runtime or dev dependencies are required; package.json only defines the test command.
  • No External APIs: Terra is rule-based and does not call an LLM or third-party service.
  • Privacy: No login, analytics, cookies, backend, or network data collection. User inputs remain in browser localStorage.

8. Accessibility & Performance

  • Contrast: Adheres to WCAG AAA/AA requirements using high-contrast dark green (#146c39) and slate charcoal (#1e293b) text against off-white surfaces.
  • Forms: Fully accessible using explicit <label for="..."> linking and validation guidelines.
  • Keyboard Friendly: Clean :focus-visible styling for form controls, navigation tabs, and buttons.
  • Load Speed: Extremely high performance due to pure static design with zero external network requests.

About

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors