Carbon0 - Track Your Purchasing Carbon Footprint

Python JavaScript Flask Chrome Extension SQLite Google Gemini MongoDB

Inspiration

Every day, millions of people shop online without realizing the environmental impact of their purchases. The carbon footprint of a product isn't just about the item itself—it includes manufacturing processes, materials used, shipping distances, and packaging waste. We were inspired to create Carbon0 to bring transparency to online shopping and empower consumers to make environmentally conscious decisions.

The idea came from recognizing that while many people want to reduce their carbon footprint, they lack the tools and information needed to make informed purchasing decisions. We wanted to bridge the gap between intention and action by providing real-time carbon footprint analysis directly in the browser, making sustainability accessible to everyone.

What it does

Carbon0 is a browser extension that transforms online shopping into a carbon-conscious experience. Here's what it does:

Real-time Product Analysis:

  • Captures product information from any e-commerce site using AI-powered screenshot analysis
  • Extracts key details like product name, price, brand, materials, shipping origin, and more
  • Uses Google Gemini AI to intelligently parse product pages and extract structured data

Carbon Footprint Calculation:

  • Searches the web for additional product information to fill data gaps
  • Transforms product data into structured carbon input format using LLM-powered transformation
  • Calculates CO2 emissions based on materials, manufacturing location, shipping distance, and packaging

Eco-Friendly Alternatives:

  • Provides up to 5 alternative products with lower carbon footprints
  • Shows comparative CO2 scores and explanations for each alternative
  • Allows users to add eco-friendly alternatives to their Carbon0 cart

Carbon Tracking:

  • Maintains a cart system to track carbon savings from choosing eco-friendly alternatives
  • Displays total carbon emissions reduced across all purchases
  • Provides a visual dashboard showing environmental impact

Seamless Integration:

  • Works on major e-commerce platforms (Amazon, Walmart, Etsy, Best Buy, Target, eBay)
  • One-click analysis directly from the product page
  • No need to leave the shopping site or manually input data

How we built it

Frontend (Browser Extension):

  • Built a Chrome/Edge extension using JavaScript
  • Implemented screenshot capture API to extract product information
  • Integrated Google Gemini API for AI-powered product data extraction
  • Created a user-friendly popup interface for displaying results
  • Built a cart system for tracking carbon savings

Backend (Flask Server):

  • Developed a RESTful API using Flask and Python
  • Integrated MongoDB for storing carbon reduction totals
  • Implemented CORS to allow extension-to-server communication
  • Created endpoints for product analysis, search, and carbon tracking

AI & Data Processing:

  • Used Google Gemini 2.5 Flash for image analysis and product information extraction
  • Implemented SerpAPI for web searching to find additional product details
  • Built Playwright-based web scraping to capture product screenshots
  • Created an LLM-powered transformation pipeline (transform.py) to convert product data into carbon calculation inputs

State Management & Workflow:

  • Designed a state machine (state.py) to track product analysis stages
  • Built helper functions (helper.py) to update state from product data
  • Created a search agent tool (search_agent_tool.py) that:
    • Searches Google for products
    • Takes screenshots of search results
    • Divides screenshots into parts for analysis
    • Uses Gemini to analyze product images and extract detailed information
    • Saves results as JSON files

Key Technologies:

  • Frontend: JavaScript, Chrome Extension API, HTML/CSS
  • Backend: Python, Flask, MongoDB, PyMongo
  • AI/ML: Google Gemini API, Langchain
  • Web Scraping: Playwright, SerpAPI, BeautifulSoup
  • Image Processing: Pillow (PIL), pytesseract
  • Data Storage: MongoDB, JSON file system

Challenges we ran into

1. AI Integration Complexity:

  • Initially struggled with Gemini API integration and parsing responses
  • Had to implement robust JSON extraction to handle various response formats
  • Solved by creating a _safe_load_json function with multiple fallback strategies

2. Screenshot Analysis:

  • Found that full-page screenshots were too large for OCR processing
  • Encountered "image too long" errors when trying to extract text
  • Solution: Divided screenshots into 5 parts and used Gemini vision API instead of OCR

3. State Management:

  • Complex state transitions between product data extraction, search, and transformation
  • Had to handle missing fields gracefully while maintaining data integrity
  • Implemented a TypedDict-based state system with clear stage transitions

4. Web Scraping Reliability:

  • Playwright navigation timeouts on slow-loading pages
  • Bot detection mechanisms blocking automated browsers
  • Solved by implementing multiple wait strategies, custom user agents, and browser fingerprint masking

5. Data Transformation:

  • Converting unstructured product data into structured carbon input format
  • Handling null values and missing information appropriately
  • Created a sophisticated LLM prompt template that enforces strict JSON output format

