Skip to content

Yash200691/EcoTracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EcoTasker

A gamified, eco-focused web app that helps users track sustainable tasks, estimate carbon footprint, fetch environmental news, and earn rewards for green actions.

Highlights

  • User authentication and profiles (MongoDB + Express)
  • Task management with gamified points and leaderboard
  • Carbon footprint prediction using a Python model (PyCaret)
  • Environmental news fetcher (NewsAPI)
  • Green tips and actionable suggestions

Tech stack

  • Backend: Node.js, Express
  • Database: MongoDB (Mongoose)
  • Views: EJS templates
  • Frontend: static assets in public/ and views/
  • Machine learning: Python (PyCaret) model in model/

Repository structure

  • app.js — main/root server entry (Express app)
  • backend/app.js — alternative/expanded Express server with APIs and ML integration
  • backend/ — Python scripts and helpers (predictor.py, newsFetcher.py, suggestions.js, train_model.py)
  • model/ — trained ML artifacts loaded by predictor.py
  • public/ — static frontend assets (CSS, JS)
  • views/ — EJS templates for the UI
  • data/ — CSV and JSON data used for training or bootstrapping

Setup

Prerequisites:

  • Node.js (v16+ recommended)
  • Python 3.8+ (with required ML libraries)
  • MongoDB running locally (or update connection string)

Install Node dependencies:

npm install

Install Python dependencies (example):

python -m pip install pandas requests pycaret

Notes: PyCaret and some ML dependencies can be large and may require additional system packages. If you don't need ML features, you can skip installing PyCaret and the model/ usage.

Run

Start MongoDB (locally) then run:

npm start
# or
node app.js

By default the app listens on http://localhost:3000.

Key Endpoints & Usage

  • GET / — home (redirects to login or serves public/index.html depending on server file)
  • GET /login, POST /login — authentication
  • GET /signup, POST /signup — create account
  • GET /tasks, POST /tasks — task list and creation
  • POST /tasks/done — mark task complete (session-protected)
  • POST /api/complete — API endpoint to complete a task and award points (uses tasks.json + leaderboard.json in backend/)
  • POST /api/refresh-tasks — triggers Python task generation (ml_task.py) and refreshes tasks.json
  • POST /chat — sends input to model/predict.py and returns model reply
  • GET /get-news?q=... — fetches environmental news via newsFetcher.py (uses NewsAPI key)
  • POST /calculate — sends numeric inputs to backend/predictor.py to estimate carbon emissions

ML model notes

  • backend/predictor.py loads a PyCaret model from model/carbon_model and expects three numeric args: electricity, car, meat.
  • If the model is absent or fails, the code falls back to a simple heuristic calculation.
  • Training scripts (if present) are in backend/train_model.py or similar; check data/eco_user_behavior.csv for training data.

Configuration & Secrets

  • backend/newsFetcher.py currently contains an API key placeholder. Replace it with an environment variable or a secure secret manager before production.
  • MongoDB connection string is currently mongodb://localhost:27017/eco_auth in the server files — update for production environments.

Security & Privacy

  • Do not commit real API keys or credentials.
  • Validate and sanitize user inputs before executing external commands or Python scripts — the code currently spawns Python processes with passed arguments.

Suggested Project Name

EcoTasker — a clear, friendly name conveying eco-friendly task tracking and gamification.

Next steps (suggested)

  1. Extract secrets to environment variables and add a .env.example file.
  2. Add a requirements.txt for Python dependencies and/or a pyproject.toml for reproducible ML environment.
  3. Add tests (backend API unit tests) and a simple CI workflow.
  4. Harden input validation around Python subprocess calls.

License

Add a LICENSE file (MIT or your preferred license).


Generated from repository analysis on May 28, 2026.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages