Hackathon submission for Hack2Skill PromptWars by Google for Developers Challenge vertical: Carbon Footprint Awareness
CO₂Track is an India-focused carbon footprint tracker designed to help individuals measure, analyze, and reduce their greenhouse gas emissions. The platform features Supabase authentication (Google & GitHub OAuth), a secure real-time relational database, Indian cultural adaptation (no beef/pork, local staples, and local transit), and AI-driven insights with monthly rate limiting.
This project was built for the Carbon Footprint Awareness vertical. The goal is to help individuals understand, measure, and actively reduce their carbon emissions through localized data-driven calculations and AI-powered recommendations.
To better fit the Indian context, the application logic was refactored:
- Zero Beef/Pork: Removed beef and pork entirely from calculation factors, forms, and recommendations.
- Indian Diet Options: Included mutton, chicken, fish, paneer/dairy, eggs, dal/pulses, rice + sabzi, veg thali, and fully plant-based food items.
- Indian Transit Modes: Integrated local transport options such as Metro, Auto Rickshaws, and 2-Wheelers (Petrol and Electric).
- Indian Energy Sources: Updated emissions calculation using the CEA India Grid baseline intensity, LPG (cooking gas), natural gas (PNG), kerosene, and rooftop solar.
All calculations use IPCC AR6 and EPA emission factors:
| Category | Source / Factor | Unit |
|---|---|---|
| Transport | IPCC AR6 WG3 / CEA India | kg CO₂ per km |
| Food | FAO / Poore & Nemecek (2018) | kg CO₂ per 150g serving |
| Energy | CEA India Grid Intensity 2022 (0.82 kg/kWh) | kg CO₂ per kWh |
| Shopping | Carbon Trust Product Footprinting | kg CO₂ per item |
CO₂Track uses Groq's llama-3.1-8b-instant model to deliver custom action plans:
- Injects the user's actual emission breakdown (transport, food, energy, shopping).
- Compares their total monthly footprint to India's national average (230 kg) and the global average (391.67 kg).
- Forces the model to address their highest-impact category first.
- Constrains output to 3 actionable, numbered recommendations under 60 words.
- Rate Limiting: Restricts users to 2 AI insight generations per calendar month to control API costs. Usage is securely tracked in the database.
The application uses Supabase (PostgreSQL) for state management. The schema contains the following tables:
profiles: Extends Supabase Auth users. Stores onboarding responses (diet, typical transport, electricity usage) and user details.emission_logs: Logs daily user activity across transport, food, energy, and shopping.challenge_state: Tracks accepted and completed weekly eco-challenges for gamification.ai_usage: Tracks monthly AI insights request count per user for rate limiting.
All tables are secured using PostgreSQL Row Level Security (RLS), ensuring users can only read/write their own records.
- Node.js (v18+)
- A Supabase account
- A Groq Console account
# Clone the repository
git clone https://github.com/your-username/ecotrack.git
cd ecotrack/ecotrack
# Install dependencies
npm install- Go to your Supabase Dashboard and create a New Project.
- Go to SQL Editor -> New Query.
- Copy the contents of
supabase/schema.sqlpaste them into the SQL Editor. - Click Run to create the tables, indexes, triggers, and Row-Level Security (RLS) policies.
Note: The script includes a trigger on_auth_user_created that automatically inserts a corresponding profile row whenever a new user signs up via OAuth.
CO₂Track utilizes GitHub OAuth for authentication.
- In the Supabase Dashboard, navigate to Authentication -> Providers.
- Configure GitHub:
- Enable the GitHub provider.
- Register a new OAuth application on GitHub Developer Settings.
- Copy the Client ID and Client Secret into the Supabase GitHub configuration.
- Set the Homepage URL to
http://localhost:5173and the Authorization callback URL to the Redirect URI provided by Supabase.
- In Supabase Authentication -> URL Configuration, set the site URL to
http://localhost:5173/(for local development).
- Copy the
.env.examplefile to.env:cp .env.example .env
- Open
.envand fill in the values:VITE_SUPABASE_URL: Your Supabase Project URL (found in Settings -> API).VITE_SUPABASE_ANON_KEY: Your Supabase project public anon key (found in Settings -> API).VITE_GROQ_API_KEY: Your Groq API key (found in console.groq.com).
npm run devOpen http://localhost:5173 to view the app!
1. Login Page
→ Sign in securely with Google or GitHub OAuth.
→ Profile name is fetched automatically from OAuth metadata.
2. Onboarding (3 steps)
→ Step 1 (Personal Info): Confirm name (prefilled) and location (default: India).
→ Step 2 (Transport & Diet): Select typical transport modes and diet type.
→ Step 3 (Home Energy): Enter average monthly electricity bill (kWh) and household size.
3. Dashboard
→ Animated carbon emissions count-up.
→ Comparison chart showing your emissions against India's and the Global average.
→ Interactive donut chart showing category breakdowns.
→ Logged activity history list.
4. Log Activity
→ Input transport distance, food servings, energy usage, or shopping items.
→ View instant, live carbon footprint previews before logging.
5. AI Insights
→ Generate 3 personalized action points tailored to your highest emission category.
→ Chat window for follow-up questions.
→ Displays remaining monthly requests (2 left).
6. Weekly Challenges
→ Earn badges and points by accepting and completing green challenges.
| Technology | Version | Why |
|---|---|---|
| React | 19 | Component-driven UI development and modern hook state management. |
| Vite | 8 | Lightning-fast development environment and HMR. |
| Supabase | 2 | Secure authentication, PostgreSQL relational database, and real-time operations. |
| Tailwind CSS | 3 | Utility-first styling with customized color palette design tokens. |
| Recharts | 3 | Responsive, interactive charts for dashboard metrics. |
| Groq API | Llama 3.1 8B | Fast, lightweight AI inference for personalized insights (optimized for free-tier rate limits). |
| Jest | 30 | Standard unit testing runner. |
The project enforces strict code quality and linting standards using ESLint:
- Zero Errors or Warnings: The codebase compiles with no warnings/errors under ESLint rules.
- Strict Lint Config: Rules ensure no unused variables, no undefined variables, and compliant React Hooks dependency arrays.
- Centralized Utils: Standardized logger (
logger.js), local storage access (storage.js), and user input sanitization (sanitize.js). - JSDoc & PropTypes: All utilities, hooks, and React components are comprehensively decorated with JSDoc annotations and enforced via
PropTypes.
# Run ESLint validation
npx eslint src/
# Run unit tests
npm test
# Run unit tests with coverage metrics (>80% target for utils and hooks)
npm run test:coverage
# Compile production build
npm run build
# Start preview server for production build
npm run previewMIT — see LICENSE