EcoLyf

Web application designed to track and reduce carbon footprints by monitoring daily activities.

Technovate 2.0

🎓 Sardar Patel Institute of Technology

📌 Mumbai, Maharashtra

🚀 24 hours Hackathon Project

What it is

EcoLyf is a web app that estimates a person's carbon footprint from daily activities. Users log activities such as driving or electricity use, scan product barcodes, and see their emissions as totals and charts. When the footprint is high, the app asks a language model for suggestions to reduce it. A leaderboard ranks users and families by emissions.

It was built in 24 hours at Technovate 2.0, a sustainability-themed hackathon.

How it works

EcoLyf is a SvelteKit app with a PostgreSQL database accessed through Prisma. Better Auth handles sign-in with Google. Page loaders and the activity and product routes reject requests without a session.

RouteWhat it does
/activitiesFive forms (vehicles, electricity, waste, food, indoor smoking) compute an emission value and post it to /api/activities
/productsScans a barcode, looks the product up, estimates its emissions and saves it through /api/products
/footprintShows total emissions, the top five activities, a bar chart and a gauge
/leaderboardRanks users and families by total emissions, lowest first
/accountCreates a family or joins one by family ID

The data model is small. An Activity row holds a name, an emission value, a timestamp and an isFood flag, and belongs to a User. A User can belong to one Family. Better Auth adds the Session, Account and Verification tables.

What I built

I built authentication and the Prisma integration, the product scanning and carbon-score pages, and the personal and family leaderboards with the account flows. Sundaram built the initial Svelte app, the activity, transport and waste forms, the footprint charts and the first version of the AI suggestions. We both edited the AI route.

Design decisions

Emission factors in the client. Each activity form multiplies the user's input by a constant, such as a per-fuel factor for vehicles or a per-type factor for waste. The server stores the result as given. This keeps the prototype simple. The trade-off is that the factors are scattered across components and the server cannot recompute them.

Eco-Score as a proxy for product emissions. The products page scans a barcode with @zxing/library and fetches the product from the Open Food Facts API. It then maps the product's Eco-Score grade (A to E) to a factor between 0.1 and 2.0 kg CO2e per kg and multiplies by the quantity. This gives a coarse estimate without per-product lifecycle data.

A hosted model behind a server route. The footprint page posts a prompt, with the user's activities in JSON, to /api/ai. That route calls the Hugging Face Inference API with Mistral-7B-Instruct-v0.3 and returns the text. The API key stays on the server. The prompt asks for short, actionable steps.

Families as a grouping. A Family entity groups users so the leaderboard can compare households as well as individuals.

Run it locally

Prerequisites: Node.js, a PostgreSQL database, a Google OAuth client and a Hugging Face token.

  1. Clone the repository and install dependencies.

    git clone https://github.com/sundaram123krishnan/EcoLyf.git
    cd EcoLyf
    npm install
    
  2. Create a .env file with DATABASE_URL, GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET and AI_KEY.

  3. Create the database tables.

    npx prisma migrate dev
    
  4. Start the development server.

    npm run dev
    

Reference

AreaChoiceUsed for
FrameworkSvelteKit 2, Svelte 5, TypeScriptPages and API routes
StylingTailwind CSS, shadcn-svelte componentsInterface
DataPostgreSQL, Prisma 5Users, activities, families
AuthBetter Auth with Google OAuthSign-in and sessions
ChartsChart.jsEmission bar chart
Scanning@zxing/library, Open Food Facts APIBarcode lookup
AIHugging Face Inference API, Mistral-7B-Instruct-v0.3Reduction suggestions

Outcome

  • EcoLyf was built at Technovate 2.0 on 2024-11-09 at the Sardar Patel Institute of Technology in Mumbai. The team had two members and did not place.
  • The repository has 75 commits between 2024-11-09 and 2024-11-10.
  • The repository belongs to the teammate's account, so the code lives at sundaram123krishnan/EcoLyf.

Liked EcoLyf? Here's my background.

Full-stack TypeScript, shipped to real users.