How noobyco/ledx works
Main Components
• Browser Client: Representing the web application’s user interface (found in the public/ directory with index.html, main.html, and CSS assets).
• Node.js Server (Express.js): The core of the web application (app.js and package.json indicate the use of Node/Express). This handles user commands from the browser.
• MQTT Broker: A public MQTT broker (mqtt://broker.hivemq.com, as noted in the README) that serves as the message exchange intermediary.
• Raspberry Pi with Hardware Control: The hardware side managed by the Python script (Pi/led.py) that subscribes to MQTT topics and controls the LED.
Detail the Relationships and Data Flow
• The Browser Client sends HTTP requests to the Node.js server (for commands like turning the LED on/off).
• The Node.js server processes these commands and publishes corresponding messages on MQTT topics to the public broker.
• The Raspberry Pi, running the led.py script, subscribes to the relevant MQTT topic. When it receives a command (e.g., “on” or “off”), it triggers the LED hardware accordingly.
• Optionally, there could be feedback channels or status updates that, if implemented, would flow in reverse – from LED/Pi to the server, then to the client.
Architectural Patterns and Design Principles
• Microcontroller-based IoT design: Separating concerns between a web-based control interface and a physical device.
• Decoupling via Messaging: The MQTT broker decouples the Node.js application from the Raspberry Pi’s LED controller, promoting scalability and reliability.
• Separation of Frontend and Backend: The clear organization of static files under the public directory and backend logic in app.js indicate an MVC-like separation (even if informal).
Relevant Technologies and Frameworks
• Frontend: HTML, CSS (under public/), and potentially JavaScript driven by the Node.js server.
• Backend: Node.js and Express.js (as seen in package.json and app.js).
• Communication: MQTT protocol for messaging between the server and the Raspberry Pi.
• Hardware: Python3 script (Pi/led.py) interfacing with the LED (likely using a library such as RPi.GPIO or similar).