A comprehensive full-stack application for managing smart waste bins with real-time monitoring, collection optimization, and user role management.
- 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
- Residents: Manage personal bins, create collection requests
- Collectors: View all bins, manage collection schedules, update statuses
- Administrators: Full system access, user management, analytics
- 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
- 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
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
- Node.js (v16 or higher)
- MongoDB (local or cloud instance)
- npm or yarn package manager
-
Clone the repository
git clone <repository-url> cd SmartBin
-
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
-
Frontend Setup
cd frontend npm install # Start development server npm run dev
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.0Comprehensive API documentation is available in API_DOCUMENTATION.md.
- 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)
cd backend
npm run dev # Start with nodemon for auto-reloadcd frontend
npm run dev # Start Vite development server# Frontend
cd frontend
npm run build
# Backend
cd backend
npm start- 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
- 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
The application uses MongoDB with the following collections:
- users: User accounts and authentication
- bins: Waste bin information and locations
- collectionrequests: Collection scheduling and management
- JWT-based authentication
- Role-based access control (RBAC)
- Password hashing with bcrypt
- Token expiration management
- Password encryption
- JWT token authentication
- Input validation and sanitization
- Role-based access control
- Environment variable protection
- Error message sanitization
- Real-time bin fill level monitoring
- Collection request tracking
- System usage statistics
- User activity analytics
- Performance metrics
- Fork the repository
- Create a feature branch:
git checkout -b feature/new-feature - Commit changes:
git commit -am 'Add new feature' - Push to branch:
git push origin feature/new-feature - Submit a pull request
- 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
This project is licensed under the ISC License.
For support and questions:
- Create an issue in the repository
- Check the API documentation
- Review the code comments and documentation
- Real-time notifications
- Mobile application
- IoT sensor integration
- Advanced analytics dashboard
- Automated route optimization
- Integration with city waste management systems