Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

13 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ—‘๏ธ SmartWaste - AI-Powered Waste Management System

๐ŸŒŸ Overview

SmartWaste is a web platform that uses a simple AI model to score waste contamination and streamline pickups between households, drivers, and recyclers. It helps reduce contamination by up to 30%, improving recycling efficiency and supporting Sustainable Cities (SDG 11).

๐ŸŽฏ Key Features

  • ๐Ÿค– AI-Powered Contamination Detection - Automatically analyzes waste images to detect contamination levels
  • ๐Ÿ“ฑ Multi-Role User System - Support for households, businesses, drivers, recyclers, councils, and admins
  • ๐Ÿš› Smart Pickup Management - GPS-enabled pickup requests with real-time tracking
  • ๐Ÿญ Facility Management - Comprehensive recycling facility management system
  • ๐Ÿ“ง Intelligent Notifications - Real-time email alerts for contamination detection
  • ๐Ÿ—บ๏ธ Interactive Maps - Google Maps integration for location-based services
  • ๐Ÿ’ฌ AI Assistant - Gemini AI-powered chat assistant for waste management advice
  • ๐Ÿ“Š Analytics Dashboard - Role-based dashboards with comprehensive statistics

๐Ÿ—๏ธ System Architecture

SmartWaste/
โ”œโ”€โ”€ ๐ŸŽจ Frontend (React + TypeScript)
โ”‚   โ”œโ”€โ”€ User Interface & Authentication
โ”‚   โ”œโ”€โ”€ Pickup Management System
โ”‚   โ”œโ”€โ”€ Facility Management
โ”‚   โ”œโ”€โ”€ AI Chat Assistant
โ”‚   โ””โ”€โ”€ Analytics Dashboard
โ”œโ”€โ”€ โš™๏ธ Backend (NestJS + MongoDB)
โ”‚   โ”œโ”€โ”€ RESTful API Services
โ”‚   โ”œโ”€โ”€ User Management & Authentication
โ”‚   โ”œโ”€โ”€ Pickup & Facility Management
โ”‚   โ”œโ”€โ”€ Notification System
โ”‚   โ””โ”€โ”€ File Upload & Cloudinary Integration
โ””โ”€โ”€ ๐Ÿง  AI Classifier (Python + Flask)
    โ”œโ”€โ”€ Contamination Detection Model
    โ”œโ”€โ”€ Image Processing Pipeline
    โ””โ”€โ”€ Machine Learning Scoring

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18+
  • Python 3.8+
  • MongoDB 4.4+
  • Git

Installation

  1. Clone the repository

    git clone <repository-url>
    cd SmartWaste
  2. Install dependencies

    # Install root dependencies
    npm install
    
    # Install backend dependencies
    cd backend/waste-management
    npm install
    
    # Install frontend dependencies
    cd ../../frontend
    npm install
    
    # Install AI classifier dependencies
    cd ../backend/classifier
    pip install -r requirements.txt
  3. Environment Configuration

    Backend (.env):

    # Database
    MONGODB_URI=mongodb://localhost:27017/smartwaste
    
    # JWT
    JWT_SECRET=your-super-secret-jwt-key
    JWT_EXPIRES_IN=7d
    
    # Email Configuration (EmailJS)
    EMAILJS_SERVICE_ID=your_service_id
    EMAILJS_TEMPLATE_ID=your_template_id
    EMAILJS_PUBLIC_KEY=your_public_key
    EMAILJS_PRIVATE_KEY=your_private_key
    MAIL_FROM=noreply@smartwaste.com
    MAIL_FROM_NAME=SmartWaste Team
    
    # Cloudinary
    CLOUDINARY_CLOUD_NAME=your_cloud_name
    CLOUDINARY_API_KEY=your_api_key
    CLOUDINARY_API_SECRET=your_api_secret
    
    # AI Classifier
    CONTAMINATION_API_URL=http://localhost:8001
    
    # Gemini AI
    GEMINI_API_KEY=your_gemini_api_key
    
    # Server
    PORT=3000
    NODE_ENV=development

    Frontend (.env):

    VITE_API_BASE_URL=http://localhost:3000
    VITE_GEMINI_API_KEY=your_gemini_api_key_here
  4. Start the services

    # Terminal 1: Start MongoDB
    mongod
    
    # Terminal 2: Start AI Classifier
    cd backend/classifier
    python model.py
    
    # Terminal 3: Start Backend
    cd backend/waste-management
    npm run start:dev
    
    # Terminal 4: Start Frontend
    cd frontend
    npm run dev
  5. Access the application

๐Ÿ‘ฅ User Roles & Features

๐Ÿ  Household Users

  • Request Pickups - Schedule waste collection with photo uploads
  • Track Status - Monitor pickup request status in real-time
  • Location Services - Automatic GPS location detection

๐Ÿข Small Business (SME)

  • Request Pickups - Schedule waste collection with photo uploads
  • Track Status - Monitor pickup request status in real-time
  • Location Services - Automatic GPS location detection

๐Ÿš› Drivers

  • Claim Pickups - Browse and claim available pickup assignments
  • Contamination Alerts - Real-time notifications for contaminated waste
  • Status Updates - Update pickup completion status

โ™ป๏ธ Recyclers

  • Facility Management - Manage recycling facility operations
  • Capacity Tracking - Monitor facility capacity and load
  • Waste Type Configuration - Configure accepted waste types
  • Inventory Management - Track incoming waste materials

๐Ÿ›๏ธ Council

  • Municipal Oversight - Monitor city-wide waste management
  • Analytics Dashboard - Comprehensive waste management statistics

๐Ÿ‘จโ€๐Ÿ’ผ Admin

  • System Administration - Full system control and configuration
  • User Management - Manage all user accounts and permissions

๐Ÿ› ๏ธ Technology Stack

Frontend

  • React 19 - Modern React with hooks and concurrent features
  • TypeScript - Type-safe development with full IntelliSense
  • Vite - Lightning-fast build tool and development server
  • Tailwind CSS - Utility-first CSS framework for rapid UI development
  • React Router - Declarative routing for single-page applications
  • React Hook Form - Performant forms with easy validation
  • Yup - Schema validation for form inputs
  • Axios - HTTP client with request/response interceptors
  • Lucide React - Beautiful, customizable SVG icons
  • React Hot Toast - Elegant toast notifications

Backend

  • NestJS 11 - Progressive Node.js framework for scalable server-side applications
  • MongoDB - NoSQL database for flexible data storage
  • Mongoose - Elegant MongoDB object modeling for Node.js
  • JWT - JSON Web Tokens for secure authentication
  • Passport - Authentication middleware for Node.js
  • Bcrypt - Password hashing for security
  • Cloudinary - Cloud-based image and video management
  • Nodemailer - Email sending capabilities
  • Handlebars - Template engine for email templates
  • Swagger - API documentation and testing interface

AI & Machine Learning

  • Python 3.8+ - Core AI development language
  • Flask - Lightweight web framework for AI services
  • NumPy - Numerical computing for image processing
  • PIL (Pillow) - Python Imaging Library for image manipulation
  • OpenCV - Computer vision and image processing
  • Scikit-learn - Machine learning algorithms
  • Google Gemini AI - Advanced AI for chat assistance

Development Tools

  • ESLint - Code linting and quality assurance
  • Prettier - Code formatting for consistency
  • Jest - Testing framework for JavaScript
  • TypeScript - Static type checking
  • Git - Version control and collaboration

๐Ÿ“ Project Structure

SmartWaste/
โ”œโ”€โ”€ ๐Ÿ“ฑ frontend/                    # React frontend application
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ components/            # Reusable UI components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ ui/               # Basic UI components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ layout/           # Layout components
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ProtectedRoute.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ pages/                # Page components
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ auth/            # Authentication pages
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ dashboard/       # Dashboard pages
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ pickups/         # Pickup management
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ facilities/      # Facility management
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ notifications/   # Notification center
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ profile/         # User profile
โ”‚   โ”‚   โ”œโ”€โ”€ contexts/             # React contexts
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ AuthContext.tsx  # Authentication state
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ LocationContext.tsx # Location services
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ThemeContext.tsx # Theme management
โ”‚   โ”‚   โ”œโ”€โ”€ services/             # API services
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ api.ts           # Axios configuration
โ”‚   โ”‚   โ”œโ”€โ”€ types/                # TypeScript definitions
โ”‚   โ”‚   โ”œโ”€โ”€ hooks/                # Custom React hooks
โ”‚   โ”‚   โ””โ”€โ”€ utils/                # Utility functions
โ”‚   โ”œโ”€โ”€ public/                   # Static assets
โ”‚   โ”œโ”€โ”€ package.json
โ”‚   โ””โ”€โ”€ vite.config.ts
โ”œโ”€โ”€ โš™๏ธ backend/                    # NestJS backend services
โ”‚   โ”œโ”€โ”€ waste-management/         # Main backend application
โ”‚   โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ admin/           # Admin management
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ auth/            # Authentication & authorization
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ cloudinary/      # Image upload service
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ common/          # Shared utilities
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ council/         # Council management
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ facility/        # Facility management
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ mail/            # Email services
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ notifications/   # Notification system
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ pickup/          # Pickup management
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ uploads/         # File upload handling
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ users/           # User management
โ”‚   โ”‚   โ”œโ”€โ”€ scripts/             # Database scripts
โ”‚   โ”‚   โ”œโ”€โ”€ test/                # Test files
โ”‚   โ”‚   โ””โ”€โ”€ package.json
โ”‚   โ””โ”€โ”€ classifier/               # AI contamination detection
โ”‚       โ”œโ”€โ”€ model.py             # Main AI model
โ”‚       โ”œโ”€โ”€ requirements.txt     # Python dependencies
โ”‚       โ””โ”€โ”€ ReadMe.md            # AI setup instructions
โ””โ”€โ”€ ๐Ÿ“„ README.md                  # This file

