How magicinuse/cnc-tank works
Main Components
• Frontend (Client):
• This is located in the “client” directory and built using React, Tailwind CSS, and Vite.
• It includes various UI components like the Dashboard, Configuration Menu, Real-time Console, Map, and File Comparison interface.
• It also employs Socket.IO client integration for real-time bidirectional communication.
• Backend (Server):
• Found in the “server” directory. It is built on Node.js with Express.
• It provides a RESTful API with multiple endpoints for commands, configuration updates, status polling, and firmware updates.
• It uses Socket.IO to manage real-time events and communications with the client.
• Microcontroller Integration (ESP32):
• The “_ESP32” folder contains firmware and code (e.g., machine.cpp, preferences.cpp, and mapping docs) for controlling the ESP32 microcontroller.
• This component represents the embedded system that directly drives and monitors the CNC machine, interfacing with GRBL settings.
Relationships and Data Flow
• The Frontend communicates with the Backend primarily via:
• HTTP/RESTful API calls for initiating commands, update processes, and configuration changes.
• WebSocket (Socket.IO) connections for real-time data such as machine status updates and real-time console feedback.
• The Backend, in turn, communicates with the ESP32 microcontroller:
• It sends commands (movement, configuration changes) and receives feedback/status updates.
• It also manages mapping and configuration via files and dedicated controllers (e.g., configController, movementController).
Architectural Patterns and Design Principles
• Separation of Concerns:
• The project cleanly separates the presentation layer (client) from the business logic and API (server) and the hardware interface (ESP32).
• MVC-Like Structure on the Backend:
• Controllers, routes, and configuration files indicate an organized structure for processing requests.
• Real-Time Communication:
• Integration of Socket.IO ensures low-latency, bidirectional communications between client and server.
• Modularization:
• Different directories for specific functionalities (e.g., components in the client, separate controllers in the server) enhance maintainability.
Technologies to Highlight
• Frontend: React, Tailwind CSS, Vite, and Socket.IO Client.
• Backend: Node.js, Express, Socket.IO server library, and Axios for API calls.
• Embedded: ESP32 microcontroller with GRBL firmware for CNC control.