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).
- ๐ค 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
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
- Node.js 18+
- Python 3.8+
- MongoDB 4.4+
- Git
-
Clone the repository
git clone <repository-url> cd SmartWaste
-
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
-
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
-
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
-
Access the application
- Frontend: http://localhost:5173
- Backend API: http://localhost:3000
- API Documentation: http://localhost:3000/api
- AI Classifier: http://localhost:8001/apidocs
- Request Pickups - Schedule waste collection with photo uploads
- Track Status - Monitor pickup request status in real-time
- Location Services - Automatic GPS location detection
- Request Pickups - Schedule waste collection with photo uploads
- Track Status - Monitor pickup request status in real-time
- Location Services - Automatic GPS location detection
- Claim Pickups - Browse and claim available pickup assignments
- Contamination Alerts - Real-time notifications for contaminated waste
- Status Updates - Update pickup completion status
- 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
- Municipal Oversight - Monitor city-wide waste management
- Analytics Dashboard - Comprehensive waste management statistics
- System Administration - Full system control and configuration
- User Management - Manage all user accounts and permissions
- 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
- 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
- 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
- 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
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
The SmartWaste system includes a sophisticated AI model that analyzes waste images to detect contamination levels:
- 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
# Health check
GET http://localhost:8001/health
# Contamination prediction
POST http://localhost:8001/predict
Content-Type: multipart/form-data
Body: file (image file){
"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
}
}SmartWaste includes a comprehensive email notification system powered by EmailJS:
- 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 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
- 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
- Interactive Maps - Google Maps integration
- Pickup Locations - Visual pickup request locations
- Facility Locations - Recycling facility mapping
- Route Planning - Driver route optimization
- 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
- Pickup Statistics - Pickup request analytics
- Contamination Reports - Contamination level analysis
- User Activity - User engagement metrics
- Facility Performance - Recycling facility statistics
- JWT Tokens - Secure token-based authentication
- Role-based Access Control - Granular permission system
- Password Hashing - Bcrypt password encryption
- Session Management - Secure session handling
- Input Validation - Comprehensive input sanitization
- XSS Protection - Cross-site scripting prevention
- CSRF Protection - Cross-site request forgery prevention
- Secure Headers - Security headers implementation
- Rate Limiting - API rate limiting
- CORS Configuration - Cross-origin resource sharing
- Request Validation - Input validation middleware
- Error Handling - Secure error responses
cd frontend
npm run test # Run unit tests
npm run test:coverage # Run tests with coverage
npm run lint # Run ESLintcd 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 ESLintcd backend/classifier
python -m pytest # Run Python testscd frontend
npm run build
npx vercel --prodcd backend/waste-management
npm run build
# Deploy to your preferred platformcd backend/classifier
# Deploy Python Flask app# 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=productionPOST /auth/register # User registration
POST /auth/login # User login
POST /auth/refresh # Token refresh
POST /auth/logout # User logout
POST /auth/forgot-password # Password resetGET /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 pickupGET /facilities # Get all facilities
POST /facilities # Create facility
GET /facilities/:id # Get facility details
PUT /facilities/:id # Update facility
DELETE /facilities/:id # Delete facilityGET /users # Get all users
GET /users/:id # Get user details
PUT /users/:id # Update user
DELETE /users/:id # Delete userWe welcome contributions to SmartWaste! Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow TypeScript best practices
- Use ESLint and Prettier for code formatting
- Write comprehensive tests
- Document new features
- Follow conventional commit messages
- Provide a clear description of changes
- Include screenshots for UI changes
- Ensure all tests pass
- Update documentation as needed
- Request reviews from maintainers
- 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
- MongoDB Connection: Ensure MongoDB is running and accessible
- Environment Variables: Verify all required environment variables are set
- Port Conflicts: Check that ports 3000, 5173, and 8001 are available
- CORS Issues: Verify frontend and backend URLs are correctly configured
- 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