Skip to content
ย 
ย 

Repository files navigation

SmartBin - Intelligent Waste Management System

A comprehensive full-stack application for managing smart waste bins with real-time monitoring, collection optimization, and user role management.

๐Ÿš€ Features

Core Functionality

  • Smart Bin Management: Create, monitor, and manage different types of waste bins
  • Real-time Fill Level Tracking: Monitor bin capacity in real-time
  • Collection Request System: Schedule and manage waste collection requests
  • Route Optimization: Optimize collection routes for efficiency
  • Role-based Access Control: Support for residents, collectors, and administrators

User Roles

  • Residents: Manage personal bins, create collection requests
  • Collectors: View all bins, manage collection schedules, update statuses
  • Administrators: Full system access, user management, analytics

๐Ÿ—๏ธ Architecture

Backend (Node.js/Express)

  • Clean Architecture: Service layer pattern with separation of concerns
  • RESTful API: Well-structured endpoints with comprehensive validation
  • Authentication: JWT-based authentication with role-based authorization
  • Database: MongoDB with Mongoose ODM and proper indexing
  • Error Handling: Centralized error handling with consistent responses
  • Validation: Comprehensive input validation and sanitization

Frontend (React)

  • Modern React: Functional components with hooks
  • Responsive Design: Mobile-first approach with Tailwind CSS
  • Route Protection: Private routes based on user roles
  • Interactive Maps: Real-time bin locations and route visualization
  • Dashboard Views: Role-specific dashboards with relevant data

๐Ÿ“ Project Structure

SmartBin/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ config/           # Configuration management
โ”‚   โ”‚   โ”œโ”€โ”€ constants/        # Shared constants and enums
โ”‚   โ”‚   โ”œโ”€โ”€ controllers/      # HTTP request handlers
โ”‚   โ”‚   โ”œโ”€โ”€ middlewares/      # Custom middleware (auth, validation, error)
โ”‚   โ”‚   โ”œโ”€โ”€ models/          # MongoDB schemas and models
โ”‚   โ”‚   โ”œโ”€โ”€ routes/          # API route definitions
โ”‚   โ”‚   โ”œโ”€โ”€ services/        # Business logic layer
โ”‚   โ”‚   โ””โ”€โ”€ server.js        # Application entry point
โ”‚   โ”œโ”€โ”€ .env.example         # Environment variables template
โ”‚   โ””โ”€โ”€ package.json
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ api/             # API client configuration
โ”‚   โ”‚   โ”œโ”€โ”€ components/      # Reusable React components
โ”‚   โ”‚   โ”œโ”€โ”€ pages/           # Page components
โ”‚   โ”‚   โ””โ”€โ”€ assets/          # Static assets
โ”‚   โ””โ”€โ”€ package.json
โ”œโ”€โ”€ API_DOCUMENTATION.md     # Complete API documentation
โ””โ”€โ”€ README.md

๐Ÿš€ Quick Start

Prerequisites

  • Node.js (v16 or higher)
  • MongoDB (local or cloud instance)
  • npm or yarn package manager

Installation

  1. Clone the repository

    git clone <repository-url>
    cd SmartBin
  2. Backend Setup

    cd backend
    npm install
    
    # Copy environment template and configure
    cp .env.example .env
    # Edit .env with your configuration
    
    # Start development server
    npm run dev
  3. Frontend Setup

    cd frontend
    npm install
    
    # Start development server
    npm run dev

Environment Configuration

Create a .env file in the backend directory:

# Server Configuration
PORT=5000
NODE_ENV=development

# Database
MONGO_URI=mongodb://127.0.0.1:27017/smartbin

# Authentication
JWT_SECRET=your-super-secret-jwt-key-here
JWT_EXPIRES_IN=7d

# Security
BCRYPT_ROUNDS=12
PASSWORD_MIN_LENGTH=6
USERNAME_MIN_LENGTH=3

# App Metadata
APP_NAME=SmartBin
APP_VERSION=1.0.0

๐Ÿ“š API Documentation

Comprehensive API documentation is available in API_DOCUMENTATION.md.

Key Endpoints

  • Authentication: /api/auth/login, /api/auth/register
  • Bins: /api/bins (CRUD operations, fill level management)
  • Collections: /api/collections (request management, status updates)
  • Users: /api/users/profile (profile management)
  • Admin: /api/admin (user management, system statistics)

๐Ÿƒโ€โ™‚๏ธ Development

Backend Development

cd backend
npm run dev  # Start with nodemon for auto-reload

Frontend Development

cd frontend
npm run dev  # Start Vite development server

Production Build

# Frontend
cd frontend
npm run build

# Backend
cd backend
npm start

๐Ÿงช Code Quality Features

Backend Best Practices

  • Service Layer Pattern: Business logic separated from HTTP concerns
  • Centralized Configuration: Environment-based configuration management
  • Input Validation: Comprehensive validation middleware
  • Error Handling: Global error handling with consistent responses
  • Security: JWT authentication, password hashing, input sanitization
  • Database: Proper indexing, schema validation, relationship management

Frontend Best Practices

  • Component Architecture: Reusable, modular components
  • State Management: Efficient state handling with React hooks
  • Route Protection: Role-based route access control
  • Responsive Design: Mobile-first responsive layouts
  • Performance: Code splitting and optimization

๐Ÿ”ง Configuration

Database Configuration

The application uses MongoDB with the following collections:

  • users: User accounts and authentication
  • bins: Waste bin information and locations
  • collectionrequests: Collection scheduling and management

Authentication & Authorization

  • JWT-based authentication
  • Role-based access control (RBAC)
  • Password hashing with bcrypt
  • Token expiration management

๐Ÿ”’ Security Features

  • Password encryption
  • JWT token authentication
  • Input validation and sanitization
  • Role-based access control
  • Environment variable protection
  • Error message sanitization

๐Ÿ“Š Monitoring & Analytics

  • Real-time bin fill level monitoring
  • Collection request tracking
  • System usage statistics
  • User activity analytics
  • Performance metrics

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/new-feature
  3. Commit changes: git commit -am 'Add new feature'
  4. Push to branch: git push origin feature/new-feature
  5. Submit a pull request

Code Style Guidelines

  • Follow ESLint configuration
  • Use meaningful variable and function names
  • Write comprehensive comments for complex logic
  • Follow the established project structure
  • Write unit tests for new features

๐Ÿ“ License

This project is licensed under the ISC License.

๐Ÿ“ž Support

For support and questions:

  • Create an issue in the repository
  • Check the API documentation
  • Review the code comments and documentation

๐Ÿ”ฎ Future Enhancements

  • Real-time notifications
  • Mobile application
  • IoT sensor integration
  • Advanced analytics dashboard
  • Automated route optimization
  • Integration with city waste management systems

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages