Inspiration

The idea for Carbon Guard was born out of a shared concern for climate change and a desire to empower individuals to take action. While many care about the planet, few have tools to quantify their personal environmental impact. Our goal was to create a personalized, data-driven platform that makes environmental responsibility tangible and actionable, enhanced with machine learning-powered insights.

What it Does

Carbon Guard provides a comprehensive platform for personal carbon footprint management:

  • Personalized Carbon Footprint Calculation: Users can input various daily activities and lifestyle choices (e.g., diet, transportation, energy usage, consumption habits) through an intuitive form. Our integrated Machine Learning model (Flask API) then processes this data to provide an accurate estimate of their monthly carbon emissions in kilograms.
  • Detailed Insights and Breakdown: Beyond a single number, the application offers a detailed breakdown of the carbon footprint by categories such as "Personal Information," "Transportation," "Lifestyle," "Waste & Consumption," and "Home Energy." This helps users understand which areas contribute most to their environmental impact.
  • Actionable Recommendations: Based on the calculated footprint and category contributions, the system generates personalized recommendations to help users reduce their emissions. These recommendations are dynamic and tailored to the user's specific habits.
  • Historical Tracking and Trends: All submitted carbon data is saved, allowing users to view their historical emissions, track their progress over time, and see monthly trends.
  • Comparison with Averages: Users can compare their carbon footprint against global and country averages, providing context to their impact.
  • User Profile Management: Secure user registration and login, with options to manage personal information and notification preferences.
  • Responsive Design: The frontend is built with Next.js and Tailwind CSS, ensuring a seamless experience across various devices.

Model: CatBoost Regressor

We use CatBoost, a gradient boosting framework by Yandex, which offers the following advantages:

  • Built-in categorical handling using target-based encoding
  • No need for one-hot encoding or manual label processing
  • Fast training and high accuracy on structured/tabular data
  • Works well even with small-to-medium datasets

What We Learned

Building Carbon Guard was a significant learning experience across multiple domains. On the technical front, we deepened our understanding of:

  • Full-Stack Integration: Mastering the seamless communication between a Next.js frontend, a Node.js/Express backend, and a Python Flask API. This involved intricate routing, API design, and ensuring data consistency across different services.
  • Machine Learning Deployment: We learned the nuances of deploying a CatBoost regression model within a Flask API, including data preprocessing, handling categorical features, and generating SHAP-based explanations for model predictions. This was crucial for providing meaningful insights beyond just a number.
  • Authentication and Authorization: Implementing robust JWT-based authentication in the Node.js backend was a key learning, ensuring secure user data and protected API routes.
  • State Management in React: Efficiently managing complex form states and integrating asynchronous API calls with React hooks (useState, useEffect, useRouter) was a continuous learning curve.

Beyond technology, we gained insights into the complexities of environmental data and the importance of clear, actionable recommendations for behavioral change.

How We Built Our Project

The project was built using a modular approach, separating concerns into distinct services:

  1. Next.js Frontend (app/): Developed with React and Next.js (App Router) for a dynamic and responsive user interface. It handles user authentication (login/signup), the carbon footprint input form, and displays insights and dashboard data. Tailwind CSS and Shadcn/UI components were used for styling and UI consistency. The frontend directly calls the Flask API for immediate predictions and insights upon form submission, providing a snappy user experience.
  2. Node.js/Express Backend (backend/): This serves as the central API gateway and data persistence layer. It manages user authentication, stores user profiles, and saves carbon footprint data to a MongoDB database. It also acts as an intermediary for retrieving historical carbon data and, crucially, calls the Flask API to generate fresh insights for historical data, ensuring that the analysis is always up-to-date with the latest ML model.
  3. Python Flask API (flask-api/): This service is dedicated to the machine learning model. It hosts a pre-trained CatBoost Regressor model. It exposes two main endpoints:
    • /predict: Takes user input, preprocesses it by making pool of categorical values as needed by catboost framework , makes a carbon emission prediction, and generates SHAP-based category breakdowns, top individual feature contributions, and personalized recommendations.
    • /insights: Similar to /predict but specifically designed for generating insights from existing data, used by the Node.js backend.
  4. MongoDB Database: Used by the Node.js backend to store user accounts and their historical carbon footprint submissions.

Challenges We Ran Into

  1. Inter-Service Communication: Ensuring seamless and robust communication between the Next.js frontend, Node.js backend, and Flask API was complex. This involved correctly configuring CORS, handling environment variables for different deployment environments (local vs. production), and managing asynchronous calls. For instance, correctly setting NEXT_PUBLIC_API_URL and NEXT_PUBLIC_FLASK_API_URL for both browser-side and server-side rendering within Next.js.
  2. Data Schema and Mapping: The machine learning model in Flask expected specific feature names and data types. Mapping the frontend form data to the Flask API's expected input, and then mapping the Flask API's output back to the MongoDB schema, required meticulous attention to detail. Any mismatch could lead to prediction errors or data corruption.
  3. Machine Learning Model Integration: Beyond just getting a prediction, integrating the SHAP (SHapley Additive exPlanations) library in the Flask API to provide explainable AI insights was challenging. Calculating category-based importance and generating dynamic, relevant recommendations based on these insights required careful logic and iterative refinement.
  4. Error Handling and Fallbacks: Implementing comprehensive error handling across all three services, especially for the Flask API calls, was critical. Designing fallback mechanisms (e.g., simple carbon calculation if the ML model fails) ensured a more resilient user experience.

Accomplishments That We're Proud Of

We are particularly proud of several key accomplishments in building Carbon Guard:

  • Seamless Multi-Service Integration: Successfully integrating a Next.js frontend, a Node.js/Express backend, and a Python Flask ML API into a cohesive application was a significant achievement.
  • Intelligent Carbon Prediction with Explainable AI: Developing and deploying a machine learning model that not only predicts carbon emissions but also provides explainable insights using SHAP values is a core strength. This allows users to understand why their footprint is a certain value and what factors are most influential.
  • Comprehensive and Actionable Insights: The system's ability to generate personalized, category-based recommendations directly from the ML model's analysis is something we're very proud of. These aren't generic tips but are tailored to the user's specific data, making them much more impactful.
  • Robust Data Handling and Persistence: Establishing a secure and efficient data flow from the frontend, through the backend, to MongoDB, and ensuring data consistency and retrieval for historical analysis, showcases a strong foundation for data management.
  • User-Centric Design: From the intuitive form to the clear dashboard and insights visualizations, we focused on creating a user-friendly experience that empowers individuals to engage with their environmental impact effectively.

What's Next for Carbon Guard - ML Powered Carbon Footprint Tracker

Here’s what we’re planning next to make Carbon Guard even smarter:

Mobile Optimization

A fully responsive mobile version to help users track on-the-go and get real-time suggestions.

Smart Integrations

Planned integrations with:

  • Smart meters & EVs
  • Fitness/transport apps
  • Carbon offset services

Better Insights

Improved dashboards with trends, SHAP visualizations, and: $$\text{Future Emissions} = f(\text{Past Data}, \text{User Behavior})$$

Community Features

  • Carbon-saving challenges
  • Streaks, leaderboards, and rewards for eco-friendly habits

Built With

Share this project:

Updates