Skip to content

Aaricacoding/EcoTrack-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

title EcoTrack AI
emoji 🌿
colorFrom green
colorTo green
sdk docker
pinned false

🌿 EcoTrack AI : Carbon Intelligence Platform

AI-powered carbon footprint calculator with ML predictions, Groq AI insights, anomaly detection, AR product scanner, carbon offset marketplace, and community leaderboard. Hack2Skill Challenge 3 submission.

Python FastAPI scikit-learn Tests License: MIT

πŸ”— Live Demo: https://ecotracka-i.netlify.app βš™οΈ Backend API: https://aaricacoding-ecotrack-ai.hf.space πŸ’» GitHub: https://github.com/Aaricacoding/EcoTrack-AI


What It Does

Feature Detail
4-Step Carbon Wizard Transport Β· Home Energy Β· Diet Β· Shopping β€” under 2 minutes
ML Trend Forecast Polynomial Ridge Regression β€” 6-month carbon trajectory
Anomaly Detection Isolation Forest detects unusual emission spikes in history
AI Insights Groq LLaMA generates personalised narrative footprint analysis
EcoBot AI Coach Multi-turn AI carbon coach β€” knows your exact footprint data
AR Carbon Scanner Point camera at product barcode β€” instant COβ‚‚ footprint overlay
Offset Marketplace 4 verified Indian carbon offset projects with real pricing
Community Leaderboard Anonymous global ranking with footprint distribution chart
Smart Dashboard Donut chart Β· comparison bars vs global/India benchmarks
Ranked Tips Personalised actions sorted by COβ‚‚ impact β€” highest savings first
Secure Accounts JWT + bcrypt authentication with IP rate limiting

Architecture

ecotrack-ai/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ core/        # config Β· security Β· database
β”‚   β”‚   β”œβ”€β”€ models/      # Pydantic schemas Β· SQLAlchemy ORM
β”‚   β”‚   β”œβ”€β”€ routers/     # auth Β· carbon Β· predictions Β· tips Β· insights
β”‚   β”‚   β”œβ”€β”€ services/    # carbon_calculator Β· ml_predictor Β· ai_insights Β· anomaly_detector
β”‚   β”‚   └── main.py      # FastAPI app Β· middleware Β· security headers
β”‚   β”œβ”€β”€ tests/
β”‚   β”‚   └── test_all.py  # 43 deterministic unit tests
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── .env.example
└── frontend/
    └── index.html       # Single-file SPA Β· 9 tabs Β· Chart.js Β· ARIA compliant

Quick Start

cd backend
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
uvicorn app.main:app --reload --port 8000
pytest tests/ -v --tb=short

API Endpoints

Method Endpoint Description
POST /api/auth/register Register new user
POST /api/auth/login Login and receive JWT
GET /api/auth/me Get current user profile
POST /api/carbon/calculate Calculate footprint (authenticated)
POST /api/carbon/calculate/anonymous Calculate footprint (no auth)
GET /api/carbon/history Get user calculation history
POST /api/predictions/forecast 6-month ML forecast
POST /api/tips/personalized Get ranked reduction tips
POST /api/insights/analyze Groq LLaMA footprint analysis
POST /api/insights/anomaly Isolation Forest anomaly detection
POST /api/insights/chat EcoBot multi-turn conversation
GET /health Health check

ML Models

Polynomial Ridge Regression (Trend Forecasting)

  • PolynomialFeatures(degree=2) + Ridge(alpha=1.0, random_state=42)
  • Captures realistic reduction curve β€” rapid early gains then plateau
  • Uses real DB history when available, simulated otherwise

Isolation Forest (Anomaly Detection)

  • IsolationForest(n_estimators=100, contamination=0.15, random_state=42)
  • Trains on user personal history β€” not global thresholds
  • Returns per-category z-scores and human-readable explanation

Security

Layer Mechanism
Passwords bcrypt via passlib
Auth HS256 JWT Β· 60-minute expiry
Validation Pydantic v2 strict schemas
Rate limiting slowapi Β· 5 reg/min Β· 10 login/min Β· 30 calc/min
Headers X-Frame-Options Β· HSTS Β· X-Content-Type-Options
Secrets Environment variables only Β· never hardcoded

Tests : 43 Passing

Class Coverage
TestTransportCalculation Zero input Β· petrol vs EV Β· flights
TestHomeCalculation Solar Β· per-capita scaling
TestDietCalculation Vegan vs omnivore Β· waste multiplier
TestRatingAndPercentile All 5 tiers Β· monotonicity Β· bounds
TestFullFootprint Total integrity Β· valid rating
TestMLPrediction Determinism Β· output length Β· non-negative
TestInputValidation Negative values Β· invalid enums
TestSecurity bcrypt Β· JWT roundtrip Β· tampered token
TestAnomalyDetection Spike detection Β· z-scores Β· determinism
TestInsightSchemas AI request response validation

Emission Factors

Category Factor Source
Petrol car 0.192 kg COβ‚‚e/km EPA 2023
EV India grid 0.053 kg COβ‚‚e/km CEA 2023
Electricity India 0.716 kg COβ‚‚e/kWh CEA 2023
Short-haul flight 255 kg COβ‚‚e/trip ICAO
Long-haul flight 1050 kg COβ‚‚e/trip ICAO
Vegan diet 1500 kg COβ‚‚e/yr Poore & Nemecek 2018
Global average 4000 kg COβ‚‚e/yr IPCC AR6
India average 1800 kg COβ‚‚e/yr World Bank

Tech Stack

Layer Technology
Backend FastAPI Β· Python 3.11 Β· Uvicorn
Database SQLAlchemy Β· SQLite
ML scikit-learn Β· numpy
AI Groq LLaMA 3.1 8B
Auth python-jose Β· passlib bcrypt
Frontend Vanilla JS Β· Chart.js Β· BarcodeDetector API
Deployment HuggingFace Spaces Β· Netlify
Testing pytest Β· 43 tests

License

MIT License : Built for Hack2Skill Challenge 3

About

🌿 AI-powered carbon footprint platform with ML predictions, Groq AI insights, anomaly detection and EcoBot coach. Built with FastAPI + scikit-learn.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors