Backend: Difference between revisions

From Rsewiki
Line 25: Line 25:




Communication Flow
=== Communication Flow ===


The backend acts as an intermediary between the frontend and the Tuype robot.
The backend acts as an intermediary between the frontend and the Tuype robot.


# The Tuype robot publishes data to specific MQTT topics through an MQTT broker.
# The Robobot publishes data to specific MQTT topics through an MQTT broker.
# The backend subscribes to relevant topics and receives incoming robot data.
# The backend subscribes to relevant topics and receives incoming robot data.
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.
Line 35: Line 35:


For interactions that require sending information or commands to the robot, the communication can also work in the opposite direction, with the backend publishing messages to the appropriate MQTT topics.
For interactions that require sending information or commands to the robot, the communication can also work in the opposite direction, with the backend publishing messages to the appropriate MQTT topics.
==== Model-View-Controller====


=== Authentication and Session Management ===
=== Authentication and Session Management ===

Revision as of 09:30, 13 October 2026

Backend

Introduction

The backend of the Robot Dashboard is responsible for managing communication between the frontend and the Robobot. It is developed using Node.js and Express, with MQTT handling communication with the robot and Socket.IO providing real-time updates to the frontend.

The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.

The backend consists of several files and components, each serving a specific purpose. Some files can be modified to customize the dashboard's functionality, while others contain core functionality and should generally remain unchanged to ensure the system operates correctly.

This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.

Backend Architecutre

The backend of the Robot Dashboard is built using Node.js and Express and acts as a communication layer between the Robobot and the frontend application.

The architecture consists of three main components:

  1. Express: Handles HTTP requests, including user authentication and session management.
  2. MQTT: Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.
  3. Socket.IO: Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.


Communication Flow

The backend acts as an intermediary between the frontend and the Tuype robot.

  1. The Robobot publishes data to specific MQTT topics through an MQTT broker.
  2. The backend subscribes to relevant topics and receives incoming robot data.
  3. The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.
  4. The frontend receives these updates and displays them in the corresponding dashboard widgets.

For interactions that require sending information or commands to the robot, the communication can also work in the opposite direction, with the backend publishing messages to the appropriate MQTT topics.

Model-View-Controller

Authentication and Session Management

The backend also manages dashboard access through a password-based authentication system.

When a user logs in, Express validates the provided password and creates a session. The session is maintained using a cookie, allowing the backend to recognize authenticated users during subsequent HTTP requests.

Project Structure

Configuration and Customization

Core files and Restrictions

Running the backend