How ammaar-alam/doorunlocker works
Main Components
• Hardware & IoT Device:
• Arduino Nano ESP32 Connect loaded with various Arduino sketches (e.g., ble_control.ino, doorOpener.ino, wifi-diagnosis.ino).
• Attached hardware components such as the L298N Motor Driver and 24V DC Motor.
• Integration with Arduino IoT Cloud for connectivity (both WiFi and BLE options).
• Backend Server:
• Built using Node.js and Express.js (evident both in the root server.mjs and the backend/proxyServer directory).
• Exposes RESTful API endpoints (/login, /command, /emergency-close, /status) for controlling and monitoring the door.
• Client Applications:
• iOS Application (“Ammaar’s Dorm Controls” folder), which uses Swift with a structured MVC-like pattern (with Views, ViewModels, Models, Services, and Assets).
• A web interface front-end coming from the “public” folder (HTML, CSS, JS) that supports door control features.
• Supporting Documentation & Configuration:
• Docs folder outlining API guides, troubleshooting, and user documentation.
• Environment configuration files such as .env.example and package.json for dependency management.
Interactions and Data Flow
• User Interaction:
• End users interact through either the iOS app or the web interface, which send API requests (via HTTP/REST) to the backend server.
• Backend Processing:
• The Node.js backend, upon receiving API requests, processes authentication (JWT authentication), door command logic, and status reports.
• A separate “proxyServer” may manage specific task routing, possibly acting as a relay between different segments.
• IoT Connectivity:
• The backend communicates with the Arduino IoT Cloud (or directly with the hardware, depending on configuration) to relay commands.
• The Arduino sketches on the ESP32 device then drive the physical motor through the motor driver.
• There is also support for BLE for local operations – think of it as an alternative flow that bypasses some internet layers for a quicker local control.
Important Architectural Patterns and Technologies
• Client-Server Architecture is central:
• Loose coupling between the frontend (iOS app and web UI) and backend REST API.
• Clear separation of concerns:
• iOS client has dedicated ViewModels, Views, and Services that abstract the REST interactions.
• The Node.js server manages business logic, API routing, and IoT connectivity.
• IoT Integration Pattern:
• The physical door control system (Arduino + motor driver) works as an edge device that receives commands through the cloud (Arduino IoT Cloud) and local BLE.
• Utilization of JWT for secure authentication in API calls.
• Use of standard configuration files (like .env and package.json) to orchestrate the system.
• Incorporate labels for important technologies (Node.js/Express.js, Arduino IoT Cloud, Swift, BLE).
• Provide annotations on API endpoints and additional notes on security and configuration.