A real-time monitoring solution for managing restroom facilities with sensor tracking and automated alerts.
The dashboard provides real-time monitoring of:
Sensor Type | Default Threshold | Alert Condition |
---|---|---|
Soap Dispenser | 20% | Below threshold |
Paper Towel 1 | 20% | Below threshold |
Paper Towel 2 | 20% | Below threshold |
Paper Towel 3 | 20% | Below threshold |
Dustbin | 80% | Above threshold |
Clone the repository
git clone https://github.com/yourusername/smart-restroom-monitoring.git
cd smart-restroom-monitoring
Install dependencies ```bash
cd backend npm install
cd ../frontend npm install
3. Configure environment variables
```bash
# Backend (.env)
MQTT_HOST=localhost
MQTT_PORT=1883
MQTT_PROTOCOL=mqtt
MQTT_RECONNECT_PERIOD=5000
DB_USER=postgres
DB_HOST=localhost
DB_DATABASE=smart_restroom
DB_PASSWORD=your_password
DB_PORT=5432
SERVER_PORT=3000
# Frontend (.env)
REACT_APP_API_URL=http://localhost:3000
REACT_APP_WS_URL=ws://localhost:3000
Initialize the database
psql -U postgres -d smart_restroom -f init.sql
Start the services ```bash
cd backend npm start
cd frontend npm start
## Component Structure
### Frontend Components
src/ ├── components/ │ ├── Dashboard/ │ │ ├── index.jsx │ │ ├── SensorCard.jsx │ │ └── AlertList.jsx │ ├── ui/ │ │ ├── Card.jsx │ │ └── Progress.jsx │ └── Header.jsx ├── App.jsx └── index.jsx
### Backend Structure
backend/ ├── config/ │ └── thresholds.js ├── controllers/ │ └── alertController.js ├── models/ │ └── Alert.js ├── services/ │ ├── alertService.js │ └── sensorService.js ├── routes/ │ └── alertRoutes.js └── server.js
## API Endpoints
### Alerts
- `GET /api/alerts` - Get all active alerts
- `PUT /api/alerts/:id/resolve` - Resolve a specific alert
### WebSocket Events
- `sensorUpdate` - Real-time sensor data updates
- `alert` - Real-time alert notifications
## Contributing
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request
## License
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
## Acknowledgments
- Shadcn UI for React components
- Tailwind CSS for styling
- MQTT.js for sensor communication
- WebSocket for real-time updates