๐Ÿค– AI Contamination Detection

The SmartWaste system includes a sophisticated AI model that analyzes waste images to detect contamination levels:

Features

  • Real-time Analysis - Instant contamination scoring
  • Multi-class Classification - Clean, Low, Medium, High contamination levels
  • Feature Extraction - Saturation, color analysis, edge detection, entropy
  • Confidence Scoring - Probability distribution across contamination levels
  • RESTful API - Easy integration with web applications

API Endpoints

# Health check
GET http://localhost:8001/health

# Contamination prediction
POST http://localhost:8001/predict
Content-Type: multipart/form-data
Body: file (image file)

Response Format

{
  "label": "medium",
  "score": 0.58,
  "probs": {
    "clean": 0.05,
    "low": 0.22,
    "medium": 0.48,
    "high": 0.25
  },
  "features": {
    "sat": 0.31,
    "brown": 0.18,
    "dark": 0.09,
    "entropy": 0.54,
    "edge": 0.27
  }
}

๐Ÿ“ง Email Notification System

SmartWaste includes a comprehensive email notification system powered by EmailJS:

Features

  • Template-based Emails - Customizable email templates
  • Multi-recipient Support - Different emails for different waste types
  • Real-time Alerts - Instant notifications for contamination
  • Professional Templates - Branded email designs
  • Delivery Tracking - Monitor email delivery status

Email Types

  • Email Verification - User account verification
  • Password Reset - Secure password recovery
  • Contamination Alerts - Driver notifications for contaminated waste
  • Pickup Confirmations - Pickup request confirmations
  • System Notifications - General system alerts

๐Ÿ—บ๏ธ Location Services

GPS Integration

  • Automatic Location Detection - Browser-based GPS location
  • Address Validation - Google Maps address verification
  • Route Optimization - Optimal pickup routes for drivers
  • Geofencing - Location-based service areas

Map Features

  • Interactive Maps - Google Maps integration
  • Pickup Locations - Visual pickup request locations
  • Facility Locations - Recycling facility mapping
  • Route Planning - Driver route optimization

๐Ÿ“Š Analytics & Reporting

Dashboard Features

  • Role-based Analytics - Customized metrics for each user type
  • Real-time Updates - Live data synchronization
  • Performance Metrics - System performance monitoring
  • Trend Analysis - Historical data analysis

Available Reports

  • Pickup Statistics - Pickup request analytics
  • Contamination Reports - Contamination level analysis
  • User Activity - User engagement metrics
  • Facility Performance - Recycling facility statistics

๐Ÿ”’ Security Features

Authentication & Authorization

  • JWT Tokens - Secure token-based authentication
  • Role-based Access Control - Granular permission system
  • Password Hashing - Bcrypt password encryption
  • Session Management - Secure session handling

Data Protection

  • Input Validation - Comprehensive input sanitization
  • XSS Protection - Cross-site scripting prevention
  • CSRF Protection - Cross-site request forgery prevention
  • Secure Headers - Security headers implementation

API Security

  • Rate Limiting - API rate limiting
  • CORS Configuration - Cross-origin resource sharing
  • Request Validation - Input validation middleware
  • Error Handling - Secure error responses

๐Ÿงช Testing

Frontend Testing

cd frontend
npm run test          # Run unit tests
npm run test:coverage # Run tests with coverage
npm run lint          # Run ESLint

Backend Testing

cd backend/waste-management
npm run test          # Run unit tests
npm run test:e2e      # Run end-to-end tests
npm run test:cov      # Run tests with coverage
npm run lint          # Run ESLint

AI Classifier Testing

cd backend/classifier
python -m pytest     # Run Python tests

๐Ÿš€ Deployment

Frontend Deployment (Vercel)

cd frontend
npm run build
npx vercel --prod

Backend Deployment (Render/Railway)

cd backend/waste-management
npm run build
# Deploy to your preferred platform

AI Classifier Deployment (Railway/Heroku)

cd backend/classifier
# Deploy Python Flask app

Environment Variables for Production

# Database
MONGODB_URI=your_production_mongodb_uri

# JWT
JWT_SECRET=your_production_jwt_secret
JWT_EXPIRES_IN=7d

# Email
EMAILJS_SERVICE_ID=your_production_service_id
EMAILJS_TEMPLATE_ID=your_production_template_id
EMAILJS_PUBLIC_KEY=your_production_public_key
EMAILJS_PRIVATE_KEY=your_production_private_key

# Cloudinary
CLOUDINARY_CLOUD_NAME=your_production_cloud_name
CLOUDINARY_API_KEY=your_production_api_key
CLOUDINARY_API_SECRET=your_production_api_secret

# AI
CONTAMINATION_API_URL=your_production_ai_url
GEMINI_API_KEY=your_production_gemini_key

# Server
PORT=3000
NODE_ENV=production

๐Ÿ“š API Documentation

Authentication Endpoints

POST /auth/register     # User registration
POST /auth/login        # User login
POST /auth/refresh      # Token refresh
POST /auth/logout       # User logout
POST /auth/forgot-password # Password reset

Pickup Management

GET    /pickups         # Get all pickups
POST   /pickups         # Create pickup request
GET    /pickups/:id     # Get pickup details
PUT    /pickups/:id     # Update pickup
DELETE /pickups/:id     # Delete pickup
POST   /pickups/:id/claim # Claim pickup

Facility Management

GET    /facilities      # Get all facilities
POST   /facilities      # Create facility
GET    /facilities/:id  # Get facility details
PUT    /facilities/:id  # Update facility
DELETE /facilities/:id # Delete facility

User Management

GET    /users           # Get all users
GET    /users/:id       # Get user details
PUT    /users/:id       # Update user
DELETE /users/:id       # Delete user

๐Ÿค Contributing

We welcome contributions to SmartWaste! Please follow these guidelines:

Development Setup

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Add tests for new functionality
  5. Ensure all tests pass
  6. Commit your changes (git commit -m 'Add amazing feature')
  7. Push to the branch (git push origin feature/amazing-feature)
  8. Open a Pull Request

Code Standards

  • Follow TypeScript best practices
  • Use ESLint and Prettier for code formatting
  • Write comprehensive tests
  • Document new features
  • Follow conventional commit messages

Pull Request Guidelines

  • Provide a clear description of changes
  • Include screenshots for UI changes
  • Ensure all tests pass
  • Update documentation as needed
  • Request reviews from maintainers

๐Ÿ†˜ Support

Getting Help

  • Documentation: Check this README and inline code comments
  • Issues: Report bugs and request features via GitHub Issues
  • Discussions: Join community discussions in GitHub Discussions
  • Email: Contact support@smartwaste.com

Common Issues

  1. MongoDB Connection: Ensure MongoDB is running and accessible
  2. Environment Variables: Verify all required environment variables are set
  3. Port Conflicts: Check that ports 3000, 5173, and 8001 are available
  4. CORS Issues: Verify frontend and backend URLs are correctly configured

๐Ÿ”ฎ Roadmap

Upcoming Features

  • Mobile App - React Native mobile application
  • Real-time Notifications - WebSocket-based real-time updates
  • Advanced Analytics - Machine learning-powered insights
  • IoT Integration - Smart waste bin sensors
  • Blockchain Integration - Waste tracking on blockchain
  • Multi-language Support - Internationalization
  • Dark Mode - Theme customization
  • Offline Support - Progressive Web App features
  • Advanced AI Features - Enhanced contamination detection
  • API Rate Limiting - Advanced API protection

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages