The IoT Smart Parking System is a modern solution that combines IoT sensors, real-time monitoring, and user management to create an efficient parking management system. The system uses WebSocket technology for real-time communication between sensors and clients, providing instant updates on parking slot availability and status changes. The system is hosted on Microsoft Azure Virtual Machine for reliable cloud infrastructure.
- Real-time Monitoring: Live updates of parking slot status using WebSocket
- User Authentication: Secure JWT-based authentication system
- Slot Management: Advanced booking and management of parking slots
- IoT Integration: Direct communication with IoT sensors
- Automated Status Updates: Real-time updates of slot occupancy
- Vehicle Tracking: Track vehicles and their parking status
- Logging System: Comprehensive system logging for monitoring and debugging
- Cloud Hosting: Deployed on Microsoft Azure VM for scalability and reliability
- Backend: Node.js, Express.js
- Database: MongoDB with Mongoose ODM
- Real-time Communication: WebSocket (ws) & Socket.IO
- Authentication: JWT (JSON Web Tokens)
- Logging: Winston Logger
- Security: CORS, Environment Variables
- Cloud Platform: Microsoft Azure Virtual Machine
The system consists of three main components:
- IoT Sensors: Connected via WebSocket for real-time status updates
- Backend Server: Handles business logic and data management, hosted on Azure VM
- Client Applications: Receive real-time updates via Socket.IO
- Node.js (v16.20.1 or higher)
- MongoDB
- npm or yarn package manager
- Microsoft Azure account (for deployment)
-
Clone the repository:
git clone https://github.com/devdaim6/iot-smart-parking-backend.git cd iot-smart-parking
-
Install dependencies:
npm install
-
Create a
.env
file in the root directory with the following configurations:# MongoDB MONGO_URI=your_mongodb_connection_string # JWT JWT_SECRET=your_jwt_secret_key JWT_EXPIRES_IN=90d # Server PORT=5000 # Client CLIENT_URL=http://localhost:3000
-
Start the server:
# Development mode npm run dev # Production mode npm run prod
POST /api/auth/register
POST /api/auth/login
GET /api/slots
GET /api/slots/available
POST /api/slots/book
POST /api/slots/release
// Sensor Events
'sensorData' - Receives sensor status updates
'PARKING_UPDATE' - Broadcasts parking status changes
'INITIAL_STATE' - Sends initial parking state to clients
// Error Events
'PARKING_ERROR' - Broadcasts parking-related errors
'ERROR' - General error broadcasts
- Username
- Password (hashed)
- Mobile number
- Vehicle number
- Role (user/admin)
- Parking status
- Booking history
- Slot number
- Status (available/occupied/parked)
- Sensor ID
- Booking information
- Vehicle information
- Timestamp data
- JWT Authentication
- Password Hashing
- CORS Protection
- Environment Variable Security
- Error Handling Middleware
- Input Validation
The system uses Winston logger for comprehensive logging:
- Error logs:
error.log
- Combined logs:
combined.log
The system implements a centralized error handling mechanism with:
- Custom error classes
- HTTP status codes
- Operational vs Programming errors
- Error logging
To contribute to the project:
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
- Set up environment variables
- Configure MongoDB connection
- Set up SSL/TLS certificates
- Configure CORS settings
- Enable production logging
- Deploy using PM2 or similar process manager
This project is licensed under the MIT License - see the LICENSE file for details.
For support, email daimdev6+iot+support@gmail.com