A RESTful API for tracking and managing carbon emissions from various daily activities — transport, energy, food, waste, and more.
Developed by Keshav Nandwal
The Carbon Footprint Tracker API enables users to log their daily activities and calculate their associated carbon emissions.
It helps individuals and organizations monitor, analyze, and reduce their environmental impact through data-driven insights.
- 🔐 User Authentication using JWT
- 📊 Activity Tracking (transport, food, waste, etc.)
- 📅 Emission History with user-based records
- 🧮 Summaries and category-wise breakdowns
- ⚙️ Modular Architecture for scalability
- 🧾 MongoDB Integration via Mongoose
- 🧰 Environment Configurations using
.env - 🐞 Centralized Error Handling middleware
- 🔄 Nodemon for live reloading during development
| Layer | Technology |
|---|---|
| Runtime | Node.js |
| Framework | Express.js |
| Database | MongoDB + Mongoose |
| Authentication | JWT (JSON Web Token) |
| Dev Tools | Nodemon, ESLint, Prettier |
| Env Config | Dotenv |
- Node.js (v16 or newer)
- MongoDB (local or Atlas)
- npm or yarn
git clone https://github.com/keshavnandwal2003/carbon-footprint-tracker-api.git
cd carbon-footprint-tracker-api
npm installCreate a .env file in the root directory:
PORT=5000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_secret_key(You can copy from .env.example if available.)
npm run devServer runs at:
👉 http://localhost:5000
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| POST | /api/v1/users/register |
Register new user | ❌ |
| POST | /api/v1/users/login |
User login & get JWT | ❌ |
| GET | /api/v1/footprints |
Get all user emissions | ✅ |
| POST | /api/v1/footprints |
Create new emission record | ✅ |
| DELETE | /api/v1/footprints/:id |
Delete an emission | ✅ |
| GET | /api/v1/footprints/summary |
Get category-wise total emissions | ✅ |
✅ requires Authorization header:
Authorization: Bearer <token>
carbon-footprint-tracker-api/
│
├── config/ # DB connection & app configuration
├── controllers/ # Business logic for each route
├── middleware/ # Authentication & error handling
├── models/ # Mongoose schemas
├── routes/ # Express route definitions
├── server.js # Application entry point
├── package.json
└── README.md
Contributions are welcome 💚
- Fork the repo
- Create a new branch
- Commit your changes
- Push to your branch
- Open a Pull Request
This project is licensed under the MIT License.
See the LICENSE file for details.
- Swagger/OpenAPI documentation
- Role-based access control
- PDF/CSV report export
- Monthly emission trends
- Frontend dashboard for analytics
💚 Let’s code for a cleaner, greener planet.