back to work
2024 · full-stack · iot

Smart Waste.

stack
  • node.js
  • react
  • mongodb
  • k8s
  • terraform
status
built

README.md

dilrukshax/smart-waste-management

GitHub

🌍 Smart Waste Management System

A full-stack web application for managing waste collection: users register and submit special waste requests, admins allocate resources and manage requests from a dashboard, and collectors track assigned tasks. It supports real-time waste-level tracking, invoicing, role-based access, and a centralized API configuration.

A team project (see Contributors) built with Node.js/Express, React, MongoDB, and Redis, packaged with Docker, Kubernetes, and Terraform for deployment.

Project Status

Team coursework project; not under active development. Implemented: user/admin/collector flows, request management, invoicing (Stripe), and Docker/K8s/Terraform deployment manifests.

Note on deployment: the previously advertised homepage on Vercel is no longer reachable (returns 404) and has been removed from repository metadata. Run the application locally via Docker Compose (see Running with Docker).

Key Features

  • User management — registration, login, profile management, submission of special waste-collection requests
  • Admin dashboard — view, manage, and assign waste-collection requests; generate invoices; manage user access
  • Waste tracking — real-time waste-level tracking with visualizations of levels and collector assignments
  • Collector dashboard — task assignment and tracking for waste collectors
  • Payments — Stripe and PayPal integrations for invoicing
  • Validation and error handling — server-side Joi validation and client-side form validation

Roles

  • User — registers, logs in, and submits waste-collection requests
  • Admin — manages requests, invoices, analytics, and user access
  • Collector — views assigned tasks and reports completion

Architecture

Loading architecture diagram…

Diagram source
flowchart TD
    FE["React frontend (CRA)<br/>port 3000"] -->|REST API| BE["Express backend<br/>port 3001"]
    BE --> DB[(("MongoDB 6.0"))]
    BE --> Redis[("Redis 7 (cache)")]
    BE --> Stripe["Stripe / PayPal (payments)"]
    BE --> Firebase["Firebase (auth/integration)"]
    NGINX["nginx (reverse proxy)"] --> FE

Containers are orchestrated with Docker Compose (frontend, backend, MongoDB, Redis, nginx) and the same services are described in the k8s/ manifests for Kubernetes, with terraform/ defining the Azure infrastructure.

Technology Stack

  • Frontend: React (Create React App), react-router-dom, react-bootstrap, react-hook-form, zod, chart.js / react-chartjs-2, Firebase web SDK, Stripe and PayPal React SDKs
  • Backend: Node.js, Express, Mongoose, bcryptjs, jsonwebtoken, joi, stripe
  • Database: MongoDB 6.0 (schema initialized via init-mongo.js); Redis 7 for caching
  • Infrastructure: Docker, Docker Compose, Kubernetes manifests (k8s/), Terraform (terraform/)
  • Reverse proxy: nginx (Alpine)
  • CI: GitHub Actions (.github/)
  • Auth: JWT bearer tokens (server), Firebase (client)

Repository Structure

.
├── backend/
│   ├── server.js
│   ├── routes/        # Express route handlers
│   ├── models/        # Mongoose models
│   ├── middleware/
│   └── package.json
├── frontend/
│   ├── src/           # React app (react-scripts / CRA)
│   ├── public/
│   └── package.json
├── k8s/               # Kubernetes manifests (deployment, service, ingress, db, namespace)
├── terraform/         # Azure IaC (main.tf, outputs.tf)
├── .github/           # GitHub Actions workflows
├── .env.example       # backend/frontend env template
├── init-mongo.js      # MongoDB init script
├── docker-compose.yaml
├── nginx.conf
├── Dockerfile         # frontend image
├── DEPLOYMENT.md
└── README.md

Prerequisites

  • Docker and Docker Compose (recommended), or
  • Node.js 18+ and npm (for manual setup)
  • MongoDB 6.0 and Redis 7 (if not using Docker)

Getting Started

Manual setup

  1. Clone the repository:

    git clone https://github.com/dilrukshax/smart-waste-management
    cd smart-waste-management
    
  2. Install backend dependencies:

    cd backend
    npm install
    
  3. Install frontend dependencies:

    cd ../frontend
    npm install
    
  4. Configure the environment. Copy .env.example to .env at the repository root and fill in the placeholders (MongoDB URI, Redis URL, JWT secret, Stripe/PayPal keys, frontend/backend ports). The default backend port is 3001 and the frontend port is 3000.

  5. Start MongoDB and Redis locally (or use Docker: docker compose up -d mongor redis).

  6. Run the backend:

    cd ../backend
    npm run dev      # nodemon server.js, http://localhost:3001
    
  7. In a second terminal, run the frontend:

    cd frontend
    npm start        # CRA dev server, http://localhost:3000
    

    The frontend expects the backend API at http://localhost:3001 (configured via the centralized API config in frontend/src/config/api.js).

Running with Docker

The repository includes a docker-compose.yaml that brings up MongoDB, Redis, the backend, the frontend, and nginx:

docker compose up -d --build

Once running, the frontend is served through nginx on its configured port. See docker-compose.yaml for the mapped host ports and DEPLOYMENT.md for deployment details.

Kubernetes / Terraform

Kubernetes manifests are in k8s/ (deployment, service, ingress, database, namespace-config). Azure infrastructure is defined in terraform/ (main.tf, outputs.tf). Apply with kubectl apply -f k8s/ and terraform apply after configuring your Azure credentials and variables.

Environment Variables

.env.example documents all configuration keys (placeholders only):

NODE_ENV=development
PORT=3001
FRONTEND_PORT=3000
MONGODB_URI=mongodb://admin:password123@localhost:27017/smart_waste?authSource=admin
MONGODB_DATABASE=smart_waste
REDIS_URL=redis://localhost:6379
JWT_SECRET=your-super-secure-jwt-secret-key-here
# plus Stripe / PayPal / Firebase keys as needed

Do not commit real values.

Testing

The frontend CRA exposes npm test (react-scripts test). There is no backend test suite. Tests were not executed as part of this documentation update.

Deployment

Deployment notes are in DEPLOYMENT.md. The previously advertised Vercel URL is no longer reachable and was removed from repository metadata. Use Docker Compose or the Kubernetes/Terraform manifests for deployment.

Screenshots

Home Page

Home

Admin Dashboard

Admin Dashboard Admin Dashboard 2 Admin Dashboard 3

User Side

User User 2 User 3

Garbage Collect

Garbage Collect

Contributing

This is a team coursework project and not accepting external contributions.

License

No license file is present. This repository is a team project with multiple contributors (see Contributors); ownership has not been confirmed and no open-source license has been added. If you intend to reuse this code, first clarify ownership with the contributors.

Contributors

We'd like to thank all contributors to this project:

overview

Waste management platform with user registration, profile management, and special waste request submissions. Real-time monitoring of waste levels with visualised data drives resource allocation and collector assignments.

approach

Node.js and Express.js backend with MongoDB, React frontend. Production infrastructure built with Docker containerisation, Kubernetes orchestration, Nginx reverse proxy, and Terraform automation. Firebase for real-time data sync.