6. Frontend-Backend Communication:

  • CORS issues when extension tried to communicate with local server
  • Screenshot data being too large for direct transmission
  • Implemented proper CORS headers and used base64 encoding for images

7. Merge Conflicts:

  • Encountered Git merge conflicts when integrating features from different branches
  • Had to carefully resolve conflicts while preserving functionality
  • Learned to use git merge --abort when needed

Accomplishments that we're proud of

1. Seamless User Experience:

  • Created a one-click solution that works across multiple e-commerce platforms
  • Users can analyze products without leaving their shopping page
  • Intuitive interface that makes carbon footprint information accessible

2. Robust AI Integration:

  • Successfully integrated multiple AI models (Gemini for vision and text analysis)
  • Built a reliable pipeline that handles various product page formats
  • Created fallback mechanisms for when AI extraction fails

3. Comprehensive Data Pipeline:

  • Built an end-to-end system from product extraction to carbon calculation
  • Implemented state management that tracks progress through multiple stages
  • Created transformation logic that converts unstructured data into carbon inputs

4. Real-time Web Search Integration:

  • Integrated SerpAPI for Google searches
  • Built Playwright-based screenshot system that captures product information
  • Successfully analyzes multiple search results using Gemini vision API

5. Carbon Tracking System:

  • Built a cart system that tracks carbon savings
  • Created a dashboard showing total emissions reduced
  • Implemented MongoDB persistence for long-term tracking

6. Code Quality:

  • Implemented proper error handling throughout the application
  • Created modular, reusable components
  • Added comprehensive logging for debugging
  • Used type hints and TypedDict for better code reliability

7. Documentation:

  • Created clear API endpoints with proper error responses
  • Implemented environment variable management
  • Added helpful console logging for development

What we learned

Technical Learnings:

  • AI Integration: Learned how to effectively use vision models for product information extraction
  • Browser Automation: Gained expertise in Playwright for web scraping and screenshot capture
  • State Management: Understood the importance of proper state machines for complex workflows
  • LLM Prompting: Discovered techniques for getting structured outputs from language models
  • Error Handling: Learned to build robust systems with multiple fallback strategies

Product Development:

  • User Experience: Realized the importance of seamless integration—users want tools that don't interrupt their workflow
  • Data Quality: Learned that incomplete data is better than no data, but proper handling of missing fields is crucial
  • Performance: Discovered that dividing large images into parts improves processing speed and reliability

Team Collaboration:

  • Git Workflow: Learned to handle merge conflicts and manage feature branches effectively
  • API Design: Understood the importance of clear API contracts between frontend and backend
  • Debugging: Developed skills in tracing issues across multiple systems (extension → API → AI services)

Environmental Impact:

  • Carbon Calculation: Learned about the complexity of calculating carbon footprints accurately
  • Data Sources: Discovered the importance of reliable emission factor databases
  • User Behavior: Realized that making information visible can drive behavior change

What's next for Carbon0

Short-term Improvements:

  • Enhanced Carbon Calculation: Integrate with established carbon databases (DEFRA, Ecoinvent) for more accurate emission factors
  • More Platforms: Expand support to additional e-commerce sites and international markets
  • Better Alternatives: Improve the algorithm for finding eco-friendly alternatives using more sophisticated matching
  • User Profiles: Allow users to set preferences (e.g., prioritize local products, prefer certain materials)

Medium-term Features:

  • Historical Tracking: Build a dashboard showing carbon footprint trends over time
  • Social Features: Allow users to share their carbon savings and compare with friends
  • Product Database: Create a database of analyzed products to avoid re-analyzing the same items
  • Mobile App: Develop a mobile version for shopping on smartphones

Long-term Vision:

  • Partnerships: Collaborate with e-commerce platforms to integrate carbon scores directly into product listings
  • Certification: Work with environmental organizations to certify carbon scores
  • Marketplace: Create a marketplace specifically for low-carbon products
  • Education: Build educational content to help users understand carbon footprints and make better choices

Technical Enhancements:

  • Machine Learning: Train models specifically for carbon footprint prediction
  • Real-time Updates: Implement WebSocket connections for real-time carbon score updates
  • Offline Mode: Add offline capabilities for basic carbon calculations
  • API for Developers: Create a public API so other developers can integrate carbon tracking

Impact Goals:

  • Scale: Reach 100,000+ users within the first year
  • Carbon Reduction: Help users collectively reduce 1 million kg of CO2 emissions
  • Awareness: Raise awareness about the environmental impact of online shopping
  • Behavior Change: Measure and report on actual behavior changes driven by the tool

Carbon0 represents our commitment to making sustainability accessible and actionable. We believe that by providing transparent, real-time carbon footprint information, we can empower consumers to make choices that align with their values and contribute to a more sustainable future.

Built With

Share this project:

Updates

Submission history