A full-stack MERN application empowering households to measure, track, and reduce their carbon footprint.
- Project Overview
- Key Features
- Tech Stack
- Quick Start
- Project Structure
- Documentation
- Development
- Deployment
- Contributing
ecoTrack is a comprehensive platform designed to help households understand and manage their environmental impact. Users can:
- Calculate their household carbon footprint based on energy consumption, transportation, waste, and consumption patterns
- Track historical trends and monitor progress over time
- Get Insights through personalized recommendations to reduce their carbon footprint
- Compare performance on leaderboards and participate in sustainability challenges
Administrators can:
- Analyze global emission trends and user demographics
- Manage emission factors for accurate calculations
- Monitor platform metrics and generate reports
- π Secure Authentication - JWT-based login/registration with role-based access control
- π Carbon Footprint Calculation - Instant COβe calculation from activity data
- π Trend Tracking - Visual dashboard showing historical footprint trends
- π― Personalized Recommendations - AI-driven suggestions to reduce carbon footprint
- π€ Profile Management - Secure password and profile updates
- π Global Analytics - Real-time leaderboards (Top/Bottom 10 performers)
- π Data Aggregation - Filter and analyze logs by region, home size, consumption patterns
- βοΈ Factor Management - Update emission factors for calculation accuracy
- π Dashboard - Comprehensive metrics and performance indicators
| Layer | Technology | Purpose |
|---|---|---|
| Frontend | Next.js 16, React 19, TypeScript | Modern, performant UI with server components |
| Backend | Node.js, Express.js 5 | Scalable RESTful API |
| Database | MongoDB | Flexible, persistent storage for user data |
| Cache/Leaderboard | Redis | High-speed Sorted Sets for real-time leaderboards |
| Validation | Zod | Runtime schema validation |
| Authentication | JWT, Bcrypt, RBAC | Secure auth and authorization |
| UI Components | Radix UI, TailwindCSS | Accessible, responsive design |
| Charts | Recharts | Data visualization |
| Containerization | Docker, Docker Compose | Easy deployment and environment consistency |
| Observability | Prometheus, Grafana, Node Exporter | Metrics collection and monitoring |
| CI / DevOps | Jenkins | Build automation and deployment orchestration |
- Node.js v18+
- npm or yarn
- MongoDB (local or Atlas)
- Redis (local or cloud)
- Docker & Docker Compose (optional, for containerized setup)
-
Clone the repository
git clone https://github.com/thissidemayur/ecoTrack.git cd ecoTrack -
Install dependencies
# Backend cd backend npm install # Frontend cd ../frontend npm install
-
Configure environment variables
Backend (
backend/.env):PORT=3000 NODE_ENV=development # Database MONGODB_URI=mongodb://localhost:27017/ecotrack # Redis REDIS_URL=redis://localhost:6379 # JWT JWT_SECRET=your_jwt_secret_here JWT_EXPIRY=7d # Admin credentials ADMIN_EMAIL=admin@ecotrack.com ADMIN_PASSWORD=your_secure_password
Frontend (
frontend/.env.local):NEXT_PUBLIC_API_URL=http://localhost:3000/api
-
Start services
Option A: Using Docker Compose
docker-compose up
Option B: Manual startup
# Terminal 1: Start Backend cd backend npm run dev # Terminal 2: Start Frontend cd frontend npm run dev
-
Access the application
- Frontend: http://localhost:3000
- Backend API: http://localhost:3000/api
ecoTrack/
βββ backend/ # Express.js API server
β βββ src/
β β βββ config/ # Database & Redis configuration
β β βββ controllers/ # HTTP request handlers
β β βββ middleware/ # Auth, validation, error handling
β β βββ models/ # Mongoose schemas
β β βββ repositories/ # Database abstraction layer
β β βββ routes/ # API route definitions
β β βββ services/ # Business logic & orchestration
β β βββ utils/ # Helpers & utilities
β β βββ validators/ # Zod validation schemas
β β βββ app.js # Express app setup
β β βββ index.js # Server entry point
β βββ API.md # Complete API documentation
β βββ ARCHITECTURE.md # System design & environmental logic
β βββ deploy.md # Deployment guide
β βββ package.json
β βββ Dockerfile
β βββ .env # Environment variables (git ignored)
β
βββ frontend/ # Next.js application
β βββ src/
β β βββ app/ # Next.js 14 App Router
β β βββ components/ # Reusable React components
β β βββ lib/ # Utilities & helpers
β β βββ hooks/ # Custom React hooks
β β βββ store/ # Zustand state management
β β βββ styles/ # TailwindCSS configuration
β βββ public/ # Static assets
β βββ package.json
β βββ tsconfig.json
β βββ next.config.js
β βββ .env.local # Environment variables (git ignored)
β
βββ docker-compose.yml # Multi-service Docker orchestration
βββ task-definition.json # AWS ECS task definition
βββ README.md # This file
For detailed information, refer to the following documents:
- API.md - Complete REST API reference with request/response examples
- ARCHITECTURE.md - System design, Service-Repository pattern, calculation logic
- deploy.md - Production deployment guide
- README.md - Frontend setup and development guide
cd backend
# Development server with hot reload
npm run dev
# Production build
npm run build
# Start production server
npm start
# Run tests
npm testcd frontend
# Development server
npm run dev
# Production build
npm run build
# Start production server
npm start
# Lint code
npm run lint- Service-Repository Pattern: Clean separation between business logic (Services) and data access (Repositories)
- Centralized Error Handling: All errors flow through middleware for consistent responses
- Zod Validation: Runtime schema validation for all user inputs
- RBAC: Role-based access control for protected routes
- Redis Leaderboards: Real-time performance tracking using Sorted Sets
# Build all services
docker-compose build
# Run services
docker-compose up
# Stop services
docker-compose down
# View logs
docker-compose logs -fFor production deployment instructions, see backend/deploy.md.
This repository also includes DevOps and monitoring tooling for a full production-ready deployment:
- Prometheus for metrics scraping
- Grafana for dashboards and visualizations
- Node Exporter for host-level monitoring
- Jenkins for CI/CD and build automation
The docker-compose.yml includes local orchestration for the app plus monitoring services. A Terraform configuration is provided in terraform/ to provision AWS infrastructure:
- EC2 instance running the application stack
- Security Group with rules for SSH, HTTP/HTTPS, frontend, backend, Jenkins, Prometheus, Grafana, and Node Exporter
- AWS region and credentials configured via
terraform/variables.tfandterraform/terraform.tfvars
Supported Platforms:
- AWS (EC2 + Terraform provisioning)
- Vercel (Frontend)
- Heroku
- DigitalOcean
- Railway
The carbon footprint calculation follows the Greenhouse Gas Protocol (GHG) standard:
Categories:
- Energy - Electricity, gas, heating oil consumption
- Transportation - Car mileage, public transport usage
- Waste - Landfill waste, recycling rates
- Consumption - Food, clothing, goods purchases
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the ISC License - see the LICENSE file for details.
GitHub ID: @thissidemayur
- GitHub Repository: thissidemayur/ecoTrack
- Live Deployment: ecotrack.thissidemayur.me
- API Documentation: Backend API.md
For issues, feature requests, or questions:
- Open an issue on GitHub
- Check existing documentation in
backend/API.mdandbackend/ARCHITECTURE.md