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.
| Route | What it does |
|---|---|
/activities | Five forms (vehicles, electricity, waste, food, indoor smoking) compute an emission value and post it to /api/activities |
/products | Scans a barcode, looks the product up, estimates its emissions and saves it through /api/products |
/footprint | Shows total emissions, the top five activities, a bar chart and a gauge |
/leaderboard | Ranks users and families by total emissions, lowest first |
/account | Creates 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.
-
Clone the repository and install dependencies.
git clone https://github.com/sundaram123krishnan/EcoLyf.git cd EcoLyf npm install -
Create a
.envfile withDATABASE_URL,GOOGLE_CLIENT_ID,GOOGLE_CLIENT_SECRETandAI_KEY. -
Create the database tables.
npx prisma migrate dev -
Start the development server.
npm run dev
Reference
| Area | Choice | Used for |
|---|---|---|
| Framework | SvelteKit 2, Svelte 5, TypeScript | Pages and API routes |
| Styling | Tailwind CSS, shadcn-svelte components | Interface |
| Data | PostgreSQL, Prisma 5 | Users, activities, families |
| Auth | Better Auth with Google OAuth | Sign-in and sessions |
| Charts | Chart.js | Emission bar chart |
| Scanning | @zxing/library, Open Food Facts API | Barcode lookup |
| AI | Hugging Face Inference API, Mistral-7B-Instruct-v0.3 | Reduction 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.