<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://rsewiki.electro.dtu.dk/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Spring2026</id>
	<title>Rsewiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://rsewiki.electro.dtu.dk/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Spring2026"/>
	<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Special:Contributions/Spring2026"/>
	<updated>2026-10-29T01:16:00Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9240</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9240"/>
		<updated>2026-10-13T12:41:02Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Socket.IO Configuration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend documentation ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The backend contains two &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Scripts directory (&amp;lt;code&amp;gt;back-end-node-js/scripts/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains environment variables used specifically by scripts and test files within the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory. These settings are separate from the main backend configuration.&lt;br /&gt;
&lt;br /&gt;
===== Main Backend Environment Variables =====&lt;br /&gt;
&lt;br /&gt;
The main backend &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the bcrypt-hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. The new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
The MQTT protocol is created in the &amp;quot;mqttConnection.js&amp;quot; file, and is the main file for communicating with the robot. To communicate different commands is used:&lt;br /&gt;
* mqttClient.subscribe&lt;br /&gt;
* mqttClient.unsubscribe&lt;br /&gt;
* mqttClient.publish&lt;br /&gt;
* mqttClient.on&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.subscribe =====&lt;br /&gt;
This is used to make the back-end begin to listen to a certain topic. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mqttClient.subscribe(&amp;quot;dtubot/drive/T0/gyroo&amp;quot;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;dtubot&amp;quot; identifies the robot platform.&lt;br /&gt;
* &amp;quot;drive&amp;quot; represents telemetry topics used to receive data from the robot.&lt;br /&gt;
* &amp;quot;T0&amp;quot; is dependent on the number of Teensy Boards and is zero-indexed. It mentions which Teensy board it will listen to.&lt;br /&gt;
* &amp;quot;gyroo&amp;quot; represents the topic that is subscribed to.&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.unsubscribe =====&lt;br /&gt;
This is used to make the back-end stop listening to a topic. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mqttClient.unsubscribe(&amp;quot;dtubot/drive/T0/gyroo&amp;quot;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;dtubot&amp;quot; identifies the robot platform.&lt;br /&gt;
* &amp;quot;drive&amp;quot; represents telemetry topics used to receive data from the robot.&lt;br /&gt;
* &amp;quot;T0&amp;quot; is dependent on the number of Teensy Boards and is zero-indexed. It mentions which Teensy board it will listen to.&lt;br /&gt;
* &amp;quot;gyroo&amp;quot; represents the topic that is subscribed to.&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.publish =====&lt;br /&gt;
This is to send a message to a specific topic, which the robot will receive. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mqttClient.publish(&amp;quot;dtubot/cmd/T0&amp;quot;, &amp;quot;gyroc Start&amp;quot;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;dtubot&amp;quot; identifies the robot platform.&lt;br /&gt;
* &amp;quot;cmd&amp;quot; represents telemetry topics used to send commands to the robot.&lt;br /&gt;
* &amp;quot;T0&amp;quot; is dependent on the number of Teensy Boards and is zero-indexed. It mentions which Teensy board it will listen to.&lt;br /&gt;
* &amp;quot;gyroc Start&amp;quot; is the command that is sent to the robot.&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.on =====&lt;br /&gt;
This function listens to certain MQTT messages from the protocol. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mqttClient.on(title, payload)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The MQTT has different label titles i.e (&amp;quot;message&amp;quot; or &amp;quot;error&amp;quot;) and payload is the content that follows that title. These determines what kind of output the MQTT protocol has sent.&lt;br /&gt;
&lt;br /&gt;
If the label title is &amp;quot;message&amp;quot; it will contain a topic and a message. &lt;br /&gt;
&lt;br /&gt;
If the label title is &amp;quot;error&amp;quot; it will contain an error message.&lt;br /&gt;
&lt;br /&gt;
====  Service filles Configuration ==== &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;services/&amp;lt;/code&amp;gt; directory contains files responsible for handling specific backend functionalities and communication between different components of the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
Each service is responsible for a particular task, helping separate the application&#039;s functionality and making the codebase easier to maintain.&lt;br /&gt;
&lt;br /&gt;
===== Tab Service =====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;tabService.js&amp;lt;/code&amp;gt; file is responsible for managing MQTT subscriptions based on the active dashboard tab. It communicates with &amp;lt;code&amp;gt;mqttConnection.js&amp;lt;/code&amp;gt; to start and stop subscriptions, ensuring that the backend only subscribes to the data required by the selected tab.&lt;br /&gt;
&lt;br /&gt;
The file contains three main functions:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;tabChanged(previousTabTitle, newTabTitle):&#039;&#039;&#039; Handles switching between dashboard tabs by stopping subscriptions associated with the previously active tab and starting subscriptions required by the newly selected tab.&lt;br /&gt;
* &#039;&#039;&#039;onlyTabClosed(previousTabTitle):&#039;&#039;&#039; Handles closing the last open tab by stopping its associated MQTT subscriptions.&lt;br /&gt;
* &#039;&#039;&#039;tabChangedNoPrevious(newTabTitle):&#039;&#039;&#039; Handles opening a tab when no previous tab was active by starting the subscriptions required by the selected tab.&lt;br /&gt;
&lt;br /&gt;
Each dashboard tab is associated with specific MQTT subscriptions, such as heartbeat data, IMU sensor readings, robot information, and distance sensor data.&lt;br /&gt;
&lt;br /&gt;
When adding a new tab that requires MQTT data, the corresponding subscription handling should be added to the relevant functions in &amp;lt;code&amp;gt;tabService.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Sockets is the primary method of communication between the front-end and the back-end. There are two primary functions:&lt;br /&gt;
* socket.on (used in socket.js)&lt;br /&gt;
* io.emit (used in mqttConnection.js)&lt;br /&gt;
===== socket.on ===== &lt;br /&gt;
&amp;quot;socket.on&amp;quot; listens for any commands that have been sent with a specific topic from the front end. &lt;br /&gt;
&lt;br /&gt;
===== io.emit ===== &lt;br /&gt;
&amp;quot;io.emit&amp;quot; sends commands to the front-end with a package.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
The \&amp;lt;code&amp;gt;security/\&amp;lt;/code&amp;gt; directory contains the script responsible for handling authentication. This script should remain unchanged.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory.&lt;br /&gt;
&lt;br /&gt;
To change the administrator password, follow these steps:&lt;br /&gt;
&lt;br /&gt;
===== Step 1: Generate a New Password Hash =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/generateHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Locate the variable &amp;lt;code&amp;gt;userPassword&amp;lt;/code&amp;gt; and replace its current value with the desired new password.&lt;br /&gt;
# Open a terminal and navigate to the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Run the following command to generate a new bcrypt hash:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node generateHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# Copy the generated hash (the second output in the terminal).&lt;br /&gt;
&lt;br /&gt;
===== Step 2: Update the Environment Variable =====&lt;br /&gt;
&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;).&lt;br /&gt;
# Locate the &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
# Replace its existing value with the newly generated bcrypt hash.&lt;br /&gt;
# Save the file and restart the backend application to apply the changes.&lt;br /&gt;
# To restart the backend application, go to the robot&#039;s terminal and type &amp;lt;code&amp;gt;sudo systemctl restart webapp.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Step 3: Verify the New Password =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/testHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Update the test password to match the newly chosen administrator password.&lt;br /&gt;
# Ensure that the test script compares the new password against the newly generated hash.&lt;br /&gt;
# Run the test script from the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node testHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# The script should return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the password matches the hash, or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; if they do not match.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The administrator password must always be hashed using bcrypt before being stored in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file. Never store plaintext passwords in environment variables or commit passwords and hashes to version control.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
If a new session needs to be generated, type from the root directory &lt;br /&gt;
&amp;lt;code&amp;gt; node -e &amp;quot;console.log(require(&#039;crypto&#039;).randomBytes(32).toString(&#039;hex&#039;))&amp;quot; &amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Frontend&amp;diff=9239</id>
		<title>Frontend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Frontend&amp;diff=9239"/>
		<updated>2026-10-13T12:32:45Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Frontend ==&lt;br /&gt;
&lt;br /&gt;
The frontend is mainly structured around components, each responsible for specific functions. These components are used within pages, where they are combined to create complete pages with the required functionality. The frontend is developed using TypeScript, React, and Redux, with Tailwind CSS used for styling.&lt;br /&gt;
&lt;br /&gt;
=== Components ===&lt;br /&gt;
Currently, the frontend consists of seven different components, organized as follows:&lt;br /&gt;
&lt;br /&gt;
==== button ====&lt;br /&gt;
&lt;br /&gt;
the tsx-file defines the button&#039;s properties and functionality, including its type, size, color, and whether it is disabled. This file also creates the HTML button element &amp;lt;button&amp;gt; that can be used in the page you want to add a button.&lt;br /&gt;
&lt;br /&gt;
the ts-file defines the button&#039;s styling using Tailwind CSS, including colors, text sizes, rounded corners, and hover effects. This file does not contain any HTML.&lt;br /&gt;
&lt;br /&gt;
==== dropdown ====&lt;br /&gt;
&lt;br /&gt;
The dropdown menu does not have any specific properties of its own. It is mainly used as a placeholder that appears on the screen when the user clicks a button or hovers over it. The dropdown menu contains different buttons and does not require a separate `.ts` file, as it does not have any styling of its own.&lt;br /&gt;
&lt;br /&gt;
==== inputfield ====&lt;br /&gt;
&lt;br /&gt;
The InputField component It supports both text and password inputs and handles user interactions through event handlers such as onChange and onKeyDown. This component also uses Tailwind CSS for styling, which is defined directly within the tsx.&lt;br /&gt;
&lt;br /&gt;
==== popupwindow ====&lt;br /&gt;
&lt;br /&gt;
PopupWindow consists of a TSX file and a TS file. The TSX file defines the basic structure and functionality of the popup window, providing a default version that can be reused. The TS file defines the styling using Tailwind CSS, allowing the popup window to be customized with different sizes and colors.&lt;br /&gt;
&lt;br /&gt;
The PopupWindowContent folder contains the completed popup windows, which currently consist of two different components: SettingsPopupWindow and WidgetPopupWindow.&lt;br /&gt;
&lt;br /&gt;
The reason these two components are not included in the general TS and TSX files is that they contain different content and functionality. When a new type of popup window is needed, a new component can be created under PopupWindowContent, where its specific content and functionality are defined, while the basic structure and styling are reused from PopupWindow.&lt;br /&gt;
&lt;br /&gt;
==== sidebar ====&lt;br /&gt;
&lt;br /&gt;
Sidebar consists of a TSX file and a TS file. The TSX file defines the &lt;br /&gt;
&lt;br /&gt;
==== tabbar ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== widget ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Pages ===&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9238</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9238"/>
		<updated>2026-10-13T11:08:33Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* mqttClient.publish */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend documentation ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The backend contains two &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Scripts directory (&amp;lt;code&amp;gt;back-end-node-js/scripts/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains environment variables used specifically by scripts and test files within the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory. These settings are separate from the main backend configuration.&lt;br /&gt;
&lt;br /&gt;
===== Main Backend Environment Variables =====&lt;br /&gt;
&lt;br /&gt;
The main backend &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the bcrypt-hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. The new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
The MQTT protocol is created in the &amp;quot;mqttConnection.js&amp;quot; file, and is the main file for communicating with the robot. To communicate different commands is used:&lt;br /&gt;
* mqttClient.subscribe&lt;br /&gt;
* mqttClient.unsubscribe&lt;br /&gt;
* mqttClient.publish&lt;br /&gt;
* mqttClient.on&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.subscribe =====&lt;br /&gt;
This is used to make the back-end begin to listen to a certain topic. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mqttClient.subscribe(&amp;quot;dtubot/drive/T0/gyroo&amp;quot;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;dtubot&amp;quot; identifies the robot platform.&lt;br /&gt;
* &amp;quot;drive&amp;quot; represents telemetry topics used to receive data from the robot.&lt;br /&gt;
* &amp;quot;T0&amp;quot; is dependent on the number of Teensy Boards and is zero-indexed. It mentions which Teensy board it will listen to.&lt;br /&gt;
* &amp;quot;gyroo&amp;quot; represents the topic that is subscribed to.&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.unsubscribe =====&lt;br /&gt;
This is used to make the back-end stop listening to a topic. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mqttClient.unsubscribe(&amp;quot;dtubot/drive/T0/gyroo&amp;quot;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;dtubot&amp;quot; identifies the robot platform.&lt;br /&gt;
* &amp;quot;drive&amp;quot; represents telemetry topics used to receive data from the robot.&lt;br /&gt;
* &amp;quot;T0&amp;quot; is dependent on the number of Teensy Boards and is zero-indexed. It mentions which Teensy board it will listen to.&lt;br /&gt;
* &amp;quot;gyroo&amp;quot; represents the topic that is subscribed to.&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.publish =====&lt;br /&gt;
This is to send a message to a specific topic, which the robot will receive. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mqttClient.publish(&amp;quot;dtubot/cmd/T0&amp;quot;, &amp;quot;gyroc Start&amp;quot;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;dtubot&amp;quot; identifies the robot platform.&lt;br /&gt;
* &amp;quot;cmd&amp;quot; represents telemetry topics used to send commands to the robot.&lt;br /&gt;
* &amp;quot;T0&amp;quot; is dependent on the number of Teensy Boards and is zero-indexed. It mentions which Teensy board it will listen to.&lt;br /&gt;
* &amp;quot;gyroc Start&amp;quot; is the command that is sent to the robot.&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.on =====&lt;br /&gt;
This function listens to certain MQTT messages from the protocol. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mqttClient.on(title, payload)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The MQTT has different label titles i.e (&amp;quot;message&amp;quot; or &amp;quot;error&amp;quot;) and payload is the content that follows that title. These determines what kind of output the MQTT protocol has sent.&lt;br /&gt;
&lt;br /&gt;
If the label title is &amp;quot;message&amp;quot; it will contain a topic and a message. &lt;br /&gt;
&lt;br /&gt;
If the label title is &amp;quot;error&amp;quot; it will contain an error message.&lt;br /&gt;
&lt;br /&gt;
====  Service filles Configuration ==== &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;services/&amp;lt;/code&amp;gt; directory contains files responsible for handling specific backend functionalities and communication between different components of the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
Each service is responsible for a particular task, helping separate the application&#039;s functionality and making the codebase easier to maintain.&lt;br /&gt;
&lt;br /&gt;
===== Tab Service =====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;tabService.js&amp;lt;/code&amp;gt; file is responsible for managing MQTT subscriptions based on the active dashboard tab. It communicates with &amp;lt;code&amp;gt;mqttConnection.js&amp;lt;/code&amp;gt; to start and stop subscriptions, ensuring that the backend only subscribes to the data required by the selected tab.&lt;br /&gt;
&lt;br /&gt;
The file contains three main functions:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;tabChanged(previousTabTitle, newTabTitle):&#039;&#039;&#039; Handles switching between dashboard tabs by stopping subscriptions associated with the previously active tab and starting subscriptions required by the newly selected tab.&lt;br /&gt;
* &#039;&#039;&#039;onlyTabClosed(previousTabTitle):&#039;&#039;&#039; Handles closing the last open tab by stopping its associated MQTT subscriptions.&lt;br /&gt;
* &#039;&#039;&#039;tabChangedNoPrevious(newTabTitle):&#039;&#039;&#039; Handles opening a tab when no previous tab was active by starting the subscriptions required by the selected tab.&lt;br /&gt;
&lt;br /&gt;
Each dashboard tab is associated with specific MQTT subscriptions, such as heartbeat data, IMU sensor readings, robot information, and distance sensor data.&lt;br /&gt;
&lt;br /&gt;
When adding a new tab that requires MQTT data, the corresponding subscription handling should be added to the relevant functions in &amp;lt;code&amp;gt;tabService.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
The \&amp;lt;code&amp;gt;security/\&amp;lt;/code&amp;gt; directory contains the script responsible for handling authentication. This script should remain unchanged.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory.&lt;br /&gt;
&lt;br /&gt;
To change the administrator password, follow these steps:&lt;br /&gt;
&lt;br /&gt;
===== Step 1: Generate a New Password Hash =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/generateHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Locate the variable &amp;lt;code&amp;gt;userPassword&amp;lt;/code&amp;gt; and replace its current value with the desired new password.&lt;br /&gt;
# Open a terminal and navigate to the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Run the following command to generate a new bcrypt hash:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node generateHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# Copy the generated hash (the second output in the terminal).&lt;br /&gt;
&lt;br /&gt;
===== Step 2: Update the Environment Variable =====&lt;br /&gt;
&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;).&lt;br /&gt;
# Locate the &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
# Replace its existing value with the newly generated bcrypt hash.&lt;br /&gt;
# Save the file and restart the backend application to apply the changes.&lt;br /&gt;
# To restart the backend application, go to the robot&#039;s terminal and type &amp;lt;code&amp;gt;sudo systemctl restart webapp.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Step 3: Verify the New Password =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/testHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Update the test password to match the newly chosen administrator password.&lt;br /&gt;
# Ensure that the test script compares the new password against the newly generated hash.&lt;br /&gt;
# Run the test script from the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node testHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# The script should return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the password matches the hash, or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; if they do not match.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The administrator password must always be hashed using bcrypt before being stored in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file. Never store plaintext passwords in environment variables or commit passwords and hashes to version control.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
If a new session needs to be generated, type from the root directory &lt;br /&gt;
&amp;lt;code&amp;gt; node -e &amp;quot;console.log(require(&#039;crypto&#039;).randomBytes(32).toString(&#039;hex&#039;))&amp;quot; &amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9237</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9237"/>
		<updated>2026-10-13T11:08:11Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* MQTT Configuration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend documentation ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The backend contains two &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Scripts directory (&amp;lt;code&amp;gt;back-end-node-js/scripts/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains environment variables used specifically by scripts and test files within the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory. These settings are separate from the main backend configuration.&lt;br /&gt;
&lt;br /&gt;
===== Main Backend Environment Variables =====&lt;br /&gt;
&lt;br /&gt;
The main backend &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the bcrypt-hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. The new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
The MQTT protocol is created in the &amp;quot;mqttConnection.js&amp;quot; file, and is the main file for communicating with the robot. To communicate different commands is used:&lt;br /&gt;
* mqttClient.subscribe&lt;br /&gt;
* mqttClient.unsubscribe&lt;br /&gt;
* mqttClient.publish&lt;br /&gt;
* mqttClient.on&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.subscribe =====&lt;br /&gt;
This is used to make the back-end begin to listen to a certain topic. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mqttClient.subscribe(&amp;quot;dtubot/drive/T0/gyroo&amp;quot;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;dtubot&amp;quot; identifies the robot platform.&lt;br /&gt;
* &amp;quot;drive&amp;quot; represents telemetry topics used to receive data from the robot.&lt;br /&gt;
* &amp;quot;T0&amp;quot; is dependent on the number of Teensy Boards and is zero-indexed. It mentions which Teensy board it will listen to.&lt;br /&gt;
* &amp;quot;gyroo&amp;quot; represents the topic that is subscribed to.&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.unsubscribe =====&lt;br /&gt;
This is used to make the back-end stop listening to a topic. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mqttClient.unsubscribe(&amp;quot;dtubot/drive/T0/gyroo&amp;quot;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;dtubot&amp;quot; identifies the robot platform.&lt;br /&gt;
* &amp;quot;drive&amp;quot; represents telemetry topics used to receive data from the robot.&lt;br /&gt;
* &amp;quot;T0&amp;quot; is dependent on the number of Teensy Boards and is zero-indexed. It mentions which Teensy board it will listen to.&lt;br /&gt;
* &amp;quot;gyroo&amp;quot; represents the topic that is subscribed to.&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.publish =====&lt;br /&gt;
This is to send a message to a specific topic, which the robot will receive. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mqttClient.publish(&amp;quot;dtubot/cmd/T0&amp;quot;, &amp;quot;gyroc Start&amp;quot;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;dtubot&amp;quot; identifies the robot platform.&lt;br /&gt;
* &amp;quot;cmd&amp;quot; represents telemetry topics used to send commands to the robot.&lt;br /&gt;
* &amp;quot;T0&amp;quot; is dependent on the number of Teensy Boards and is zero-indexed. It mentions which Teensy board it will listen to.&lt;br /&gt;
* &amp;quot;gyroc Start&amp;quot; is the command that is sent to the robot.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.on =====&lt;br /&gt;
This function listens to certain MQTT messages from the protocol. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mqttClient.on(title, payload)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The MQTT has different label titles i.e (&amp;quot;message&amp;quot; or &amp;quot;error&amp;quot;) and payload is the content that follows that title. These determines what kind of output the MQTT protocol has sent.&lt;br /&gt;
&lt;br /&gt;
If the label title is &amp;quot;message&amp;quot; it will contain a topic and a message. &lt;br /&gt;
&lt;br /&gt;
If the label title is &amp;quot;error&amp;quot; it will contain an error message.&lt;br /&gt;
&lt;br /&gt;
====  Service filles Configuration ==== &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;services/&amp;lt;/code&amp;gt; directory contains files responsible for handling specific backend functionalities and communication between different components of the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
Each service is responsible for a particular task, helping separate the application&#039;s functionality and making the codebase easier to maintain.&lt;br /&gt;
&lt;br /&gt;
===== Tab Service =====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;tabService.js&amp;lt;/code&amp;gt; file is responsible for managing MQTT subscriptions based on the active dashboard tab. It communicates with &amp;lt;code&amp;gt;mqttConnection.js&amp;lt;/code&amp;gt; to start and stop subscriptions, ensuring that the backend only subscribes to the data required by the selected tab.&lt;br /&gt;
&lt;br /&gt;
The file contains three main functions:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;tabChanged(previousTabTitle, newTabTitle):&#039;&#039;&#039; Handles switching between dashboard tabs by stopping subscriptions associated with the previously active tab and starting subscriptions required by the newly selected tab.&lt;br /&gt;
* &#039;&#039;&#039;onlyTabClosed(previousTabTitle):&#039;&#039;&#039; Handles closing the last open tab by stopping its associated MQTT subscriptions.&lt;br /&gt;
* &#039;&#039;&#039;tabChangedNoPrevious(newTabTitle):&#039;&#039;&#039; Handles opening a tab when no previous tab was active by starting the subscriptions required by the selected tab.&lt;br /&gt;
&lt;br /&gt;
Each dashboard tab is associated with specific MQTT subscriptions, such as heartbeat data, IMU sensor readings, robot information, and distance sensor data.&lt;br /&gt;
&lt;br /&gt;
When adding a new tab that requires MQTT data, the corresponding subscription handling should be added to the relevant functions in &amp;lt;code&amp;gt;tabService.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
The \&amp;lt;code&amp;gt;security/\&amp;lt;/code&amp;gt; directory contains the script responsible for handling authentication. This script should remain unchanged.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory.&lt;br /&gt;
&lt;br /&gt;
To change the administrator password, follow these steps:&lt;br /&gt;
&lt;br /&gt;
===== Step 1: Generate a New Password Hash =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/generateHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Locate the variable &amp;lt;code&amp;gt;userPassword&amp;lt;/code&amp;gt; and replace its current value with the desired new password.&lt;br /&gt;
# Open a terminal and navigate to the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Run the following command to generate a new bcrypt hash:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node generateHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# Copy the generated hash (the second output in the terminal).&lt;br /&gt;
&lt;br /&gt;
===== Step 2: Update the Environment Variable =====&lt;br /&gt;
&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;).&lt;br /&gt;
# Locate the &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
# Replace its existing value with the newly generated bcrypt hash.&lt;br /&gt;
# Save the file and restart the backend application to apply the changes.&lt;br /&gt;
# To restart the backend application, go to the robot&#039;s terminal and type &amp;lt;code&amp;gt;sudo systemctl restart webapp.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Step 3: Verify the New Password =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/testHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Update the test password to match the newly chosen administrator password.&lt;br /&gt;
# Ensure that the test script compares the new password against the newly generated hash.&lt;br /&gt;
# Run the test script from the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node testHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# The script should return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the password matches the hash, or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; if they do not match.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The administrator password must always be hashed using bcrypt before being stored in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file. Never store plaintext passwords in environment variables or commit passwords and hashes to version control.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
If a new session needs to be generated, type from the root directory &lt;br /&gt;
&amp;lt;code&amp;gt; node -e &amp;quot;console.log(require(&#039;crypto&#039;).randomBytes(32).toString(&#039;hex&#039;))&amp;quot; &amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Frontend&amp;diff=9236</id>
		<title>Frontend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Frontend&amp;diff=9236"/>
		<updated>2026-10-13T11:01:54Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Frontend ==&lt;br /&gt;
&lt;br /&gt;
The frontend is mainly structured around components, each responsible for specific functions. These components are used within pages, where they are combined to create complete pages with the required functionality. The frontend is developed using TypeScript, React, and Redux, with Tailwind CSS used for styling.&lt;br /&gt;
&lt;br /&gt;
=== Components ===&lt;br /&gt;
Currently, the frontend consists of seven different components, organized as follows:&lt;br /&gt;
&lt;br /&gt;
==== button ====&lt;br /&gt;
&lt;br /&gt;
the tsx-file defines the button&#039;s properties and functionality, including its type, size, color, and whether it is disabled. This file also creates the HTML button element &amp;lt;button&amp;gt; that can be used in the page you want to add a button.&lt;br /&gt;
&lt;br /&gt;
the ts-file defines the button&#039;s styling using Tailwind CSS, including colors, text sizes, rounded corners, and hover effects. This file does not contain any HTML.&lt;br /&gt;
&lt;br /&gt;
==== dropdown ====&lt;br /&gt;
&lt;br /&gt;
The dropdown menu does not have any specific properties of its own. It is mainly used as a placeholder that appears on the screen when the user clicks a button or hovers over it. The dropdown menu contains different buttons and does not require a separate `.ts` file, as it does not have any styling of its own.&lt;br /&gt;
&lt;br /&gt;
==== inputfield ====&lt;br /&gt;
&lt;br /&gt;
The InputField component It supports both text and password inputs and handles user interactions through event handlers such as onChange and onKeyDown. This component also uses Tailwind CSS for styling, which is defined directly within the tsx.&lt;br /&gt;
&lt;br /&gt;
==== popupwindow ====&lt;br /&gt;
&lt;br /&gt;
PopupWindow consists of a TSX file and a TS file. The TSX file defines the basic structure and functionality of the popup window, providing a default version that can be reused. The TS file defines the styling using Tailwind CSS, allowing the popup window to be customized with different sizes and colors.&lt;br /&gt;
&lt;br /&gt;
The PopupWindowContent folder contains the completed popup windows, which currently consist of two different components: SettingsPopupWindow and WidgetPopupWindow.&lt;br /&gt;
&lt;br /&gt;
The reason these two components are not included in the general TS and TSX files is that they contain different content and functionality. When a new type of popup window is needed, a new component can be created under PopupWindowContent, where its specific content and functionality are defined, while the basic structure and styling are reused from PopupWindow.&lt;br /&gt;
&lt;br /&gt;
==== sidebar ====&lt;br /&gt;
&lt;br /&gt;
The Sidebar component consists of a TSX file and a TS file. The TSX file defines the basic structure and functionality of the sidebar, including the ability to open, close, and resize it. It also stores the sidebar&#039;s state and previous width, allowing the user&#039;s settings to be preserved during the session.&lt;br /&gt;
&lt;br /&gt;
The TS file defines the styling using Tailwind CSS. This includes the sidebar colors, the positioning of the toggle button and resize bar, and the rotation of the arrow when the sidebar is opened or closed.&lt;br /&gt;
&lt;br /&gt;
The `SidebarContent` folder contains the left and right sidebar components. This is where developers can modify the content and functionality of each individual sidebar without changing the general Sidebar component.&lt;br /&gt;
&lt;br /&gt;
The reason for this structure is to separate the basic structure and styling from the specific content of each sidebar. This allows developers to reuse the existing Sidebar component when creating new sidebars, while customizing their content and functionality as needed.&lt;br /&gt;
&lt;br /&gt;
==== tabbar ====&lt;br /&gt;
&lt;br /&gt;
The Tabbar is structured into four TSX files, each responsible for a specific part of the tab system. This structure separates the management of tabs from their content and layouts, making it easier for developers to maintain and extend the system.&lt;br /&gt;
&lt;br /&gt;
The tabbar.tsx file contains the main functionality of the tab bar. It handles opening, closing, and switching between tabs, as well as managing which tabs are currently open. It also uses React Router for navigation and Socket.IO to notify the backend when the active tab changes.&lt;br /&gt;
&lt;br /&gt;
The tabs.tsx file contains the predefined tabs available in the dashboard. Each tab defines which widgets should be displayed and which layout should be used.&lt;br /&gt;
&lt;br /&gt;
If a developer wants to modify the widgets displayed in an existing tab or create a new tab, this is where its content and layout are defined.&lt;br /&gt;
&lt;br /&gt;
The tabLayout.tsx file contains the different layout templates used by the tabs. Each layout determines how the widgets are arranged on the screen, including their positions and sizes.&lt;br /&gt;
&lt;br /&gt;
The layouts use resizable panels, allowing users to adjust the size of individual widgets. The styling is defined directly within the TSX file using Tailwind CSS.&lt;br /&gt;
&lt;br /&gt;
If a developer wants to create a new layout, modify an existing one, or change the styling of the layouts, changes should be made in this file.&lt;br /&gt;
&lt;br /&gt;
The tabMap.tsx file maps tab names to their corresponding React components. This allows the application to identify the correct component based on the tab name.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When creating a new tab, developers should first define the tab in `tabs.tsx`, where they select the required layout and widgets.&lt;br /&gt;
&lt;br /&gt;
If the desired layout does not already exist, a new layout can be created in `tabLayout.tsx`.&lt;br /&gt;
&lt;br /&gt;
The new tab must then be registered in the tab mapping and management logic in `tabbar.tsx` so that it can be opened and displayed through the tab bar. If `tabMap.tsx` is used elsewhere in the application, the new tab should also be added there.&lt;br /&gt;
&lt;br /&gt;
This structure allows developers to reuse existing layouts and widgets without having to recreate the tab system for each new tab.&lt;br /&gt;
&lt;br /&gt;
==== widget ====&lt;br /&gt;
&lt;br /&gt;
The widget.tsx file acts as a central placeholder for the different widgets. It determines which widget should be displayed based on the provided widget name.&lt;br /&gt;
The widgets folder contains the individual widget components, where their specific content, functionality, and styling are developed.&lt;br /&gt;
When creating a new widget, developers should create a new component in the widgets folder and register it in widget.tsx so it can be displayed in the application.&lt;br /&gt;
&lt;br /&gt;
Each widget is developed as an individual TSX component inside the widgets folder, containing its own functionality and styling. For example, TiltGraphWidget.tsx receives data from the backend using Socket.IO and displays it in a graph using Recharts.&lt;br /&gt;
A tab can contain from one and up to four individual widgets, depending on the selected layout. The widgets displayed in each tab are defined in tabs.tsx, while tabLayout.tsx determines how they are arranged on the screen.&lt;br /&gt;
This structure allows developers to create and modify individual widgets independently and reuse them across different tabs without changing their internal functionality.&lt;br /&gt;
&lt;br /&gt;
=== Pages ===&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Frontend&amp;diff=9235</id>
		<title>Frontend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Frontend&amp;diff=9235"/>
		<updated>2026-10-13T11:01:38Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Frontend ==&lt;br /&gt;
&lt;br /&gt;
The frontend is mainly structured around components, each responsible for specific functions. These components are used within pages, where they are combined to create complete pages with the required functionality. The frontend is developed using TypeScript, React, and Redux, with Tailwind CSS used for styling.&lt;br /&gt;
&lt;br /&gt;
=== Components ===&lt;br /&gt;
Currently, the frontend consists of seven different components, organized as follows:&lt;br /&gt;
&lt;br /&gt;
==== button ====&lt;br /&gt;
&lt;br /&gt;
the tsx-file defines the button&#039;s properties and functionality, including its type, size, color, and whether it is disabled. This file also creates the HTML button element &amp;lt;button&amp;gt; that can be used in the page you want to add a button.&lt;br /&gt;
&lt;br /&gt;
the ts-file defines the button&#039;s styling using Tailwind CSS, including colors, text sizes, rounded corners, and hover effects. This file does not contain any HTML.&lt;br /&gt;
&lt;br /&gt;
==== dropdown ====&lt;br /&gt;
&lt;br /&gt;
The dropdown menu does not have any specific properties of its own. It is mainly used as a placeholder that appears on the screen when the user clicks a button or hovers over it. The dropdown menu contains different buttons and does not require a separate `.ts` file, as it does not have any styling of its own.&lt;br /&gt;
&lt;br /&gt;
==== inputfield ====&lt;br /&gt;
&lt;br /&gt;
The InputField component It supports both text and password inputs and handles user interactions through event handlers such as onChange and onKeyDown. This component also uses Tailwind CSS for styling, which is defined directly within the tsx.&lt;br /&gt;
&lt;br /&gt;
==== popupwindow ====&lt;br /&gt;
&lt;br /&gt;
PopupWindow consists of a TSX file and a TS file. The TSX file defines the basic structure and functionality of the popup window, providing a default version that can be reused. The TS file defines the styling using Tailwind CSS, allowing the popup window to be customized with different sizes and colors.&lt;br /&gt;
&lt;br /&gt;
The PopupWindowContent folder contains the completed popup windows, which currently consist of two different components: SettingsPopupWindow and WidgetPopupWindow.&lt;br /&gt;
&lt;br /&gt;
The reason these two components are not included in the general TS and TSX files is that they contain different content and functionality. When a new type of popup window is needed, a new component can be created under PopupWindowContent, where its specific content and functionality are defined, while the basic structure and styling are reused from PopupWindow.&lt;br /&gt;
&lt;br /&gt;
==== sidebar ====&lt;br /&gt;
&lt;br /&gt;
The Sidebar component consists of a TSX file and a TS file. The TSX file defines the basic structure and functionality of the sidebar, including the ability to open, close, and resize it. It also stores the sidebar&#039;s state and previous width, allowing the user&#039;s settings to be preserved during the session.&lt;br /&gt;
&lt;br /&gt;
The TS file defines the styling using Tailwind CSS. This includes the sidebar colors, the positioning of the toggle button and resize bar, and the rotation of the arrow when the sidebar is opened or closed.&lt;br /&gt;
&lt;br /&gt;
The `SidebarContent` folder contains the left and right sidebar components. This is where developers can modify the content and functionality of each individual sidebar without changing the general Sidebar component.&lt;br /&gt;
&lt;br /&gt;
The reason for this structure is to separate the basic structure and styling from the specific content of each sidebar. This allows developers to reuse the existing Sidebar component when creating new sidebars, while customizing their content and functionality as needed.&lt;br /&gt;
&lt;br /&gt;
==== tabbar ====&lt;br /&gt;
&lt;br /&gt;
The Tabbar is structured into four TSX files, each responsible for a specific part of the tab system. This structure separates the management of tabs from their content and layouts, making it easier for developers to maintain and extend the system.&lt;br /&gt;
&lt;br /&gt;
The tabbar.tsx file contains the main functionality of the tab bar. It handles opening, closing, and switching between tabs, as well as managing which tabs are currently open. It also uses React Router for navigation and Socket.IO to notify the backend when the active tab changes.&lt;br /&gt;
&lt;br /&gt;
The tabs.tsx file contains the predefined tabs available in the dashboard. Each tab defines which widgets should be displayed and which layout should be used.&lt;br /&gt;
&lt;br /&gt;
If a developer wants to modify the widgets displayed in an existing tab or create a new tab, this is where its content and layout are defined.&lt;br /&gt;
&lt;br /&gt;
The tabLayout.tsx file contains the different layout templates used by the tabs. Each layout determines how the widgets are arranged on the screen, including their positions and sizes.&lt;br /&gt;
&lt;br /&gt;
The layouts use resizable panels, allowing users to adjust the size of individual widgets. The styling is defined directly within the TSX file using Tailwind CSS.&lt;br /&gt;
&lt;br /&gt;
If a developer wants to create a new layout, modify an existing one, or change the styling of the layouts, changes should be made in this file.&lt;br /&gt;
&lt;br /&gt;
The tabMap.tsx file maps tab names to their corresponding React components. This allows the application to identify the correct component based on the tab name.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When creating a new tab, developers should first define the tab in `tabs.tsx`, where they select the required layout and widgets.&lt;br /&gt;
&lt;br /&gt;
If the desired layout does not already exist, a new layout can be created in `tabLayout.tsx`.&lt;br /&gt;
&lt;br /&gt;
The new tab must then be registered in the tab mapping and management logic in `tabbar.tsx` so that it can be opened and displayed through the tab bar. If `tabMap.tsx` is used elsewhere in the application, the new tab should also be added there.&lt;br /&gt;
&lt;br /&gt;
This structure allows developers to reuse existing layouts and widgets without having to recreate the tab system for each new tab.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== widget ====&lt;br /&gt;
&lt;br /&gt;
The widget.tsx file acts as a central placeholder for the different widgets. It determines which widget should be displayed based on the provided widget name.&lt;br /&gt;
The widgets folder contains the individual widget components, where their specific content, functionality, and styling are developed.&lt;br /&gt;
When creating a new widget, developers should create a new component in the widgets folder and register it in widget.tsx so it can be displayed in the application.&lt;br /&gt;
&lt;br /&gt;
Each widget is developed as an individual TSX component inside the widgets folder, containing its own functionality and styling. For example, TiltGraphWidget.tsx receives data from the backend using Socket.IO and displays it in a graph using Recharts.&lt;br /&gt;
A tab can contain from one and up to four individual widgets, depending on the selected layout. The widgets displayed in each tab are defined in tabs.tsx, while tabLayout.tsx determines how they are arranged on the screen.&lt;br /&gt;
This structure allows developers to create and modify individual widgets independently and reuse them across different tabs without changing their internal functionality.&lt;br /&gt;
&lt;br /&gt;
=== Pages ===&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9234</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9234"/>
		<updated>2026-10-13T10:59:54Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Backend */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend documentation ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The backend contains two &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Scripts directory (&amp;lt;code&amp;gt;back-end-node-js/scripts/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains environment variables used specifically by scripts and test files within the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory. These settings are separate from the main backend configuration.&lt;br /&gt;
&lt;br /&gt;
===== Main Backend Environment Variables =====&lt;br /&gt;
&lt;br /&gt;
The main backend &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the bcrypt-hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. The new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
The MQTT protocol is created in the &amp;quot;mqttConnection.js&amp;quot; file, and is the main file for communicating with the robot. To communicate different commands is used:&lt;br /&gt;
* mqttClient.subscribe&lt;br /&gt;
* mqttClient.unsubscribe&lt;br /&gt;
* mqttClient.publish&lt;br /&gt;
* mqttClient.on&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.subscribe =====&lt;br /&gt;
This is used to make the back-end begin to listen to a certain topic. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mqttClient.subscribe(&amp;quot;dtubot/drive/T0/gyroo&amp;quot;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;dtubot&amp;quot; identifies the robot platform.&lt;br /&gt;
* &amp;quot;drive&amp;quot; represents telemetry topics used to receive data from the robot.&lt;br /&gt;
* &amp;quot;T0&amp;quot; is dependent on the number of Teensy Boards and is zero-indexed. It mentions which Teensy board it will listen to.&lt;br /&gt;
* &amp;quot;gyroo&amp;quot; represents the topic that is subscribed to.&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.unsubscribe =====&lt;br /&gt;
This is used to make the back-end stop listening to a topic. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mqttClient.unsubscribe(&amp;quot;dtubot/drive/T0/gyroo&amp;quot;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;dtubot&amp;quot; identifies the robot platform.&lt;br /&gt;
* &amp;quot;drive&amp;quot; represents telemetry topics used to receive data from the robot.&lt;br /&gt;
* &amp;quot;T0&amp;quot; is dependent on the number of Teensy Boards and is zero-indexed. It mentions which Teensy board it will listen to.&lt;br /&gt;
* &amp;quot;gyroo&amp;quot; represents the topic that is subscribed to.&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.publish =====&lt;br /&gt;
This is to send a message to a specific topic, which the robot will receive. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mqttClient.publish(&amp;quot;dtubot/cmd/T0&amp;quot;, &amp;quot;gyroc Start&amp;quot;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;dtubot&amp;quot; identifies the robot platform.&lt;br /&gt;
* &amp;quot;cmd&amp;quot; represents telemetry topics used to send commands to the robot.&lt;br /&gt;
* &amp;quot;T0&amp;quot; is dependent on the number of Teensy Boards and is zero-indexed. It mentions which Teensy board it will listen to.&lt;br /&gt;
* &amp;quot;gyroc Start&amp;quot; is the command that is sent to the robot.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.on =====&lt;br /&gt;
&lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, &lt;br /&gt;
and topics.&lt;br /&gt;
&lt;br /&gt;
====  Service filles Configuration ==== &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;services/&amp;lt;/code&amp;gt; directory contains files responsible for handling specific backend functionalities and communication between different components of the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
Each service is responsible for a particular task, helping separate the application&#039;s functionality and making the codebase easier to maintain.&lt;br /&gt;
&lt;br /&gt;
===== Tab Service =====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;tabService.js&amp;lt;/code&amp;gt; file is responsible for managing MQTT subscriptions based on the active dashboard tab. It communicates with &amp;lt;code&amp;gt;mqttConnection.js&amp;lt;/code&amp;gt; to start and stop subscriptions, ensuring that the backend only subscribes to the data required by the selected tab.&lt;br /&gt;
&lt;br /&gt;
The file contains three main functions:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;tabChanged(previousTabTitle, newTabTitle):&#039;&#039;&#039; Handles switching between dashboard tabs by stopping subscriptions associated with the previously active tab and starting subscriptions required by the newly selected tab.&lt;br /&gt;
* &#039;&#039;&#039;onlyTabClosed(previousTabTitle):&#039;&#039;&#039; Handles closing the last open tab by stopping its associated MQTT subscriptions.&lt;br /&gt;
* &#039;&#039;&#039;tabChangedNoPrevious(newTabTitle):&#039;&#039;&#039; Handles opening a tab when no previous tab was active by starting the subscriptions required by the selected tab.&lt;br /&gt;
&lt;br /&gt;
Each dashboard tab is associated with specific MQTT subscriptions, such as heartbeat data, IMU sensor readings, robot information, and distance sensor data.&lt;br /&gt;
&lt;br /&gt;
When adding a new tab that requires MQTT data, the corresponding subscription handling should be added to the relevant functions in &amp;lt;code&amp;gt;tabService.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
The \&amp;lt;code&amp;gt;security/\&amp;lt;/code&amp;gt; directory contains the script responsible for handling authentication. This script should remain unchanged.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory.&lt;br /&gt;
&lt;br /&gt;
To change the administrator password, follow these steps:&lt;br /&gt;
&lt;br /&gt;
===== Step 1: Generate a New Password Hash =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/generateHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Locate the variable &amp;lt;code&amp;gt;userPassword&amp;lt;/code&amp;gt; and replace its current value with the desired new password.&lt;br /&gt;
# Open a terminal and navigate to the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Run the following command to generate a new bcrypt hash:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node generateHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# Copy the generated hash (the second output in the terminal).&lt;br /&gt;
&lt;br /&gt;
===== Step 2: Update the Environment Variable =====&lt;br /&gt;
&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;).&lt;br /&gt;
# Locate the &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
# Replace its existing value with the newly generated bcrypt hash.&lt;br /&gt;
# Save the file and restart the backend application to apply the changes.&lt;br /&gt;
# To restart the backend application, go to the robot&#039;s terminal and type &amp;lt;code&amp;gt;sudo systemctl restart webapp.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Step 3: Verify the New Password =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/testHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Update the test password to match the newly chosen administrator password.&lt;br /&gt;
# Ensure that the test script compares the new password against the newly generated hash.&lt;br /&gt;
# Run the test script from the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node testHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# The script should return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the password matches the hash, or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; if they do not match.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The administrator password must always be hashed using bcrypt before being stored in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file. Never store plaintext passwords in environment variables or commit passwords and hashes to version control.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
If a new session needs to be generated, type from the root directory &lt;br /&gt;
&amp;lt;code&amp;gt; node -e &amp;quot;console.log(require(&#039;crypto&#039;).randomBytes(32).toString(&#039;hex&#039;))&amp;quot; &amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Robot_dashboard&amp;diff=9233</id>
		<title>Robot dashboard</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Robot_dashboard&amp;diff=9233"/>
		<updated>2026-10-13T10:59:41Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Back-end */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard is a browser-based application developed to provide a centralized interface for monitoring and interacting with autonomous robots but as fo. The dashboard enables users to visualize real-time robot data, monitor system status, and interact with different robot components through a customizable interface.&lt;br /&gt;
&lt;br /&gt;
The application was developed as part of a bachelor&#039;s project at the Technical University of Denmark (DTU) in Spring 2026. Its main objective was to create a flexible and user-friendly platform that simplifies robot monitoring and interaction without requiring users to work directly with the underlying communication systems.&lt;br /&gt;
&lt;br /&gt;
The dashboard is specifically designed for the type &#039;Robobot&#039; and is currently only compatible with this robot type. While the system has a modular architecture that allows for future extensions, supporting other robot types would require additional development and modifications to the existing implementation.&lt;br /&gt;
&lt;br /&gt;
The dashboard consists of a frontend built with React, TypeScript, and Tailwind CSS, and a backend developed using Node.js and Express. Communication between the dashboard and the robots is handled through MQTT, while Socket.IO enables real-time updates between the backend and frontend.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Key Features&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Real-time monitoring:&#039;&#039;&#039; Displays live robot information, including position, status, and sensor data.&lt;br /&gt;
*&#039;&#039;&#039;Customizable dashboard:&#039;&#039;&#039; Allows users to organize and interact with different widgets across multiple tabs.&lt;br /&gt;
* &#039;&#039;&#039;Robot interaction:&#039;&#039;&#039; Provides an interface for monitoring and interacting with robot components.&lt;br /&gt;
* &#039;&#039;&#039;Widget-based interface:&#039;&#039;&#039; Includes widgets for robot information, position, driver controls, edge sensors, and debugging.&lt;br /&gt;
* &#039;&#039;&#039;User authentication:&#039;&#039;&#039; Restricts dashboard access through a password-based login system.&lt;br /&gt;
&lt;br /&gt;
The dashboard is designed to provide a foundation for future development, allowing additional widgets and functionalities to be integrated as needed.&lt;br /&gt;
&lt;br /&gt;
= Developers note =&lt;br /&gt;
&lt;br /&gt;
This following section is for developers, it goes through the set up procedure and how the back-end and front-end is set up for further development. &lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
For further development of the dashboard these are the requirements to have.&lt;br /&gt;
* Have installed Node.js&lt;br /&gt;
* Have installed npm&lt;br /&gt;
* Have a code editor (VScode or other)&lt;br /&gt;
* Have Downloaded Type-Script&lt;br /&gt;
&lt;br /&gt;
== Set up ==&lt;br /&gt;
&lt;br /&gt;
Before setting up the robot dashboard two necessary software programs is required.&lt;br /&gt;
&lt;br /&gt;
# A file management software (Windows: RealFTP, Mac: FileZilla)&lt;br /&gt;
# A file editing software (Windows: PuTTY, Mac: Terminal)&lt;br /&gt;
&lt;br /&gt;
=== Installing nodejs and npm on the robot ===&lt;br /&gt;
For the dashboard software to function it is important to make sure that node.js and npm is installed on the robot. To check this run the following code in the terminal&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
npm -v&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
node -v&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If npm and node is not installed, install them using the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt install -y nodejs npm&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== File placement ===&lt;br /&gt;
&lt;br /&gt;
To make the dashboard software functional we need to transfer the necessary files. It is important that the files are in the correct placement with the correct names for the software to start when the system boots.&lt;br /&gt;
&lt;br /&gt;
When transferring the files locate the path:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
/home/local/svn/robobot/&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a folder named &amp;quot;Browser-based-dashboard-for-autonomous-robots&amp;quot; such that the folder path looks like this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
/home/local/svn/robobot/Browser-based-dashboard-for-autonomous-robots&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this folder we will transfer the back-end and the front-end. It is important that the back-end folder is called &amp;quot;back-end-node-js&amp;quot; as this name is used for the software to start when the system boots. Otherwise you will need to change the work directory in the upcomming service file.&lt;br /&gt;
&lt;br /&gt;
When the back-end and front-end have been transferred to the robot in the &amp;quot;Browser-based-dashboard-for-autonomous-robots&amp;quot; folder, the following commands will be needed for each folder.&lt;br /&gt;
&lt;br /&gt;
==== back-end ====&lt;br /&gt;
In the back-end run the following commands to make sure every needed package is installed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install&lt;br /&gt;
npm install socket.io-client&lt;br /&gt;
npm audit fix&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== front-end ====&lt;br /&gt;
In the front-end run the following commands to make sure every needed package is installed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install&lt;br /&gt;
npm audit fix&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Making the software start when the system boots  ===&lt;br /&gt;
The first thing is to make sure the robot will start the dashboard software on boot up. To do this we will use the editing software to create a service file using the command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo nano /etc/systemd/system/webapp.service&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will create a file named &amp;quot;webapp.service&amp;quot;, which is responsible for ensuring that the dashboard software starts automatically when the system boots.&lt;br /&gt;
&lt;br /&gt;
In this file write the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Unit]&lt;br /&gt;
Description=Webapp starter that waits for network and MQTT&lt;br /&gt;
Wants=network-online.target&lt;br /&gt;
After=network-online.target&lt;br /&gt;
StartLimitIntervalSec=0&lt;br /&gt;
&lt;br /&gt;
[Service]&lt;br /&gt;
Type=simple&lt;br /&gt;
User=local&lt;br /&gt;
#Change to the backend folder path&lt;br /&gt;
WorkingDirectory=/home/local/svn/robobot/Browser-based-dashboard-for-autonomous-robots/back-end-node-js&lt;br /&gt;
Environment=NODE_ENV=production&lt;br /&gt;
Environment=ROBOT_PORT=9090&lt;br /&gt;
&lt;br /&gt;
#Wait for network&lt;br /&gt;
ExecStartPre=/bin/bash -c &#039;\&lt;br /&gt;
  echo &amp;quot;Waiting for network...&amp;quot;; \&lt;br /&gt;
  until hostname -I &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; do \&lt;br /&gt;
    echo &amp;quot;No IP yet. Retrying...&amp;quot;; \&lt;br /&gt;
    sleep 2; \&lt;br /&gt;
  done; \&lt;br /&gt;
  echo &amp;quot;Network ready.&amp;quot; \&lt;br /&gt;
&#039;&lt;br /&gt;
&lt;br /&gt;
#Start Node with dynamically set ROBOT_HOST&lt;br /&gt;
ExecStart=/bin/bash -c &#039;ROBOT_HOST=$(hostname -I | awk &amp;quot;{print $1}&amp;quot;); \&lt;br /&gt;
        ROBOT_HOST=$(echo &amp;quot;$ROBOT_HOST&amp;quot; | xargs); \&lt;br /&gt;
        echo &amp;quot;Starting web app with ROBOT_HOST=$ROBOT_HOST&amp;quot;; \&lt;br /&gt;
        export ROBOT_HOST; exec /usr/bin/node server.js \&lt;br /&gt;
&#039;&lt;br /&gt;
&lt;br /&gt;
Restart=always&lt;br /&gt;
RestartSec=5&lt;br /&gt;
TimeoutStartSec=120&lt;br /&gt;
&lt;br /&gt;
[Install]&lt;br /&gt;
WantedBy=multi-user.target&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After writing this code save it and exit. To activate this service file run the following sequence of code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo systemctl enable webapp.service&lt;br /&gt;
sudo systemctl restart webapp.service&lt;br /&gt;
journalctl -u webapp.service -f &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this you should be able to access the dashboard at http://&amp;lt;IP ADRESS&amp;gt;:9090&lt;br /&gt;
&lt;br /&gt;
== Back-end ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
For detailed information about the backend structure and configuration, see [[Backend|Backend Documentation]].&lt;br /&gt;
&lt;br /&gt;
== Front-end ==&lt;br /&gt;
&lt;br /&gt;
[[Frontend]]&lt;br /&gt;
&lt;br /&gt;
= Users note =&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9232</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9232"/>
		<updated>2026-10-13T10:57:35Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* MQTT Configuration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The backend contains two &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Scripts directory (&amp;lt;code&amp;gt;back-end-node-js/scripts/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains environment variables used specifically by scripts and test files within the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory. These settings are separate from the main backend configuration.&lt;br /&gt;
&lt;br /&gt;
===== Main Backend Environment Variables =====&lt;br /&gt;
&lt;br /&gt;
The main backend &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the bcrypt-hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. The new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
The MQTT protocol is created in the &amp;quot;mqttConnection.js&amp;quot; file, and is the main file for communicating with the robot. To communicate different commands is used:&lt;br /&gt;
* mqttClient.subscribe&lt;br /&gt;
* mqttClient.unsubscribe&lt;br /&gt;
* mqttClient.publish&lt;br /&gt;
* mqttClient.on&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.subscribe =====&lt;br /&gt;
This is used to make the back-end begin to listen to a certain topic. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mqttClient.subscribe(&amp;quot;dtubot/drive/T0/gyroo&amp;quot;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;dtubot&amp;quot; identifies the robot platform.&lt;br /&gt;
* &amp;quot;drive&amp;quot; represents telemetry topics used to receive data from the robot.&lt;br /&gt;
* &amp;quot;T0&amp;quot; is dependent on the number of Teensy Boards and is zero-indexed. It mentions which Teensy board it will listen to.&lt;br /&gt;
* &amp;quot;gyroo&amp;quot; represents the topic that is subscribed to.&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.unsubscribe =====&lt;br /&gt;
This is used to make the back-end stop listening to a topic. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mqttClient.unsubscribe(&amp;quot;dtubot/drive/T0/gyroo&amp;quot;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;dtubot&amp;quot; identifies the robot platform.&lt;br /&gt;
* &amp;quot;drive&amp;quot; represents telemetry topics used to receive data from the robot.&lt;br /&gt;
* &amp;quot;T0&amp;quot; is dependent on the number of Teensy Boards and is zero-indexed. It mentions which Teensy board it will listen to.&lt;br /&gt;
* &amp;quot;gyroo&amp;quot; represents the topic that is subscribed to.&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.publish =====&lt;br /&gt;
This is to send a message to a specific topic, which the robot will receive. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mqttClient.publish(&amp;quot;dtubot/cmd/T0&amp;quot;, &amp;quot;gyroc Start&amp;quot;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;dtubot&amp;quot; identifies the robot platform.&lt;br /&gt;
* &amp;quot;cmd&amp;quot; represents telemetry topics used to send commands to the robot.&lt;br /&gt;
* &amp;quot;T0&amp;quot; is dependent on the number of Teensy Boards and is zero-indexed. It mentions which Teensy board it will listen to.&lt;br /&gt;
* &amp;quot;gyroc Start&amp;quot; is the command that is sent to the robot.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.on =====&lt;br /&gt;
&lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, &lt;br /&gt;
and topics.&lt;br /&gt;
&lt;br /&gt;
====  Service filles Configuration ==== &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;services/&amp;lt;/code&amp;gt; directory contains files responsible for handling specific backend functionalities and communication between different components of the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
Each service is responsible for a particular task, helping separate the application&#039;s functionality and making the codebase easier to maintain.&lt;br /&gt;
&lt;br /&gt;
===== Tab Service =====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;tabService.js&amp;lt;/code&amp;gt; file is responsible for managing MQTT subscriptions based on the active dashboard tab. It communicates with &amp;lt;code&amp;gt;mqttConnection.js&amp;lt;/code&amp;gt; to start and stop subscriptions, ensuring that the backend only subscribes to the data required by the selected tab.&lt;br /&gt;
&lt;br /&gt;
The file contains three main functions:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;tabChanged(previousTabTitle, newTabTitle):&#039;&#039;&#039; Handles switching between dashboard tabs by stopping subscriptions associated with the previously active tab and starting subscriptions required by the newly selected tab.&lt;br /&gt;
* &#039;&#039;&#039;onlyTabClosed(previousTabTitle):&#039;&#039;&#039; Handles closing the last open tab by stopping its associated MQTT subscriptions.&lt;br /&gt;
* &#039;&#039;&#039;tabChangedNoPrevious(newTabTitle):&#039;&#039;&#039; Handles opening a tab when no previous tab was active by starting the subscriptions required by the selected tab.&lt;br /&gt;
&lt;br /&gt;
Each dashboard tab is associated with specific MQTT subscriptions, such as heartbeat data, IMU sensor readings, robot information, and distance sensor data.&lt;br /&gt;
&lt;br /&gt;
When adding a new tab that requires MQTT data, the corresponding subscription handling should be added to the relevant functions in &amp;lt;code&amp;gt;tabService.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
The \&amp;lt;code&amp;gt;security/\&amp;lt;/code&amp;gt; directory contains the script responsible for handling authentication. This script should remain unchanged.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory.&lt;br /&gt;
&lt;br /&gt;
To change the administrator password, follow these steps:&lt;br /&gt;
&lt;br /&gt;
===== Step 1: Generate a New Password Hash =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/generateHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Locate the variable &amp;lt;code&amp;gt;userPassword&amp;lt;/code&amp;gt; and replace its current value with the desired new password.&lt;br /&gt;
# Open a terminal and navigate to the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Run the following command to generate a new bcrypt hash:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node generateHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# Copy the generated hash (the second output in the terminal).&lt;br /&gt;
&lt;br /&gt;
===== Step 2: Update the Environment Variable =====&lt;br /&gt;
&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;).&lt;br /&gt;
# Locate the &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
# Replace its existing value with the newly generated bcrypt hash.&lt;br /&gt;
# Save the file and restart the backend application to apply the changes.&lt;br /&gt;
# To restart the backend application, go to the robot&#039;s terminal and type &amp;lt;code&amp;gt;sudo systemctl restart webapp.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Step 3: Verify the New Password =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/testHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Update the test password to match the newly chosen administrator password.&lt;br /&gt;
# Ensure that the test script compares the new password against the newly generated hash.&lt;br /&gt;
# Run the test script from the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node testHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# The script should return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the password matches the hash, or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; if they do not match.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The administrator password must always be hashed using bcrypt before being stored in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file. Never store plaintext passwords in environment variables or commit passwords and hashes to version control.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
If a new session needs to be generated, type from the root directory &lt;br /&gt;
&amp;lt;code&amp;gt; node -e &amp;quot;console.log(require(&#039;crypto&#039;).randomBytes(32).toString(&#039;hex&#039;))&amp;quot; &amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9231</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9231"/>
		<updated>2026-10-13T10:57:07Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Backend Architecutre */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The backend contains two &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Scripts directory (&amp;lt;code&amp;gt;back-end-node-js/scripts/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains environment variables used specifically by scripts and test files within the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory. These settings are separate from the main backend configuration.&lt;br /&gt;
&lt;br /&gt;
===== Main Backend Environment Variables =====&lt;br /&gt;
&lt;br /&gt;
The main backend &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the bcrypt-hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. The new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
The MQTT protocol is created in the &amp;quot;mqttConnection.js&amp;quot; file, and is the main file for communicating with the robot. To communicate different commands is used:&lt;br /&gt;
* mqttClient.subscribe&lt;br /&gt;
* mqttClient.unsubscribe&lt;br /&gt;
* mqttClient.publish&lt;br /&gt;
* mqttClient.on&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.subscribe =====&lt;br /&gt;
This is used to make the back-end begin to listen to a certain topic. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 mqttClient.subscribe(&amp;quot;dtubot/drive/T0/gyroo&amp;quot;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;dtubot&amp;quot; identifies the robot platform.&lt;br /&gt;
* &amp;quot;drive&amp;quot; represents telemetry topics used to receive data from the robot.&lt;br /&gt;
* &amp;quot;T0&amp;quot; is dependent on the number of Teensy Boards and is zero-indexed. It mentions which Teensy board it will listen to.&lt;br /&gt;
* &amp;quot;gyroo&amp;quot; represents the topic that is subscribed to.&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.unsubscribe =====&lt;br /&gt;
This is used to make the back-end stop listening to a topic. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 mqttClient.unsubscribe(&amp;quot;dtubot/drive/T0/gyroo&amp;quot;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;dtubot&amp;quot; identifies the robot platform.&lt;br /&gt;
* &amp;quot;drive&amp;quot; represents telemetry topics used to receive data from the robot.&lt;br /&gt;
* &amp;quot;T0&amp;quot; is dependent on the number of Teensy Boards and is zero-indexed. It mentions which Teensy board it will listen to.&lt;br /&gt;
* &amp;quot;gyroo&amp;quot; represents the topic that is subscribed to.&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.publish =====&lt;br /&gt;
This is to send a message to a specific topic, which the robot will receive. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mqttClient.publish(&amp;quot;dtubot/cmd/T0&amp;quot;, &amp;quot;gyroc Start&amp;quot;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;dtubot&amp;quot; identifies the robot platform.&lt;br /&gt;
* &amp;quot;cmd&amp;quot; represents telemetry topics used to send commands to the robot.&lt;br /&gt;
* &amp;quot;T0&amp;quot; is dependent on the number of Teensy Boards and is zero-indexed. It mentions which Teensy board it will listen to.&lt;br /&gt;
* &amp;quot;gyroc Start&amp;quot; is the command that is sent to the robot.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.on =====&lt;br /&gt;
&lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, &lt;br /&gt;
and topics.&lt;br /&gt;
&lt;br /&gt;
====  Service filles Configuration ==== &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;services/&amp;lt;/code&amp;gt; directory contains files responsible for handling specific backend functionalities and communication between different components of the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
Each service is responsible for a particular task, helping separate the application&#039;s functionality and making the codebase easier to maintain.&lt;br /&gt;
&lt;br /&gt;
===== Tab Service =====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;tabService.js&amp;lt;/code&amp;gt; file is responsible for managing MQTT subscriptions based on the active dashboard tab. It communicates with &amp;lt;code&amp;gt;mqttConnection.js&amp;lt;/code&amp;gt; to start and stop subscriptions, ensuring that the backend only subscribes to the data required by the selected tab.&lt;br /&gt;
&lt;br /&gt;
The file contains three main functions:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;tabChanged(previousTabTitle, newTabTitle):&#039;&#039;&#039; Handles switching between dashboard tabs by stopping subscriptions associated with the previously active tab and starting subscriptions required by the newly selected tab.&lt;br /&gt;
* &#039;&#039;&#039;onlyTabClosed(previousTabTitle):&#039;&#039;&#039; Handles closing the last open tab by stopping its associated MQTT subscriptions.&lt;br /&gt;
* &#039;&#039;&#039;tabChangedNoPrevious(newTabTitle):&#039;&#039;&#039; Handles opening a tab when no previous tab was active by starting the subscriptions required by the selected tab.&lt;br /&gt;
&lt;br /&gt;
Each dashboard tab is associated with specific MQTT subscriptions, such as heartbeat data, IMU sensor readings, robot information, and distance sensor data.&lt;br /&gt;
&lt;br /&gt;
When adding a new tab that requires MQTT data, the corresponding subscription handling should be added to the relevant functions in &amp;lt;code&amp;gt;tabService.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
The \&amp;lt;code&amp;gt;security/\&amp;lt;/code&amp;gt; directory contains the script responsible for handling authentication. This script should remain unchanged.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory.&lt;br /&gt;
&lt;br /&gt;
To change the administrator password, follow these steps:&lt;br /&gt;
&lt;br /&gt;
===== Step 1: Generate a New Password Hash =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/generateHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Locate the variable &amp;lt;code&amp;gt;userPassword&amp;lt;/code&amp;gt; and replace its current value with the desired new password.&lt;br /&gt;
# Open a terminal and navigate to the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Run the following command to generate a new bcrypt hash:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node generateHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# Copy the generated hash (the second output in the terminal).&lt;br /&gt;
&lt;br /&gt;
===== Step 2: Update the Environment Variable =====&lt;br /&gt;
&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;).&lt;br /&gt;
# Locate the &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
# Replace its existing value with the newly generated bcrypt hash.&lt;br /&gt;
# Save the file and restart the backend application to apply the changes.&lt;br /&gt;
# To restart the backend application, go to the robot&#039;s terminal and type &amp;lt;code&amp;gt;sudo systemctl restart webapp.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Step 3: Verify the New Password =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/testHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Update the test password to match the newly chosen administrator password.&lt;br /&gt;
# Ensure that the test script compares the new password against the newly generated hash.&lt;br /&gt;
# Run the test script from the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node testHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# The script should return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the password matches the hash, or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; if they do not match.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The administrator password must always be hashed using bcrypt before being stored in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file. Never store plaintext passwords in environment variables or commit passwords and hashes to version control.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
If a new session needs to be generated, type from the root directory &lt;br /&gt;
&amp;lt;code&amp;gt; node -e &amp;quot;console.log(require(&#039;crypto&#039;).randomBytes(32).toString(&#039;hex&#039;))&amp;quot; &amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9230</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9230"/>
		<updated>2026-10-13T10:57:01Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The backend contains two &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Scripts directory (&amp;lt;code&amp;gt;back-end-node-js/scripts/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains environment variables used specifically by scripts and test files within the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory. These settings are separate from the main backend configuration.&lt;br /&gt;
&lt;br /&gt;
===== Main Backend Environment Variables =====&lt;br /&gt;
&lt;br /&gt;
The main backend &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the bcrypt-hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. The new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
The MQTT protocol is created in the &amp;quot;mqttConnection.js&amp;quot; file, and is the main file for communicating with the robot. To communicate different commands is used:&lt;br /&gt;
* mqttClient.subscribe&lt;br /&gt;
* mqttClient.unsubscribe&lt;br /&gt;
* mqttClient.publish&lt;br /&gt;
* mqttClient.on&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.subscribe =====&lt;br /&gt;
This is used to make the back-end begin to listen to a certain topic. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 mqttClient.subscribe(&amp;quot;dtubot/drive/T0/gyroo&amp;quot;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;dtubot&amp;quot; identifies the robot platform.&lt;br /&gt;
* &amp;quot;drive&amp;quot; represents telemetry topics used to receive data from the robot.&lt;br /&gt;
* &amp;quot;T0&amp;quot; is dependent on the number of Teensy Boards and is zero-indexed. It mentions which Teensy board it will listen to.&lt;br /&gt;
* &amp;quot;gyroo&amp;quot; represents the topic that is subscribed to.&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.unsubscribe =====&lt;br /&gt;
This is used to make the back-end stop listening to a topic. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 mqttClient.unsubscribe(&amp;quot;dtubot/drive/T0/gyroo&amp;quot;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;dtubot&amp;quot; identifies the robot platform.&lt;br /&gt;
* &amp;quot;drive&amp;quot; represents telemetry topics used to receive data from the robot.&lt;br /&gt;
* &amp;quot;T0&amp;quot; is dependent on the number of Teensy Boards and is zero-indexed. It mentions which Teensy board it will listen to.&lt;br /&gt;
* &amp;quot;gyroo&amp;quot; represents the topic that is subscribed to.&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.publish =====&lt;br /&gt;
This is to send a message to a specific topic, which the robot will receive. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mqttClient.publish(&amp;quot;dtubot/cmd/T0&amp;quot;, &amp;quot;gyroc Start&amp;quot;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;dtubot&amp;quot; identifies the robot platform.&lt;br /&gt;
* &amp;quot;cmd&amp;quot; represents telemetry topics used to send commands to the robot.&lt;br /&gt;
* &amp;quot;T0&amp;quot; is dependent on the number of Teensy Boards and is zero-indexed. It mentions which Teensy board it will listen to.&lt;br /&gt;
* &amp;quot;gyroc Start&amp;quot; is the command that is sent to the robot.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.on =====&lt;br /&gt;
&lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, &lt;br /&gt;
and topics.&lt;br /&gt;
&lt;br /&gt;
====  Service filles Configuration ==== &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;services/&amp;lt;/code&amp;gt; directory contains files responsible for handling specific backend functionalities and communication between different components of the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
Each service is responsible for a particular task, helping separate the application&#039;s functionality and making the codebase easier to maintain.&lt;br /&gt;
&lt;br /&gt;
===== Tab Service =====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;tabService.js&amp;lt;/code&amp;gt; file is responsible for managing MQTT subscriptions based on the active dashboard tab. It communicates with &amp;lt;code&amp;gt;mqttConnection.js&amp;lt;/code&amp;gt; to start and stop subscriptions, ensuring that the backend only subscribes to the data required by the selected tab.&lt;br /&gt;
&lt;br /&gt;
The file contains three main functions:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;tabChanged(previousTabTitle, newTabTitle):&#039;&#039;&#039; Handles switching between dashboard tabs by stopping subscriptions associated with the previously active tab and starting subscriptions required by the newly selected tab.&lt;br /&gt;
* &#039;&#039;&#039;onlyTabClosed(previousTabTitle):&#039;&#039;&#039; Handles closing the last open tab by stopping its associated MQTT subscriptions.&lt;br /&gt;
* &#039;&#039;&#039;tabChangedNoPrevious(newTabTitle):&#039;&#039;&#039; Handles opening a tab when no previous tab was active by starting the subscriptions required by the selected tab.&lt;br /&gt;
&lt;br /&gt;
Each dashboard tab is associated with specific MQTT subscriptions, such as heartbeat data, IMU sensor readings, robot information, and distance sensor data.&lt;br /&gt;
&lt;br /&gt;
When adding a new tab that requires MQTT data, the corresponding subscription handling should be added to the relevant functions in &amp;lt;code&amp;gt;tabService.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
The \&amp;lt;code&amp;gt;security/\&amp;lt;/code&amp;gt; directory contains the script responsible for handling authentication. This script should remain unchanged.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory.&lt;br /&gt;
&lt;br /&gt;
To change the administrator password, follow these steps:&lt;br /&gt;
&lt;br /&gt;
===== Step 1: Generate a New Password Hash =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/generateHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Locate the variable &amp;lt;code&amp;gt;userPassword&amp;lt;/code&amp;gt; and replace its current value with the desired new password.&lt;br /&gt;
# Open a terminal and navigate to the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Run the following command to generate a new bcrypt hash:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node generateHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# Copy the generated hash (the second output in the terminal).&lt;br /&gt;
&lt;br /&gt;
===== Step 2: Update the Environment Variable =====&lt;br /&gt;
&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;).&lt;br /&gt;
# Locate the &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
# Replace its existing value with the newly generated bcrypt hash.&lt;br /&gt;
# Save the file and restart the backend application to apply the changes.&lt;br /&gt;
# To restart the backend application, go to the robot&#039;s terminal and type &amp;lt;code&amp;gt;sudo systemctl restart webapp.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Step 3: Verify the New Password =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/testHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Update the test password to match the newly chosen administrator password.&lt;br /&gt;
# Ensure that the test script compares the new password against the newly generated hash.&lt;br /&gt;
# Run the test script from the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node testHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# The script should return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the password matches the hash, or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; if they do not match.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The administrator password must always be hashed using bcrypt before being stored in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file. Never store plaintext passwords in environment variables or commit passwords and hashes to version control.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
If a new session needs to be generated, type from the root directory &lt;br /&gt;
&amp;lt;code&amp;gt; node -e &amp;quot;console.log(require(&#039;crypto&#039;).randomBytes(32).toString(&#039;hex&#039;))&amp;quot; &amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Robot_dashboard&amp;diff=9229</id>
		<title>Robot dashboard</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Robot_dashboard&amp;diff=9229"/>
		<updated>2026-10-13T10:56:46Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Back-end */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard is a browser-based application developed to provide a centralized interface for monitoring and interacting with autonomous robots but as fo. The dashboard enables users to visualize real-time robot data, monitor system status, and interact with different robot components through a customizable interface.&lt;br /&gt;
&lt;br /&gt;
The application was developed as part of a bachelor&#039;s project at the Technical University of Denmark (DTU) in Spring 2026. Its main objective was to create a flexible and user-friendly platform that simplifies robot monitoring and interaction without requiring users to work directly with the underlying communication systems.&lt;br /&gt;
&lt;br /&gt;
The dashboard is specifically designed for the type &#039;Robobot&#039; and is currently only compatible with this robot type. While the system has a modular architecture that allows for future extensions, supporting other robot types would require additional development and modifications to the existing implementation.&lt;br /&gt;
&lt;br /&gt;
The dashboard consists of a frontend built with React, TypeScript, and Tailwind CSS, and a backend developed using Node.js and Express. Communication between the dashboard and the robots is handled through MQTT, while Socket.IO enables real-time updates between the backend and frontend.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Key Features&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Real-time monitoring:&#039;&#039;&#039; Displays live robot information, including position, status, and sensor data.&lt;br /&gt;
*&#039;&#039;&#039;Customizable dashboard:&#039;&#039;&#039; Allows users to organize and interact with different widgets across multiple tabs.&lt;br /&gt;
* &#039;&#039;&#039;Robot interaction:&#039;&#039;&#039; Provides an interface for monitoring and interacting with robot components.&lt;br /&gt;
* &#039;&#039;&#039;Widget-based interface:&#039;&#039;&#039; Includes widgets for robot information, position, driver controls, edge sensors, and debugging.&lt;br /&gt;
* &#039;&#039;&#039;User authentication:&#039;&#039;&#039; Restricts dashboard access through a password-based login system.&lt;br /&gt;
&lt;br /&gt;
The dashboard is designed to provide a foundation for future development, allowing additional widgets and functionalities to be integrated as needed.&lt;br /&gt;
&lt;br /&gt;
= Developers note =&lt;br /&gt;
&lt;br /&gt;
This following section is for developers, it goes through the set up procedure and how the back-end and front-end is set up for further development. &lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
For further development of the dashboard these are the requirements to have.&lt;br /&gt;
* Have installed Node.js&lt;br /&gt;
* Have installed npm&lt;br /&gt;
* Have a code editor (VScode or other)&lt;br /&gt;
* Have Downloaded Type-Script&lt;br /&gt;
&lt;br /&gt;
== Set up ==&lt;br /&gt;
&lt;br /&gt;
Before setting up the robot dashboard two necessary software programs is required.&lt;br /&gt;
&lt;br /&gt;
# A file management software (Windows: RealFTP, Mac: FileZilla)&lt;br /&gt;
# A file editing software (Windows: PuTTY, Mac: Terminal)&lt;br /&gt;
&lt;br /&gt;
=== Installing nodejs and npm on the robot ===&lt;br /&gt;
For the dashboard software to function it is important to make sure that node.js and npm is installed on the robot. To check this run the following code in the terminal&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
npm -v&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
node -v&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If npm and node is not installed, install them using the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt install -y nodejs npm&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== File placement ===&lt;br /&gt;
&lt;br /&gt;
To make the dashboard software functional we need to transfer the necessary files. It is important that the files are in the correct placement with the correct names for the software to start when the system boots.&lt;br /&gt;
&lt;br /&gt;
When transferring the files locate the path:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
/home/local/svn/robobot/&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a folder named &amp;quot;Browser-based-dashboard-for-autonomous-robots&amp;quot; such that the folder path looks like this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
/home/local/svn/robobot/Browser-based-dashboard-for-autonomous-robots&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this folder we will transfer the back-end and the front-end. It is important that the back-end folder is called &amp;quot;back-end-node-js&amp;quot; as this name is used for the software to start when the system boots. Otherwise you will need to change the work directory in the upcomming service file.&lt;br /&gt;
&lt;br /&gt;
When the back-end and front-end have been transferred to the robot in the &amp;quot;Browser-based-dashboard-for-autonomous-robots&amp;quot; folder, the following commands will be needed for each folder.&lt;br /&gt;
&lt;br /&gt;
==== back-end ====&lt;br /&gt;
In the back-end run the following commands to make sure every needed package is installed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install&lt;br /&gt;
npm install socket.io-client&lt;br /&gt;
npm audit fix&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== front-end ====&lt;br /&gt;
In the front-end run the following commands to make sure every needed package is installed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install&lt;br /&gt;
npm audit fix&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Making the software start when the system boots  ===&lt;br /&gt;
The first thing is to make sure the robot will start the dashboard software on boot up. To do this we will use the editing software to create a service file using the command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo nano /etc/systemd/system/webapp.service&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will create a file named &amp;quot;webapp.service&amp;quot;, which is responsible for ensuring that the dashboard software starts automatically when the system boots.&lt;br /&gt;
&lt;br /&gt;
In this file write the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Unit]&lt;br /&gt;
Description=Webapp starter that waits for network and MQTT&lt;br /&gt;
Wants=network-online.target&lt;br /&gt;
After=network-online.target&lt;br /&gt;
StartLimitIntervalSec=0&lt;br /&gt;
&lt;br /&gt;
[Service]&lt;br /&gt;
Type=simple&lt;br /&gt;
User=local&lt;br /&gt;
#Change to the backend folder path&lt;br /&gt;
WorkingDirectory=/home/local/svn/robobot/Browser-based-dashboard-for-autonomous-robots/back-end-node-js&lt;br /&gt;
Environment=NODE_ENV=production&lt;br /&gt;
Environment=ROBOT_PORT=9090&lt;br /&gt;
&lt;br /&gt;
#Wait for network&lt;br /&gt;
ExecStartPre=/bin/bash -c &#039;\&lt;br /&gt;
  echo &amp;quot;Waiting for network...&amp;quot;; \&lt;br /&gt;
  until hostname -I &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; do \&lt;br /&gt;
    echo &amp;quot;No IP yet. Retrying...&amp;quot;; \&lt;br /&gt;
    sleep 2; \&lt;br /&gt;
  done; \&lt;br /&gt;
  echo &amp;quot;Network ready.&amp;quot; \&lt;br /&gt;
&#039;&lt;br /&gt;
&lt;br /&gt;
#Start Node with dynamically set ROBOT_HOST&lt;br /&gt;
ExecStart=/bin/bash -c &#039;ROBOT_HOST=$(hostname -I | awk &amp;quot;{print $1}&amp;quot;); \&lt;br /&gt;
        ROBOT_HOST=$(echo &amp;quot;$ROBOT_HOST&amp;quot; | xargs); \&lt;br /&gt;
        echo &amp;quot;Starting web app with ROBOT_HOST=$ROBOT_HOST&amp;quot;; \&lt;br /&gt;
        export ROBOT_HOST; exec /usr/bin/node server.js \&lt;br /&gt;
&#039;&lt;br /&gt;
&lt;br /&gt;
Restart=always&lt;br /&gt;
RestartSec=5&lt;br /&gt;
TimeoutStartSec=120&lt;br /&gt;
&lt;br /&gt;
[Install]&lt;br /&gt;
WantedBy=multi-user.target&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After writing this code save it and exit. To activate this service file run the following sequence of code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo systemctl enable webapp.service&lt;br /&gt;
sudo systemctl restart webapp.service&lt;br /&gt;
journalctl -u webapp.service -f &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this you should be able to access the dashboard at http://&amp;lt;IP ADRESS&amp;gt;:9090&lt;br /&gt;
&lt;br /&gt;
== Back-end ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
[[Backend]]&lt;br /&gt;
&lt;br /&gt;
== Front-end ==&lt;br /&gt;
&lt;br /&gt;
[[Frontend]]&lt;br /&gt;
&lt;br /&gt;
= Users note =&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9228</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9228"/>
		<updated>2026-10-13T10:55:12Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* MQTT Configuration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The backend contains two &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Scripts directory (&amp;lt;code&amp;gt;back-end-node-js/scripts/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains environment variables used specifically by scripts and test files within the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory. These settings are separate from the main backend configuration.&lt;br /&gt;
&lt;br /&gt;
===== Main Backend Environment Variables =====&lt;br /&gt;
&lt;br /&gt;
The main backend &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the bcrypt-hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. The new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
The MQTT protocol is created in the &amp;quot;mqttConnection.js&amp;quot; file, and is the main file for communicating with the robot. To communicate different commands is used:&lt;br /&gt;
* mqttClient.subscribe&lt;br /&gt;
* mqttClient.unsubscribe&lt;br /&gt;
* mqttClient.publish&lt;br /&gt;
* mqttClient.on&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.subscribe =====&lt;br /&gt;
This is used to make the back-end begin to listen to a certain topic. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 mqttClient.subscribe(&amp;quot;dtubot/drive/T0/gyroo&amp;quot;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;dtubot&amp;quot; identifies the robot platform.&lt;br /&gt;
* &amp;quot;drive&amp;quot; represents telemetry topics used to receive data from the robot.&lt;br /&gt;
* &amp;quot;T0&amp;quot; is dependent on the number of Teensy Boards and is zero-indexed. It mentions which Teensy board it will listen to.&lt;br /&gt;
* &amp;quot;gyroo&amp;quot; represents the topic that is subscribed to.&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.unsubscribe =====&lt;br /&gt;
This is used to make the back-end stop listening to a topic. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 mqttClient.unsubscribe(&amp;quot;dtubot/drive/T0/gyroo&amp;quot;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;dtubot&amp;quot; identifies the robot platform.&lt;br /&gt;
* &amp;quot;drive&amp;quot; represents telemetry topics used to receive data from the robot.&lt;br /&gt;
* &amp;quot;T0&amp;quot; is dependent on the number of Teensy Boards and is zero-indexed. It mentions which Teensy board it will listen to.&lt;br /&gt;
* &amp;quot;gyroo&amp;quot; represents the topic that is subscribed to.&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.publish =====&lt;br /&gt;
This is to send a message to a specific topic, which the robot will receive. The syntax of such message is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
mqttClient.publish(&amp;quot;dtubot/cmd/T0&amp;quot;, &amp;quot;gyroc Start&amp;quot;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;dtubot&amp;quot; identifies the robot platform.&lt;br /&gt;
* &amp;quot;cmd&amp;quot; represents telemetry topics used to send commands to the robot.&lt;br /&gt;
* &amp;quot;T0&amp;quot; is dependent on the number of Teensy Boards and is zero-indexed. It mentions which Teensy board it will listen to.&lt;br /&gt;
* &amp;quot;gyroc Start&amp;quot; is the command that is sent to the robot.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== mqttClient.on =====&lt;br /&gt;
&lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, &lt;br /&gt;
and topics.&lt;br /&gt;
&lt;br /&gt;
====  Service filles Configuration ==== &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;services/&amp;lt;/code&amp;gt; directory contains files responsible for handling specific backend functionalities and communication between different components of the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
Each service is responsible for a particular task, helping separate the application&#039;s functionality and making the codebase easier to maintain.&lt;br /&gt;
&lt;br /&gt;
===== Tab Service =====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;tabService.js&amp;lt;/code&amp;gt; file is responsible for managing MQTT subscriptions based on the active dashboard tab. It communicates with &amp;lt;code&amp;gt;mqttConnection.js&amp;lt;/code&amp;gt; to start and stop subscriptions, ensuring that the backend only subscribes to the data required by the selected tab.&lt;br /&gt;
&lt;br /&gt;
The file contains three main functions:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;tabChanged(previousTabTitle, newTabTitle):&#039;&#039;&#039; Handles switching between dashboard tabs by stopping subscriptions associated with the previously active tab and starting subscriptions required by the newly selected tab.&lt;br /&gt;
* &#039;&#039;&#039;onlyTabClosed(previousTabTitle):&#039;&#039;&#039; Handles closing the last open tab by stopping its associated MQTT subscriptions.&lt;br /&gt;
* &#039;&#039;&#039;tabChangedNoPrevious(newTabTitle):&#039;&#039;&#039; Handles opening a tab when no previous tab was active by starting the subscriptions required by the selected tab.&lt;br /&gt;
&lt;br /&gt;
Each dashboard tab is associated with specific MQTT subscriptions, such as heartbeat data, IMU sensor readings, robot information, and distance sensor data.&lt;br /&gt;
&lt;br /&gt;
When adding a new tab that requires MQTT data, the corresponding subscription handling should be added to the relevant functions in &amp;lt;code&amp;gt;tabService.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
The \&amp;lt;code&amp;gt;security/\&amp;lt;/code&amp;gt; directory contains the script responsible for handling authentication. This script should remain unchanged.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory.&lt;br /&gt;
&lt;br /&gt;
To change the administrator password, follow these steps:&lt;br /&gt;
&lt;br /&gt;
===== Step 1: Generate a New Password Hash =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/generateHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Locate the variable &amp;lt;code&amp;gt;userPassword&amp;lt;/code&amp;gt; and replace its current value with the desired new password.&lt;br /&gt;
# Open a terminal and navigate to the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Run the following command to generate a new bcrypt hash:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node generateHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# Copy the generated hash (the second output in the terminal).&lt;br /&gt;
&lt;br /&gt;
===== Step 2: Update the Environment Variable =====&lt;br /&gt;
&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;).&lt;br /&gt;
# Locate the &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
# Replace its existing value with the newly generated bcrypt hash.&lt;br /&gt;
# Save the file and restart the backend application to apply the changes.&lt;br /&gt;
# To restart the backend application, go to the robot&#039;s terminal and type &amp;lt;code&amp;gt;sudo systemctl restart webapp.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Step 3: Verify the New Password =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/testHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Update the test password to match the newly chosen administrator password.&lt;br /&gt;
# Ensure that the test script compares the new password against the newly generated hash.&lt;br /&gt;
# Run the test script from the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node testHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# The script should return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the password matches the hash, or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; if they do not match.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The administrator password must always be hashed using bcrypt before being stored in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file. Never store plaintext passwords in environment variables or commit passwords and hashes to version control.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
If a new session needs to be generated, type from the root directory &lt;br /&gt;
&amp;lt;code&amp;gt; node -e &amp;quot;console.log(require(&#039;crypto&#039;).randomBytes(32).toString(&#039;hex&#039;))&amp;quot; &amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9227</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9227"/>
		<updated>2026-10-13T10:44:29Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Service filles Configuration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The backend contains two &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Scripts directory (&amp;lt;code&amp;gt;back-end-node-js/scripts/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains environment variables used specifically by scripts and test files within the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory. These settings are separate from the main backend configuration.&lt;br /&gt;
&lt;br /&gt;
===== Main Backend Environment Variables =====&lt;br /&gt;
&lt;br /&gt;
The main backend &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the bcrypt-hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. The new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  Service filles Configuration ==== &lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;services/&amp;lt;/code&amp;gt; directory contains files responsible for handling specific backend functionalities and communication between different components of the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
Each service is responsible for a particular task, helping separate the application&#039;s functionality and making the codebase easier to maintain.&lt;br /&gt;
&lt;br /&gt;
===== Tab Service =====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;tabService.js&amp;lt;/code&amp;gt; file is responsible for managing MQTT subscriptions based on the active dashboard tab. It communicates with &amp;lt;code&amp;gt;mqttConnection.js&amp;lt;/code&amp;gt; to start and stop subscriptions, ensuring that the backend only subscribes to the data required by the selected tab.&lt;br /&gt;
&lt;br /&gt;
The file contains three main functions:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;tabChanged(previousTabTitle, newTabTitle):&#039;&#039;&#039; Handles switching between dashboard tabs by stopping subscriptions associated with the previously active tab and starting subscriptions required by the newly selected tab.&lt;br /&gt;
* &#039;&#039;&#039;onlyTabClosed(previousTabTitle):&#039;&#039;&#039; Handles closing the last open tab by stopping its associated MQTT subscriptions.&lt;br /&gt;
* &#039;&#039;&#039;tabChangedNoPrevious(newTabTitle):&#039;&#039;&#039; Handles opening a tab when no previous tab was active by starting the subscriptions required by the selected tab.&lt;br /&gt;
&lt;br /&gt;
Each dashboard tab is associated with specific MQTT subscriptions, such as heartbeat data, IMU sensor readings, robot information, and distance sensor data.&lt;br /&gt;
&lt;br /&gt;
When adding a new tab that requires MQTT data, the corresponding subscription handling should be added to the relevant functions in &amp;lt;code&amp;gt;tabService.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
The \&amp;lt;code&amp;gt;security/\&amp;lt;/code&amp;gt; directory contains the script responsible for handling authentication. This script should remain unchanged.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory.&lt;br /&gt;
&lt;br /&gt;
To change the administrator password, follow these steps:&lt;br /&gt;
&lt;br /&gt;
===== Step 1: Generate a New Password Hash =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/generateHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Locate the variable &amp;lt;code&amp;gt;userPassword&amp;lt;/code&amp;gt; and replace its current value with the desired new password.&lt;br /&gt;
# Open a terminal and navigate to the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Run the following command to generate a new bcrypt hash:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node generateHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# Copy the generated hash (the second output in the terminal).&lt;br /&gt;
&lt;br /&gt;
===== Step 2: Update the Environment Variable =====&lt;br /&gt;
&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;).&lt;br /&gt;
# Locate the &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
# Replace its existing value with the newly generated bcrypt hash.&lt;br /&gt;
# Save the file and restart the backend application to apply the changes.&lt;br /&gt;
# To restart the backend application, go to the robot&#039;s terminal and type &amp;lt;code&amp;gt;sudo systemctl restart webapp.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Step 3: Verify the New Password =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/testHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Update the test password to match the newly chosen administrator password.&lt;br /&gt;
# Ensure that the test script compares the new password against the newly generated hash.&lt;br /&gt;
# Run the test script from the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node testHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# The script should return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the password matches the hash, or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; if they do not match.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The administrator password must always be hashed using bcrypt before being stored in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file. Never store plaintext passwords in environment variables or commit passwords and hashes to version control.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
If a new session needs to be generated, type from the root directory &lt;br /&gt;
&amp;lt;code&amp;gt; node -e &amp;quot;console.log(require(&#039;crypto&#039;).randomBytes(32).toString(&#039;hex&#039;))&amp;quot; &amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9226</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9226"/>
		<updated>2026-10-13T10:42:04Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Core files and Restrictions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The backend contains two &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Scripts directory (&amp;lt;code&amp;gt;back-end-node-js/scripts/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains environment variables used specifically by scripts and test files within the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory. These settings are separate from the main backend configuration.&lt;br /&gt;
&lt;br /&gt;
===== Main Backend Environment Variables =====&lt;br /&gt;
&lt;br /&gt;
The main backend &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the bcrypt-hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. The new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  Service filles Configuration ==== &lt;br /&gt;
The service files acts as the logic in the code and the ones that can and should be modifcied is &amp;lt;code&amp;gt; tabService &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
The \&amp;lt;code&amp;gt;security/\&amp;lt;/code&amp;gt; directory contains the script responsible for handling authentication. This script should remain unchanged.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory.&lt;br /&gt;
&lt;br /&gt;
To change the administrator password, follow these steps:&lt;br /&gt;
&lt;br /&gt;
===== Step 1: Generate a New Password Hash =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/generateHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Locate the variable &amp;lt;code&amp;gt;userPassword&amp;lt;/code&amp;gt; and replace its current value with the desired new password.&lt;br /&gt;
# Open a terminal and navigate to the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Run the following command to generate a new bcrypt hash:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node generateHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# Copy the generated hash (the second output in the terminal).&lt;br /&gt;
&lt;br /&gt;
===== Step 2: Update the Environment Variable =====&lt;br /&gt;
&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;).&lt;br /&gt;
# Locate the &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
# Replace its existing value with the newly generated bcrypt hash.&lt;br /&gt;
# Save the file and restart the backend application to apply the changes.&lt;br /&gt;
# To restart the backend application, go to the robot&#039;s terminal and type &amp;lt;code&amp;gt;sudo systemctl restart webapp.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Step 3: Verify the New Password =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/testHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Update the test password to match the newly chosen administrator password.&lt;br /&gt;
# Ensure that the test script compares the new password against the newly generated hash.&lt;br /&gt;
# Run the test script from the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node testHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# The script should return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the password matches the hash, or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; if they do not match.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The administrator password must always be hashed using bcrypt before being stored in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file. Never store plaintext passwords in environment variables or commit passwords and hashes to version control.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
If a new session needs to be generated, type from the root directory &lt;br /&gt;
&amp;lt;code&amp;gt; node -e &amp;quot;console.log(require(&#039;crypto&#039;).randomBytes(32).toString(&#039;hex&#039;))&amp;quot; &amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9225</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9225"/>
		<updated>2026-10-13T10:39:13Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Running the backend */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The backend contains two &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Scripts directory (&amp;lt;code&amp;gt;back-end-node-js/scripts/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains environment variables used specifically by scripts and test files within the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory. These settings are separate from the main backend configuration.&lt;br /&gt;
&lt;br /&gt;
===== Main Backend Environment Variables =====&lt;br /&gt;
&lt;br /&gt;
The main backend &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the bcrypt-hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. The new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  Service filles Configuration ==== &lt;br /&gt;
The service files acts as the logic in the code and the ones that can and should be modifcied is &amp;lt;code&amp;gt; tabService &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
The \&amp;lt;code&amp;gt;security/\&amp;lt;/code&amp;gt; directory contains the script responsible for handling authentication. This script should remain unchanged.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory.&lt;br /&gt;
&lt;br /&gt;
To change the administrator password, follow these steps:&lt;br /&gt;
&lt;br /&gt;
===== Step 1: Generate a New Password Hash =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/generateHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Locate the variable &amp;lt;code&amp;gt;userPassword&amp;lt;/code&amp;gt; and replace its current value with the desired new password.&lt;br /&gt;
# Open a terminal and navigate to the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Run the following command to generate a new bcrypt hash:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node generateHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# Copy the generated hash (the second output in the terminal).&lt;br /&gt;
&lt;br /&gt;
===== Step 2: Update the Environment Variable =====&lt;br /&gt;
&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;).&lt;br /&gt;
# Locate the &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
# Replace its existing value with the newly generated bcrypt hash.&lt;br /&gt;
# Save the file and restart the backend application to apply the changes.&lt;br /&gt;
# To restart the backend application, go to the robot&#039;s terminal and type &amp;lt;code&amp;gt;sudo systemctl restart webapp.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Step 3: Verify the New Password =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/testHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Update the test password to match the newly chosen administrator password.&lt;br /&gt;
# Ensure that the test script compares the new password against the newly generated hash.&lt;br /&gt;
# Run the test script from the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node testHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# The script should return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the password matches the hash, or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; if they do not match.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The administrator password must always be hashed using bcrypt before being stored in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file. Never store plaintext passwords in environment variables or commit passwords and hashes to version control.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
If a new session needs to be generated, type from the root directory &lt;br /&gt;
&amp;lt;code&amp;gt; node -e &amp;quot;console.log(require(&#039;crypto&#039;).randomBytes(32).toString(&#039;hex&#039;))&amp;quot; &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9224</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9224"/>
		<updated>2026-10-13T10:38:20Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* API Configuration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The backend contains two &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Scripts directory (&amp;lt;code&amp;gt;back-end-node-js/scripts/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains environment variables used specifically by scripts and test files within the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory. These settings are separate from the main backend configuration.&lt;br /&gt;
&lt;br /&gt;
===== Main Backend Environment Variables =====&lt;br /&gt;
&lt;br /&gt;
The main backend &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the bcrypt-hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. The new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  Service filles Configuration ==== &lt;br /&gt;
The service files acts as the logic in the code and the ones that can and should be modifcied is &amp;lt;code&amp;gt; tabService &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
The \&amp;lt;code&amp;gt;security/\&amp;lt;/code&amp;gt; directory contains the script responsible for handling authentication. This script should remain unchanged.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory.&lt;br /&gt;
&lt;br /&gt;
To change the administrator password, follow these steps:&lt;br /&gt;
&lt;br /&gt;
===== Step 1: Generate a New Password Hash =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/generateHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Locate the variable &amp;lt;code&amp;gt;userPassword&amp;lt;/code&amp;gt; and replace its current value with the desired new password.&lt;br /&gt;
# Open a terminal and navigate to the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Run the following command to generate a new bcrypt hash:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node generateHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# Copy the generated hash (the second output in the terminal).&lt;br /&gt;
&lt;br /&gt;
===== Step 2: Update the Environment Variable =====&lt;br /&gt;
&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;).&lt;br /&gt;
# Locate the &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
# Replace its existing value with the newly generated bcrypt hash.&lt;br /&gt;
# Save the file and restart the backend application to apply the changes.&lt;br /&gt;
# To restart the backend application, go to the robot&#039;s terminal and type &amp;lt;code&amp;gt;sudo systemctl restart webapp.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Step 3: Verify the New Password =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/testHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Update the test password to match the newly chosen administrator password.&lt;br /&gt;
# Ensure that the test script compares the new password against the newly generated hash.&lt;br /&gt;
# Run the test script from the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node testHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# The script should return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the password matches the hash, or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; if they do not match.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The administrator password must always be hashed using bcrypt before being stored in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file. Never store plaintext passwords in environment variables or commit passwords and hashes to version control.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
If a new session needs to be generated, type from the root directory &lt;br /&gt;
&amp;lt;code&amp;gt; node -e &amp;quot;console.log(require(&#039;crypto&#039;).randomBytes(32).toString(&#039;hex&#039;))&amp;quot; &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Frontend&amp;diff=9223</id>
		<title>Frontend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Frontend&amp;diff=9223"/>
		<updated>2026-10-13T10:37:35Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Frontend ==&lt;br /&gt;
&lt;br /&gt;
The frontend is mainly structured around components, each responsible for specific functions. These components are used within pages, where they are combined to create complete pages with the required functionality. The frontend is developed using TypeScript, React, and Redux, with Tailwind CSS used for styling.&lt;br /&gt;
&lt;br /&gt;
=== Components ===&lt;br /&gt;
Currently, the frontend consists of seven different components, organized as follows:&lt;br /&gt;
&lt;br /&gt;
==== button ====&lt;br /&gt;
&lt;br /&gt;
the tsx-file defines the button&#039;s properties and functionality, including its type, size, color, and whether it is disabled. This file also creates the HTML button element &amp;lt;button&amp;gt; that can be used in the page you want to add a button.&lt;br /&gt;
&lt;br /&gt;
the ts-file defines the button&#039;s styling using Tailwind CSS, including colors, text sizes, rounded corners, and hover effects. This file does not contain any HTML.&lt;br /&gt;
&lt;br /&gt;
==== dropdown ====&lt;br /&gt;
&lt;br /&gt;
The dropdown menu does not have any specific properties of its own. It is mainly used as a placeholder that appears on the screen when the user clicks a button or hovers over it. The dropdown menu contains different buttons and does not require a separate `.ts` file, as it does not have any styling of its own.&lt;br /&gt;
&lt;br /&gt;
==== inputfield ====&lt;br /&gt;
&lt;br /&gt;
The InputField component It supports both text and password inputs and handles user interactions through event handlers such as onChange and onKeyDown. This component also uses Tailwind CSS for styling, which is defined directly within the tsx.&lt;br /&gt;
&lt;br /&gt;
==== popupwindow ====&lt;br /&gt;
&lt;br /&gt;
PopupWindow consists of a TSX file and a TS file. The TSX file defines the basic structure and functionality of the popup window, providing a default version that can be reused. The TS file defines the styling using Tailwind CSS, allowing the popup window to be customized with different sizes and colors.&lt;br /&gt;
&lt;br /&gt;
The PopupWindowContent folder contains the completed popup windows, which currently consist of two different components: SettingsPopupWindow and WidgetPopupWindow.&lt;br /&gt;
&lt;br /&gt;
The reason these two components are not included in the general TS and TSX files is that they contain different content and functionality. When a new type of popup window is needed, a new component can be created under PopupWindowContent, where its specific content and functionality are defined, while the basic structure and styling are reused from PopupWindow.&lt;br /&gt;
&lt;br /&gt;
==== sidebar ====&lt;br /&gt;
&lt;br /&gt;
The Sidebar component consists of a TSX file and a TS file. The TSX file defines the basic structure and functionality of the sidebar, including the ability to open, close, and resize it. It also stores the sidebar&#039;s state and previous width, allowing the user&#039;s settings to be preserved during the session.&lt;br /&gt;
&lt;br /&gt;
The TS file defines the styling using Tailwind CSS. This includes the sidebar colors, the positioning of the toggle button and resize bar, and the rotation of the arrow when the sidebar is opened or closed.&lt;br /&gt;
&lt;br /&gt;
The `SidebarContent` folder contains the left and right sidebar components. This is where developers can modify the content and functionality of each individual sidebar without changing the general Sidebar component.&lt;br /&gt;
&lt;br /&gt;
The reason for this structure is to separate the basic structure and styling from the specific content of each sidebar. This allows developers to reuse the existing Sidebar component when creating new sidebars, while customizing their content and functionality as needed.&lt;br /&gt;
&lt;br /&gt;
==== tabbar ====&lt;br /&gt;
&lt;br /&gt;
The Tabbar is structured into four TSX files, each responsible for a specific part of the tab system. This structure separates the management of tabs from their content and layouts, making it easier for developers to maintain and extend the system.&lt;br /&gt;
&lt;br /&gt;
The tabbar.tsx file contains the main functionality of the tab bar. It handles opening, closing, and switching between tabs, as well as managing which tabs are currently open. It also uses React Router for navigation and Socket.IO to notify the backend when the active tab changes.&lt;br /&gt;
&lt;br /&gt;
The tabs.tsx file contains the predefined tabs available in the dashboard. Each tab defines which widgets should be displayed and which layout should be used.&lt;br /&gt;
&lt;br /&gt;
If a developer wants to modify the widgets displayed in an existing tab or create a new tab, this is where its content and layout are defined.&lt;br /&gt;
&lt;br /&gt;
The tabLayout.tsx file contains the different layout templates used by the tabs. Each layout determines how the widgets are arranged on the screen, including their positions and sizes.&lt;br /&gt;
&lt;br /&gt;
The layouts use resizable panels, allowing users to adjust the size of individual widgets. The styling is defined directly within the TSX file using Tailwind CSS.&lt;br /&gt;
&lt;br /&gt;
If a developer wants to create a new layout, modify an existing one, or change the styling of the layouts, changes should be made in this file.&lt;br /&gt;
&lt;br /&gt;
The tabMap.tsx file maps tab names to their corresponding React components. This allows the application to identify the correct component based on the tab name.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When creating a new tab, developers should first define the tab in `tabs.tsx`, where they select the required layout and widgets.&lt;br /&gt;
&lt;br /&gt;
If the desired layout does not already exist, a new layout can be created in `tabLayout.tsx`.&lt;br /&gt;
&lt;br /&gt;
The new tab must then be registered in the tab mapping and management logic in `tabbar.tsx` so that it can be opened and displayed through the tab bar. If `tabMap.tsx` is used elsewhere in the application, the new tab should also be added there.&lt;br /&gt;
&lt;br /&gt;
This structure allows developers to reuse existing layouts and widgets without having to recreate the tab system for each new tab.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== widget ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Pages ===&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9222</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9222"/>
		<updated>2026-10-13T10:34:44Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Authentication and Session Configuration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The backend contains two &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Scripts directory (&amp;lt;code&amp;gt;back-end-node-js/scripts/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains environment variables used specifically by scripts and test files within the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory. These settings are separate from the main backend configuration.&lt;br /&gt;
&lt;br /&gt;
===== Main Backend Environment Variables =====&lt;br /&gt;
&lt;br /&gt;
The main backend &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the bcrypt-hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. The new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
The \&amp;lt;code&amp;gt;security/\&amp;lt;/code&amp;gt; directory contains the script responsible for handling authentication. This script should remain unchanged.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory.&lt;br /&gt;
&lt;br /&gt;
To change the administrator password, follow these steps:&lt;br /&gt;
&lt;br /&gt;
===== Step 1: Generate a New Password Hash =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/generateHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Locate the variable &amp;lt;code&amp;gt;userPassword&amp;lt;/code&amp;gt; and replace its current value with the desired new password.&lt;br /&gt;
# Open a terminal and navigate to the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Run the following command to generate a new bcrypt hash:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node generateHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# Copy the generated hash (the second output in the terminal).&lt;br /&gt;
&lt;br /&gt;
===== Step 2: Update the Environment Variable =====&lt;br /&gt;
&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;).&lt;br /&gt;
# Locate the &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
# Replace its existing value with the newly generated bcrypt hash.&lt;br /&gt;
# Save the file and restart the backend application to apply the changes.&lt;br /&gt;
# To restart the backend application, go to the robot&#039;s terminal and type &amp;lt;code&amp;gt;sudo systemctl restart webapp.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Step 3: Verify the New Password =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/testHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Update the test password to match the newly chosen administrator password.&lt;br /&gt;
# Ensure that the test script compares the new password against the newly generated hash.&lt;br /&gt;
# Run the test script from the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node testHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# The script should return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the password matches the hash, or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; if they do not match.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The administrator password must always be hashed using bcrypt before being stored in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file. Never store plaintext passwords in environment variables or commit passwords and hashes to version control.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
If a new session needs to be generated, type from the root directory &lt;br /&gt;
&amp;lt;code&amp;gt; node -e &amp;quot;console.log(require(&#039;crypto&#039;).randomBytes(32).toString(&#039;hex&#039;))&amp;quot; &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9221</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9221"/>
		<updated>2026-10-13T10:34:22Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Authentication and Session Configuration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The backend contains two &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Scripts directory (&amp;lt;code&amp;gt;back-end-node-js/scripts/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains environment variables used specifically by scripts and test files within the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory. These settings are separate from the main backend configuration.&lt;br /&gt;
&lt;br /&gt;
===== Main Backend Environment Variables =====&lt;br /&gt;
&lt;br /&gt;
The main backend &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the bcrypt-hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. The new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
The \&amp;lt;code&amp;gt;security/\&amp;lt;/code&amp;gt; directory contains the script responsible for handling authentication. This script should remain unchanged unless modifications to the authentication mechanism are required, as changes may affect the security and functionality of the application.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory.&lt;br /&gt;
&lt;br /&gt;
To change the administrator password, follow these steps:&lt;br /&gt;
&lt;br /&gt;
===== Step 1: Generate a New Password Hash =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/generateHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Locate the variable &amp;lt;code&amp;gt;userPassword&amp;lt;/code&amp;gt; and replace its current value with the desired new password.&lt;br /&gt;
# Open a terminal and navigate to the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Run the following command to generate a new bcrypt hash:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node generateHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# Copy the generated hash (the second output in the terminal).&lt;br /&gt;
&lt;br /&gt;
===== Step 2: Update the Environment Variable =====&lt;br /&gt;
&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;).&lt;br /&gt;
# Locate the &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
# Replace its existing value with the newly generated bcrypt hash.&lt;br /&gt;
# Save the file and restart the backend application to apply the changes.&lt;br /&gt;
# To restart the backend application, go to the robot&#039;s terminal and type &amp;lt;code&amp;gt;sudo systemctl restart webapp.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Step 3: Verify the New Password =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/testHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Update the test password to match the newly chosen administrator password.&lt;br /&gt;
# Ensure that the test script compares the new password against the newly generated hash.&lt;br /&gt;
# Run the test script from the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node testHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# The script should return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the password matches the hash, or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; if they do not match.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The administrator password must always be hashed using bcrypt before being stored in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file. Never store plaintext passwords in environment variables or commit passwords and hashes to version control.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
If a new session needs to be generated, type from the root directory &lt;br /&gt;
&amp;lt;code&amp;gt; node -e &amp;quot;console.log(require(&#039;crypto&#039;).randomBytes(32).toString(&#039;hex&#039;))&amp;quot; &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9220</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9220"/>
		<updated>2026-10-13T10:29:16Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Authentication and Session Configuration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The backend contains two &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Scripts directory (&amp;lt;code&amp;gt;back-end-node-js/scripts/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains environment variables used specifically by scripts and test files within the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory. These settings are separate from the main backend configuration.&lt;br /&gt;
&lt;br /&gt;
===== Main Backend Environment Variables =====&lt;br /&gt;
&lt;br /&gt;
The main backend &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the bcrypt-hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. The new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory.&lt;br /&gt;
&lt;br /&gt;
To change the administrator password, follow these steps:&lt;br /&gt;
&lt;br /&gt;
===== Step 1: Generate a New Password Hash =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/generateHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Locate the variable &amp;lt;code&amp;gt;userPassword&amp;lt;/code&amp;gt; and replace its current value with the desired new password.&lt;br /&gt;
# Open a terminal and navigate to the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Run the following command to generate a new bcrypt hash:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node generateHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# Copy the generated hash (the second output in the terminal).&lt;br /&gt;
&lt;br /&gt;
===== Step 2: Update the Environment Variable =====&lt;br /&gt;
&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;).&lt;br /&gt;
# Locate the &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
# Replace its existing value with the newly generated bcrypt hash.&lt;br /&gt;
# Save the file and restart the backend application to apply the changes.&lt;br /&gt;
# To restart the backend application, go to the robot&#039;s terminal and type &amp;lt;code&amp;gt;sudo systemctl restart webapp.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Step 3: Verify the New Password =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/testHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Update the test password to match the newly chosen administrator password.&lt;br /&gt;
# Ensure that the test script compares the new password against the newly generated hash.&lt;br /&gt;
# Run the test script from the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node testHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# The script should return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the password matches the hash, or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; if they do not match.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The administrator password must always be hashed using bcrypt before being stored in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file. Never store plaintext passwords in environment variables or commit passwords and hashes to version control.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
If a new session needs to be generated, type from the root directory &lt;br /&gt;
&amp;lt;code&amp;gt; node -e &amp;quot;console.log(require(&#039;crypto&#039;).randomBytes(32).toString(&#039;hex&#039;))&amp;quot; &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9219</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9219"/>
		<updated>2026-10-13T10:27:36Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Session Secret */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The backend contains two &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Scripts directory (&amp;lt;code&amp;gt;back-end-node-js/scripts/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains environment variables used specifically by scripts and test files within the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory. These settings are separate from the main backend configuration.&lt;br /&gt;
&lt;br /&gt;
===== Main Backend Environment Variables =====&lt;br /&gt;
&lt;br /&gt;
The main backend &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the bcrypt-hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. The new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
====  Authentication and Session Configuration ==== &lt;br /&gt;
Explain which authentication and session settings&lt;br /&gt;
can be modified.&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory.&lt;br /&gt;
&lt;br /&gt;
To change the administrator password, follow these steps:&lt;br /&gt;
&lt;br /&gt;
===== Step 1: Generate a New Password Hash =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/generateHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Locate the variable &amp;lt;code&amp;gt;userPassword&amp;lt;/code&amp;gt; and replace its current value with the desired new password.&lt;br /&gt;
# Open a terminal and navigate to the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Run the following command to generate a new bcrypt hash:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node generateHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# Copy the generated hash (the second output in the terminal).&lt;br /&gt;
&lt;br /&gt;
===== Step 2: Update the Environment Variable =====&lt;br /&gt;
&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;).&lt;br /&gt;
# Locate the &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
# Replace its existing value with the newly generated bcrypt hash.&lt;br /&gt;
# Save the file and restart the backend application to apply the changes.&lt;br /&gt;
# To restart the backend application, go to the robot&#039;s terminal and type &amp;lt;code&amp;gt;sudo systemctl restart webapp.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Step 3: Verify the New Password =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/testHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Update the test password to match the newly chosen administrator password.&lt;br /&gt;
# Ensure that the test script compares the new password against the newly generated hash.&lt;br /&gt;
# Run the test script from the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node testHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# The script should return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the password matches the hash, or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; if they do not match.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The administrator password must always be hashed using bcrypt before being stored in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file. Never store plaintext passwords in environment variables or commit passwords and hashes to version control.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
If a new session needs to be generated, type from the root directory &lt;br /&gt;
&amp;lt;code&amp;gt; node -e &amp;quot;console.log(require(&#039;crypto&#039;).randomBytes(32).toString(&#039;hex&#039;))&amp;quot; &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9218</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9218"/>
		<updated>2026-10-13T10:27:30Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Session Secret */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The backend contains two &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Scripts directory (&amp;lt;code&amp;gt;back-end-node-js/scripts/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains environment variables used specifically by scripts and test files within the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory. These settings are separate from the main backend configuration.&lt;br /&gt;
&lt;br /&gt;
===== Main Backend Environment Variables =====&lt;br /&gt;
&lt;br /&gt;
The main backend &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the bcrypt-hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. The new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
====  Authentication and Session Configuration ==== &lt;br /&gt;
Explain which authentication and session settings&lt;br /&gt;
can be modified.&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory.&lt;br /&gt;
&lt;br /&gt;
To change the administrator password, follow these steps:&lt;br /&gt;
&lt;br /&gt;
===== Step 1: Generate a New Password Hash =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/generateHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Locate the variable &amp;lt;code&amp;gt;userPassword&amp;lt;/code&amp;gt; and replace its current value with the desired new password.&lt;br /&gt;
# Open a terminal and navigate to the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Run the following command to generate a new bcrypt hash:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node generateHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# Copy the generated hash (the second output in the terminal).&lt;br /&gt;
&lt;br /&gt;
===== Step 2: Update the Environment Variable =====&lt;br /&gt;
&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;).&lt;br /&gt;
# Locate the &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
# Replace its existing value with the newly generated bcrypt hash.&lt;br /&gt;
# Save the file and restart the backend application to apply the changes.&lt;br /&gt;
# To restart the backend application, go to the robot&#039;s terminal and type &amp;lt;code&amp;gt;sudo systemctl restart webapp.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Step 3: Verify the New Password =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/testHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Update the test password to match the newly chosen administrator password.&lt;br /&gt;
# Ensure that the test script compares the new password against the newly generated hash.&lt;br /&gt;
# Run the test script from the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node testHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# The script should return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the password matches the hash, or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; if they do not match.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The administrator password must always be hashed using bcrypt before being stored in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file. Never store plaintext passwords in environment variables or commit passwords and hashes to version control.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
If a new session needs to be generated, type from the root directory &amp;lt;code&amp;gt; node -e &amp;quot;console.log(require(&#039;crypto&#039;).randomBytes(32).toString(&#039;hex&#039;))&amp;quot; &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9217</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9217"/>
		<updated>2026-10-13T10:27:13Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Session Secret */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The backend contains two &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Scripts directory (&amp;lt;code&amp;gt;back-end-node-js/scripts/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains environment variables used specifically by scripts and test files within the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory. These settings are separate from the main backend configuration.&lt;br /&gt;
&lt;br /&gt;
===== Main Backend Environment Variables =====&lt;br /&gt;
&lt;br /&gt;
The main backend &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the bcrypt-hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. The new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
====  Authentication and Session Configuration ==== &lt;br /&gt;
Explain which authentication and session settings&lt;br /&gt;
can be modified.&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory.&lt;br /&gt;
&lt;br /&gt;
To change the administrator password, follow these steps:&lt;br /&gt;
&lt;br /&gt;
===== Step 1: Generate a New Password Hash =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/generateHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Locate the variable &amp;lt;code&amp;gt;userPassword&amp;lt;/code&amp;gt; and replace its current value with the desired new password.&lt;br /&gt;
# Open a terminal and navigate to the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Run the following command to generate a new bcrypt hash:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node generateHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# Copy the generated hash (the second output in the terminal).&lt;br /&gt;
&lt;br /&gt;
===== Step 2: Update the Environment Variable =====&lt;br /&gt;
&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;).&lt;br /&gt;
# Locate the &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
# Replace its existing value with the newly generated bcrypt hash.&lt;br /&gt;
# Save the file and restart the backend application to apply the changes.&lt;br /&gt;
# To restart the backend application, go to the robot&#039;s terminal and type &amp;lt;code&amp;gt;sudo systemctl restart webapp.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Step 3: Verify the New Password =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/testHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Update the test password to match the newly chosen administrator password.&lt;br /&gt;
# Ensure that the test script compares the new password against the newly generated hash.&lt;br /&gt;
# Run the test script from the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node testHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# The script should return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the password matches the hash, or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; if they do not match.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The administrator password must always be hashed using bcrypt before being stored in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file. Never store plaintext passwords in environment variables or commit passwords and hashes to version control.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
If a new session needs to be generated type in the root directory &amp;lt;code&amp;gt; node -e &amp;quot;console.log(require(&#039;crypto&#039;).randomBytes(32).toString(&#039;hex&#039;))&amp;quot; &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9216</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9216"/>
		<updated>2026-10-13T10:26:20Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Session Secret */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The backend contains two &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Scripts directory (&amp;lt;code&amp;gt;back-end-node-js/scripts/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains environment variables used specifically by scripts and test files within the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory. These settings are separate from the main backend configuration.&lt;br /&gt;
&lt;br /&gt;
===== Main Backend Environment Variables =====&lt;br /&gt;
&lt;br /&gt;
The main backend &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the bcrypt-hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. The new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
====  Authentication and Session Configuration ==== &lt;br /&gt;
Explain which authentication and session settings&lt;br /&gt;
can be modified.&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory.&lt;br /&gt;
&lt;br /&gt;
To change the administrator password, follow these steps:&lt;br /&gt;
&lt;br /&gt;
===== Step 1: Generate a New Password Hash =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/generateHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Locate the variable &amp;lt;code&amp;gt;userPassword&amp;lt;/code&amp;gt; and replace its current value with the desired new password.&lt;br /&gt;
# Open a terminal and navigate to the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Run the following command to generate a new bcrypt hash:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node generateHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# Copy the generated hash (the second output in the terminal).&lt;br /&gt;
&lt;br /&gt;
===== Step 2: Update the Environment Variable =====&lt;br /&gt;
&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;).&lt;br /&gt;
# Locate the &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
# Replace its existing value with the newly generated bcrypt hash.&lt;br /&gt;
# Save the file and restart the backend application to apply the changes.&lt;br /&gt;
# To restart the backend application, go to the robot&#039;s terminal and type &amp;lt;code&amp;gt;sudo systemctl restart webapp.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Step 3: Verify the New Password =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/testHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Update the test password to match the newly chosen administrator password.&lt;br /&gt;
# Ensure that the test script compares the new password against the newly generated hash.&lt;br /&gt;
# Run the test script from the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node testHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# The script should return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the password matches the hash, or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; if they do not match.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The administrator password must always be hashed using bcrypt before being stored in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file. Never store plaintext passwords in environment variables or commit passwords and hashes to version control.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
If a new session needs to be generated type &amp;lt;code&amp;gt; node -e &amp;quot;console.log(require(&#039;crypto&#039;).randomBytes(32).toString(&#039;hex&#039;))&amp;quot; &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Frontend&amp;diff=9215</id>
		<title>Frontend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Frontend&amp;diff=9215"/>
		<updated>2026-10-13T10:25:32Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Frontend ==&lt;br /&gt;
&lt;br /&gt;
The frontend is mainly structured around components, each responsible for specific functions. These components are used within pages, where they are combined to create complete pages with the required functionality. The frontend is developed using TypeScript, React, and Redux, with Tailwind CSS used for styling.&lt;br /&gt;
&lt;br /&gt;
=== Components ===&lt;br /&gt;
Currently, the frontend consists of seven different components, organized as follows:&lt;br /&gt;
&lt;br /&gt;
==== button ====&lt;br /&gt;
&lt;br /&gt;
the tsx-file defines the button&#039;s properties and functionality, including its type, size, color, and whether it is disabled. This file also creates the HTML button element &amp;lt;button&amp;gt; that can be used in the page you want to add a button.&lt;br /&gt;
&lt;br /&gt;
the ts-file defines the button&#039;s styling using Tailwind CSS, including colors, text sizes, rounded corners, and hover effects. This file does not contain any HTML.&lt;br /&gt;
&lt;br /&gt;
==== dropdown ====&lt;br /&gt;
&lt;br /&gt;
The dropdown menu does not have any specific properties of its own. It is mainly used as a placeholder that appears on the screen when the user clicks a button or hovers over it. The dropdown menu contains different buttons and does not require a separate `.ts` file, as it does not have any styling of its own.&lt;br /&gt;
&lt;br /&gt;
==== inputfield ====&lt;br /&gt;
&lt;br /&gt;
The InputField component It supports both text and password inputs and handles user interactions through event handlers such as onChange and onKeyDown. This component also uses Tailwind CSS for styling, which is defined directly within the tsx.&lt;br /&gt;
&lt;br /&gt;
==== popupwindow ====&lt;br /&gt;
&lt;br /&gt;
PopupWindow consists of a TSX file and a TS file. The TSX file defines the basic structure and functionality of the popup window, providing a default version that can be reused. The TS file defines the styling using Tailwind CSS, allowing the popup window to be customized with different sizes and colors.&lt;br /&gt;
&lt;br /&gt;
The PopupWindowContent folder contains the completed popup windows, which currently consist of two different components: SettingsPopupWindow and WidgetPopupWindow.&lt;br /&gt;
&lt;br /&gt;
The reason these two components are not included in the general TS and TSX files is that they contain different content and functionality. When a new type of popup window is needed, a new component can be created under PopupWindowContent, where its specific content and functionality are defined, while the basic structure and styling are reused from PopupWindow.&lt;br /&gt;
&lt;br /&gt;
==== sidebar ====&lt;br /&gt;
&lt;br /&gt;
The Sidebar component consists of a TSX file and a TS file. The TSX file defines the basic structure and functionality of the sidebar, including the ability to open, close, and resize it. It also stores the sidebar&#039;s state and previous width, allowing the user&#039;s settings to be preserved during the session.&lt;br /&gt;
&lt;br /&gt;
The TS file defines the styling using Tailwind CSS. This includes the sidebar colors, the positioning of the toggle button and resize bar, and the rotation of the arrow when the sidebar is opened or closed.&lt;br /&gt;
&lt;br /&gt;
The `SidebarContent` folder contains the left and right sidebar components. This is where developers can modify the content and functionality of each individual sidebar without changing the general Sidebar component.&lt;br /&gt;
&lt;br /&gt;
The reason for this structure is to separate the basic structure and styling from the specific content of each sidebar. This allows developers to reuse the existing Sidebar component when creating new sidebars, while customizing their content and functionality as needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== tabbar ====&lt;br /&gt;
&lt;br /&gt;
The Tabbar is structured into four TSX files, each responsible for a specific part of the tab system. This structure separates the management of tabs from their content and layouts, making it easier for developers to maintain and extend the system.&lt;br /&gt;
&lt;br /&gt;
The tabbar.tsx file contains the main functionality of the tab bar. It handles opening, closing, and switching between tabs, as well as managing which tabs are currently open. It also uses React Router for navigation and Socket.IO to notify the backend when the active tab changes.&lt;br /&gt;
&lt;br /&gt;
The tabs.tsx file contains the predefined tabs available in the dashboard. Each tab defines which widgets should be displayed and which layout should be used.&lt;br /&gt;
&lt;br /&gt;
If a developer wants to modify the widgets displayed in an existing tab or create a new tab, this is where its content and layout are defined.&lt;br /&gt;
&lt;br /&gt;
The tabLayout.tsx file contains the different layout templates used by the tabs. Each layout determines how the widgets are arranged on the screen, including their positions and sizes.&lt;br /&gt;
&lt;br /&gt;
The layouts use resizable panels, allowing users to adjust the size of individual widgets. The styling is defined directly within the TSX file using Tailwind CSS.&lt;br /&gt;
&lt;br /&gt;
If a developer wants to create a new layout, modify an existing one, or change the styling of the layouts, changes should be made in this file.&lt;br /&gt;
&lt;br /&gt;
The tabMap.tsx file maps tab names to their corresponding React components. This allows the application to identify the correct component based on the tab name.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When creating a new tab, developers should first define the tab in `tabs.tsx`, where they select the required layout and widgets.&lt;br /&gt;
&lt;br /&gt;
If the desired layout does not already exist, a new layout can be created in `tabLayout.tsx`.&lt;br /&gt;
&lt;br /&gt;
The new tab must then be registered in the tab mapping and management logic in `tabbar.tsx` so that it can be opened and displayed through the tab bar. If `tabMap.tsx` is used elsewhere in the application, the new tab should also be added there.&lt;br /&gt;
&lt;br /&gt;
This structure allows developers to reuse existing layouts and widgets without having to recreate the tab system for each new tab.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== widget ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Pages ===&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Frontend&amp;diff=9214</id>
		<title>Frontend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Frontend&amp;diff=9214"/>
		<updated>2026-10-13T10:25:05Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Frontend ==&lt;br /&gt;
&lt;br /&gt;
The frontend is mainly structured around components, each responsible for specific functions. These components are used within pages, where they are combined to create complete pages with the required functionality. The frontend is developed using TypeScript, React, and Redux, with Tailwind CSS used for styling.&lt;br /&gt;
&lt;br /&gt;
=== Components ===&lt;br /&gt;
Currently, the frontend consists of seven different components, organized as follows:&lt;br /&gt;
&lt;br /&gt;
==== button ====&lt;br /&gt;
&lt;br /&gt;
the tsx-file defines the button&#039;s properties and functionality, including its type, size, color, and whether it is disabled. This file also creates the HTML button element &amp;lt;button&amp;gt; that can be used in the page you want to add a button.&lt;br /&gt;
&lt;br /&gt;
the ts-file defines the button&#039;s styling using Tailwind CSS, including colors, text sizes, rounded corners, and hover effects. This file does not contain any HTML.&lt;br /&gt;
&lt;br /&gt;
==== dropdown ====&lt;br /&gt;
&lt;br /&gt;
The dropdown menu does not have any specific properties of its own. It is mainly used as a placeholder that appears on the screen when the user clicks a button or hovers over it. The dropdown menu contains different buttons and does not require a separate `.ts` file, as it does not have any styling of its own.&lt;br /&gt;
&lt;br /&gt;
==== inputfield ====&lt;br /&gt;
&lt;br /&gt;
The InputField component It supports both text and password inputs and handles user interactions through event handlers such as onChange and onKeyDown. This component also uses Tailwind CSS for styling, which is defined directly within the tsx.&lt;br /&gt;
&lt;br /&gt;
==== popupwindow ====&lt;br /&gt;
&lt;br /&gt;
PopupWindow consists of a TSX file and a TS file. The TSX file defines the basic structure and functionality of the popup window, providing a default version that can be reused. The TS file defines the styling using Tailwind CSS, allowing the popup window to be customized with different sizes and colors.&lt;br /&gt;
&lt;br /&gt;
The PopupWindowContent folder contains the completed popup windows, which currently consist of two different components: SettingsPopupWindow and WidgetPopupWindow.&lt;br /&gt;
&lt;br /&gt;
The reason these two components are not included in the general TS and TSX files is that they contain different content and functionality. When a new type of popup window is needed, a new component can be created under PopupWindowContent, where its specific content and functionality are defined, while the basic structure and styling are reused from PopupWindow.&lt;br /&gt;
&lt;br /&gt;
==== sidebar ====&lt;br /&gt;
&lt;br /&gt;
The Sidebar component consists of a TSX file and a TS file. The TSX file defines the basic structure and functionality of the sidebar, including the ability to open, close, and resize it. It also stores the sidebar&#039;s state and previous width, allowing the user&#039;s settings to be preserved during the session.&lt;br /&gt;
&lt;br /&gt;
The TS file defines the styling using Tailwind CSS. This includes the sidebar colors, the positioning of the toggle button and resize bar, and the rotation of the arrow when the sidebar is opened or closed.&lt;br /&gt;
&lt;br /&gt;
The `SidebarContent` folder contains the left and right sidebar components. This is where developers can modify the content and functionality of each individual sidebar without changing the general Sidebar component.&lt;br /&gt;
&lt;br /&gt;
The reason for this structure is to separate the basic structure and styling from the specific content of each sidebar. This allows developers to reuse the existing Sidebar component when creating new sidebars, while customizing their content and functionality as needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== tabbar ====&lt;br /&gt;
&lt;br /&gt;
### Tabbar&lt;br /&gt;
&lt;br /&gt;
The Tabbar is structured into four TSX files, each responsible for a specific part of the tab system. This structure separates the management of tabs from their content and layouts, making it easier for developers to maintain and extend the system.&lt;br /&gt;
&lt;br /&gt;
The tabbar.tsx file contains the main functionality of the tab bar. It handles opening, closing, and switching between tabs, as well as managing which tabs are currently open. It also uses React Router for navigation and Socket.IO to notify the backend when the active tab changes.&lt;br /&gt;
&lt;br /&gt;
The tabs.tsx file contains the predefined tabs available in the dashboard. Each tab defines which widgets should be displayed and which layout should be used.&lt;br /&gt;
&lt;br /&gt;
If a developer wants to modify the widgets displayed in an existing tab or create a new tab, this is where its content and layout are defined.&lt;br /&gt;
&lt;br /&gt;
The tabLayout.tsx file contains the different layout templates used by the tabs. Each layout determines how the widgets are arranged on the screen, including their positions and sizes.&lt;br /&gt;
&lt;br /&gt;
The layouts use resizable panels, allowing users to adjust the size of individual widgets. The styling is defined directly within the TSX file using Tailwind CSS.&lt;br /&gt;
&lt;br /&gt;
If a developer wants to create a new layout, modify an existing one, or change the styling of the layouts, changes should be made in this file.&lt;br /&gt;
&lt;br /&gt;
The tabMap.tsx file maps tab names to their corresponding React components. This allows the application to identify the correct component based on the tab name.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When creating a new tab, developers should first define the tab in `tabs.tsx`, where they select the required layout and widgets.&lt;br /&gt;
&lt;br /&gt;
If the desired layout does not already exist, a new layout can be created in `tabLayout.tsx`.&lt;br /&gt;
&lt;br /&gt;
The new tab must then be registered in the tab mapping and management logic in `tabbar.tsx` so that it can be opened and displayed through the tab bar. If `tabMap.tsx` is used elsewhere in the application, the new tab should also be added there.&lt;br /&gt;
&lt;br /&gt;
This structure allows developers to reuse existing layouts and widgets without having to recreate the tab system for each new tab.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== widget ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Pages ===&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Frontend&amp;diff=9213</id>
		<title>Frontend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Frontend&amp;diff=9213"/>
		<updated>2026-10-13T10:23:31Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Frontend ==&lt;br /&gt;
&lt;br /&gt;
The frontend is mainly structured around components, each responsible for specific functions. These components are used within pages, where they are combined to create complete pages with the required functionality. The frontend is developed using TypeScript, React, and Redux, with Tailwind CSS used for styling.&lt;br /&gt;
&lt;br /&gt;
=== Components ===&lt;br /&gt;
Currently, the frontend consists of seven different components, organized as follows:&lt;br /&gt;
&lt;br /&gt;
==== button ====&lt;br /&gt;
&lt;br /&gt;
the tsx-file defines the button&#039;s properties and functionality, including its type, size, color, and whether it is disabled. This file also creates the HTML button element &amp;lt;button&amp;gt; that can be used in the page you want to add a button.&lt;br /&gt;
&lt;br /&gt;
the ts-file defines the button&#039;s styling using Tailwind CSS, including colors, text sizes, rounded corners, and hover effects. This file does not contain any HTML.&lt;br /&gt;
&lt;br /&gt;
==== dropdown ====&lt;br /&gt;
&lt;br /&gt;
The dropdown menu does not have any specific properties of its own. It is mainly used as a placeholder that appears on the screen when the user clicks a button or hovers over it. The dropdown menu contains different buttons and does not require a separate `.ts` file, as it does not have any styling of its own.&lt;br /&gt;
&lt;br /&gt;
==== inputfield ====&lt;br /&gt;
&lt;br /&gt;
The InputField component It supports both text and password inputs and handles user interactions through event handlers such as onChange and onKeyDown. This component also uses Tailwind CSS for styling, which is defined directly within the tsx.&lt;br /&gt;
&lt;br /&gt;
==== popupwindow ====&lt;br /&gt;
&lt;br /&gt;
PopupWindow consists of a TSX file and a TS file. The TSX file defines the basic structure and functionality of the popup window, providing a default version that can be reused. The TS file defines the styling using Tailwind CSS, allowing the popup window to be customized with different sizes and colors.&lt;br /&gt;
&lt;br /&gt;
The PopupWindowContent folder contains the completed popup windows, which currently consist of two different components: SettingsPopupWindow and WidgetPopupWindow.&lt;br /&gt;
&lt;br /&gt;
The reason these two components are not included in the general TS and TSX files is that they contain different content and functionality. When a new type of popup window is needed, a new component can be created under PopupWindowContent, where its specific content and functionality are defined, while the basic structure and styling are reused from PopupWindow.&lt;br /&gt;
&lt;br /&gt;
==== sidebar ====&lt;br /&gt;
&lt;br /&gt;
The Sidebar component consists of a TSX file and a TS file. The TSX file defines the basic structure and functionality of the sidebar, including the ability to open, close, and resize it. It also stores the sidebar&#039;s state and previous width, allowing the user&#039;s settings to be preserved during the session.&lt;br /&gt;
&lt;br /&gt;
The TS file defines the styling using Tailwind CSS. This includes the sidebar colors, the positioning of the toggle button and resize bar, and the rotation of the arrow when the sidebar is opened or closed.&lt;br /&gt;
&lt;br /&gt;
The `SidebarContent` folder contains the left and right sidebar components. This is where developers can modify the content and functionality of each individual sidebar without changing the general Sidebar component.&lt;br /&gt;
&lt;br /&gt;
The reason for this structure is to separate the basic structure and styling from the specific content of each sidebar. This allows developers to reuse the existing Sidebar component when creating new sidebars, while customizing their content and functionality as needed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== tabbar ====&lt;br /&gt;
&lt;br /&gt;
### Tabbar&lt;br /&gt;
&lt;br /&gt;
The Tabbar is structured into four TSX files, each responsible for a specific part of the tab system. This structure separates the management of tabs from their content and layouts, making it easier for developers to maintain and extend the system.&lt;br /&gt;
&lt;br /&gt;
**tabbar.tsx**&lt;br /&gt;
&lt;br /&gt;
This file contains the main functionality of the tab bar. It handles opening, closing, and switching between tabs, as well as managing which tabs are currently open. It also uses React Router for navigation and Socket.IO to notify the backend when the active tab changes.&lt;br /&gt;
&lt;br /&gt;
**tabs.tsx**&lt;br /&gt;
&lt;br /&gt;
This file contains the predefined tabs available in the dashboard. Each tab defines which widgets should be displayed and which layout should be used.&lt;br /&gt;
&lt;br /&gt;
If a developer wants to modify the widgets displayed in an existing tab or create a new tab, this is where its content and layout are defined.&lt;br /&gt;
&lt;br /&gt;
**tabLayout.tsx**&lt;br /&gt;
&lt;br /&gt;
This file contains the different layout templates used by the tabs. Each layout determines how the widgets are arranged on the screen, including their positions and sizes.&lt;br /&gt;
&lt;br /&gt;
The layouts use resizable panels, allowing users to adjust the size of individual widgets. The styling is defined directly within the TSX file using Tailwind CSS.&lt;br /&gt;
&lt;br /&gt;
If a developer wants to create a new layout, modify an existing one, or change the styling of the layouts, changes should be made in this file.&lt;br /&gt;
&lt;br /&gt;
**tabMap.tsx**&lt;br /&gt;
&lt;br /&gt;
This file maps tab names to their corresponding React components. This allows the application to identify the correct component based on the tab name.&lt;br /&gt;
&lt;br /&gt;
### Adding a new tab&lt;br /&gt;
&lt;br /&gt;
When creating a new tab, developers should first define the tab in `tabs.tsx`, where they select the required layout and widgets.&lt;br /&gt;
&lt;br /&gt;
If the desired layout does not already exist, a new layout can be created in `tabLayout.tsx`.&lt;br /&gt;
&lt;br /&gt;
The new tab must then be registered in the tab mapping and management logic in `tabbar.tsx` so that it can be opened and displayed through the tab bar. If `tabMap.tsx` is used elsewhere in the application, the new tab should also be added there.&lt;br /&gt;
&lt;br /&gt;
This structure allows developers to reuse existing layouts and widgets without having to recreate the tab system for each new tab.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== widget ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Pages ===&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9212</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9212"/>
		<updated>2026-10-13T10:22:47Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Step 2: Update the Environment Variable */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The backend contains two &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Scripts directory (&amp;lt;code&amp;gt;back-end-node-js/scripts/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains environment variables used specifically by scripts and test files within the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory. These settings are separate from the main backend configuration.&lt;br /&gt;
&lt;br /&gt;
===== Main Backend Environment Variables =====&lt;br /&gt;
&lt;br /&gt;
The main backend &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the bcrypt-hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. The new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
====  Authentication and Session Configuration ==== &lt;br /&gt;
Explain which authentication and session settings&lt;br /&gt;
can be modified.&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory.&lt;br /&gt;
&lt;br /&gt;
To change the administrator password, follow these steps:&lt;br /&gt;
&lt;br /&gt;
===== Step 1: Generate a New Password Hash =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/generateHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Locate the variable &amp;lt;code&amp;gt;userPassword&amp;lt;/code&amp;gt; and replace its current value with the desired new password.&lt;br /&gt;
# Open a terminal and navigate to the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Run the following command to generate a new bcrypt hash:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node generateHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# Copy the generated hash (the second output in the terminal).&lt;br /&gt;
&lt;br /&gt;
===== Step 2: Update the Environment Variable =====&lt;br /&gt;
&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;).&lt;br /&gt;
# Locate the &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
# Replace its existing value with the newly generated bcrypt hash.&lt;br /&gt;
# Save the file and restart the backend application to apply the changes.&lt;br /&gt;
# To restart the backend application, go to the robot&#039;s terminal and type &amp;lt;code&amp;gt;sudo systemctl restart webapp.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Step 3: Verify the New Password =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/testHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Update the test password to match the newly chosen administrator password.&lt;br /&gt;
# Ensure that the test script compares the new password against the newly generated hash.&lt;br /&gt;
# Run the test script from the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node testHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# The script should return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the password matches the hash, or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; if they do not match.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The administrator password must always be hashed using bcrypt before being stored in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file. Never store plaintext passwords in environment variables or commit passwords and hashes to version control.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9211</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9211"/>
		<updated>2026-10-13T10:19:53Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Step 2: Update the Environment Variable */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The backend contains two &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Scripts directory (&amp;lt;code&amp;gt;back-end-node-js/scripts/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains environment variables used specifically by scripts and test files within the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory. These settings are separate from the main backend configuration.&lt;br /&gt;
&lt;br /&gt;
===== Main Backend Environment Variables =====&lt;br /&gt;
&lt;br /&gt;
The main backend &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the bcrypt-hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. The new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
====  Authentication and Session Configuration ==== &lt;br /&gt;
Explain which authentication and session settings&lt;br /&gt;
can be modified.&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory.&lt;br /&gt;
&lt;br /&gt;
To change the administrator password, follow these steps:&lt;br /&gt;
&lt;br /&gt;
===== Step 1: Generate a New Password Hash =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/generateHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Locate the variable &amp;lt;code&amp;gt;userPassword&amp;lt;/code&amp;gt; and replace its current value with the desired new password.&lt;br /&gt;
# Open a terminal and navigate to the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Run the following command to generate a new bcrypt hash:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node generateHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# Copy the generated hash (the second output in the terminal).&lt;br /&gt;
&lt;br /&gt;
===== Step 2: Update the Environment Variable =====&lt;br /&gt;
&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;).&lt;br /&gt;
# Locate the &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
# Replace its existing value with the newly generated bcrypt hash.&lt;br /&gt;
# Save the file and restart the backend application to apply the changes.&lt;br /&gt;
# To restart the backend application go to either your terminal and type &amp;lt;code&amp;gt;sudo systemctl restart webapp.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Step 3: Verify the New Password =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/testHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Update the test password to match the newly chosen administrator password.&lt;br /&gt;
# Ensure that the test script compares the new password against the newly generated hash.&lt;br /&gt;
# Run the test script from the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node testHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# The script should return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the password matches the hash, or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; if they do not match.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The administrator password must always be hashed using bcrypt before being stored in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file. Never store plaintext passwords in environment variables or commit passwords and hashes to version control.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9210</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9210"/>
		<updated>2026-10-13T10:19:38Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Step 2: Update the Environment Variable */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The backend contains two &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Scripts directory (&amp;lt;code&amp;gt;back-end-node-js/scripts/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains environment variables used specifically by scripts and test files within the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory. These settings are separate from the main backend configuration.&lt;br /&gt;
&lt;br /&gt;
===== Main Backend Environment Variables =====&lt;br /&gt;
&lt;br /&gt;
The main backend &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the bcrypt-hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. The new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
====  Authentication and Session Configuration ==== &lt;br /&gt;
Explain which authentication and session settings&lt;br /&gt;
can be modified.&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory.&lt;br /&gt;
&lt;br /&gt;
To change the administrator password, follow these steps:&lt;br /&gt;
&lt;br /&gt;
===== Step 1: Generate a New Password Hash =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/generateHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Locate the variable &amp;lt;code&amp;gt;userPassword&amp;lt;/code&amp;gt; and replace its current value with the desired new password.&lt;br /&gt;
# Open a terminal and navigate to the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Run the following command to generate a new bcrypt hash:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node generateHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# Copy the generated hash (the second output in the terminal).&lt;br /&gt;
&lt;br /&gt;
===== Step 2: Update the Environment Variable =====&lt;br /&gt;
&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;).&lt;br /&gt;
# Locate the &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
# Replace its existing value with the newly generated bcrypt hash.&lt;br /&gt;
# Save the file and restart the backend application to apply the changes.&lt;br /&gt;
# To restart the backend application go to either your terminal and type &amp;lt;code&amp;gt;sudo systemctl restart webapp.service&amp;lt;\code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Step 3: Verify the New Password =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/testHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Update the test password to match the newly chosen administrator password.&lt;br /&gt;
# Ensure that the test script compares the new password against the newly generated hash.&lt;br /&gt;
# Run the test script from the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node testHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# The script should return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the password matches the hash, or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; if they do not match.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The administrator password must always be hashed using bcrypt before being stored in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file. Never store plaintext passwords in environment variables or commit passwords and hashes to version control.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9209</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9209"/>
		<updated>2026-10-13T10:15:41Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Changing the Administrator Password */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The backend contains two &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Scripts directory (&amp;lt;code&amp;gt;back-end-node-js/scripts/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains environment variables used specifically by scripts and test files within the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory. These settings are separate from the main backend configuration.&lt;br /&gt;
&lt;br /&gt;
===== Main Backend Environment Variables =====&lt;br /&gt;
&lt;br /&gt;
The main backend &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the bcrypt-hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. The new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
====  Authentication and Session Configuration ==== &lt;br /&gt;
Explain which authentication and session settings&lt;br /&gt;
can be modified.&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory.&lt;br /&gt;
&lt;br /&gt;
To change the administrator password, follow these steps:&lt;br /&gt;
&lt;br /&gt;
===== Step 1: Generate a New Password Hash =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/generateHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Locate the variable &amp;lt;code&amp;gt;userPassword&amp;lt;/code&amp;gt; and replace its current value with the desired new password.&lt;br /&gt;
# Open a terminal and navigate to the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Run the following command to generate a new bcrypt hash:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node generateHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# Copy the generated hash (the second output in the terminal).&lt;br /&gt;
&lt;br /&gt;
===== Step 2: Update the Environment Variable =====&lt;br /&gt;
&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the backend root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;).&lt;br /&gt;
# Locate the &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; variable.&lt;br /&gt;
# Replace its existing value with the newly generated bcrypt hash.&lt;br /&gt;
# Save the file and restart the backend application to apply the changes.&lt;br /&gt;
&lt;br /&gt;
===== Step 3: Verify the New Password =====&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/testHash.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
# Update the test password to match the newly chosen administrator password.&lt;br /&gt;
# Ensure that the test script compares the new password against the newly generated hash.&lt;br /&gt;
# Run the test script from the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory:&lt;br /&gt;
#: &amp;lt;code&amp;gt;node testHash.js&amp;lt;/code&amp;gt;&lt;br /&gt;
# The script should return &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; if the password matches the hash, or &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt; if they do not match.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The administrator password must always be hashed using bcrypt before being stored in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file. Never store plaintext passwords in environment variables or commit passwords and hashes to version control.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9208</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9208"/>
		<updated>2026-10-13T10:00:04Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Changing the Administrator Password */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The backend contains two &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Scripts directory (&amp;lt;code&amp;gt;back-end-node-js/scripts/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains environment variables used specifically by scripts and test files within the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory. These settings are separate from the main backend configuration.&lt;br /&gt;
&lt;br /&gt;
===== Main Backend Environment Variables =====&lt;br /&gt;
&lt;br /&gt;
The main backend &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the bcrypt-hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. The new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
====  Authentication and Session Configuration ==== &lt;br /&gt;
Explain which authentication and session settings&lt;br /&gt;
can be modified.&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
To change the password:&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt;back-end-node-js/scripts/generateHash.js/&amp;lt;\code&amp;gt;&lt;br /&gt;
# Choose another passcode for the variable &amp;lt;code&amp;gt;userPassword&amp;lt;\code&amp;gt;&lt;br /&gt;
# Replace the existing &amp;lt;code&amp;gt;AdminPassword&amp;lt;\code&amp;gt; value with the newly generated hash.&lt;br /&gt;
# Save the file and restart the backend server for the changes to take effect.&lt;br /&gt;
# Verify that the new password works by logging into the dashboard.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The password must be hashed using bcrypt. Do not store the password in plaintext.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9207</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9207"/>
		<updated>2026-10-13T09:59:03Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Changing the Administrator Password */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The backend contains two &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Scripts directory (&amp;lt;code&amp;gt;back-end-node-js/scripts/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains environment variables used specifically by scripts and test files within the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory. These settings are separate from the main backend configuration.&lt;br /&gt;
&lt;br /&gt;
===== Main Backend Environment Variables =====&lt;br /&gt;
&lt;br /&gt;
The main backend &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the bcrypt-hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. The new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
====  Authentication and Session Configuration ==== &lt;br /&gt;
Explain which authentication and session settings&lt;br /&gt;
can be modified.&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
To change the password:&lt;br /&gt;
&lt;br /&gt;
# Open &amp;lt;code&amp;gt; back-end-node-js/scripts/generateHash.js/&amp;lt;\code&amp;gt;&lt;br /&gt;
# Choose another passcode for the variable &amp;lt;code&amp;gt; userPassword &amp;lt;\code&amp;gt;&lt;br /&gt;
# Replace the existing &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; value with the newly generated hash.&lt;br /&gt;
# Save the file and restart the backend server for the changes to take effect.&lt;br /&gt;
# Verify that the new password works by logging into the dashboard.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The password must be hashed using bcrypt. Do not store the password in plaintext.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Robot_dashboard&amp;diff=9206</id>
		<title>Robot dashboard</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Robot_dashboard&amp;diff=9206"/>
		<updated>2026-10-13T09:55:28Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Requirements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard is a browser-based application developed to provide a centralized interface for monitoring and interacting with autonomous robots but as fo. The dashboard enables users to visualize real-time robot data, monitor system status, and interact with different robot components through a customizable interface.&lt;br /&gt;
&lt;br /&gt;
The application was developed as part of a bachelor&#039;s project at the Technical University of Denmark (DTU) in Spring 2026. Its main objective was to create a flexible and user-friendly platform that simplifies robot monitoring and interaction without requiring users to work directly with the underlying communication systems.&lt;br /&gt;
&lt;br /&gt;
The dashboard is specifically designed for the type &#039;Robobot&#039; and is currently only compatible with this robot type. While the system has a modular architecture that allows for future extensions, supporting other robot types would require additional development and modifications to the existing implementation.&lt;br /&gt;
&lt;br /&gt;
The dashboard consists of a frontend built with React, TypeScript, and Tailwind CSS, and a backend developed using Node.js and Express. Communication between the dashboard and the robots is handled through MQTT, while Socket.IO enables real-time updates between the backend and frontend.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Key Features&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Real-time monitoring:&#039;&#039;&#039; Displays live robot information, including position, status, and sensor data.&lt;br /&gt;
*&#039;&#039;&#039;Customizable dashboard:&#039;&#039;&#039; Allows users to organize and interact with different widgets across multiple tabs.&lt;br /&gt;
* &#039;&#039;&#039;Robot interaction:&#039;&#039;&#039; Provides an interface for monitoring and interacting with robot components.&lt;br /&gt;
* &#039;&#039;&#039;Widget-based interface:&#039;&#039;&#039; Includes widgets for robot information, position, driver controls, edge sensors, and debugging.&lt;br /&gt;
* &#039;&#039;&#039;User authentication:&#039;&#039;&#039; Restricts dashboard access through a password-based login system.&lt;br /&gt;
&lt;br /&gt;
The dashboard is designed to provide a foundation for future development, allowing additional widgets and functionalities to be integrated as needed.&lt;br /&gt;
&lt;br /&gt;
= Developers note =&lt;br /&gt;
&lt;br /&gt;
This following section is for developers, it goes through the set up procedure and how the back-end and front-end is set up for further development. &lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
For further development of the dashboard these are the requirements to have.&lt;br /&gt;
* Have installed Node.js&lt;br /&gt;
* Have installed npm&lt;br /&gt;
* Have a code editor (VScode or other)&lt;br /&gt;
* Have Downloaded Type-Script&lt;br /&gt;
&lt;br /&gt;
== Set up ==&lt;br /&gt;
&lt;br /&gt;
Before setting up the robot dashboard two necessary software programs is required.&lt;br /&gt;
&lt;br /&gt;
# A file management software (Windows: RealFTP, Mac: FileZilla)&lt;br /&gt;
# A file editing software (Windows: PuTTY, Mac: Terminal)&lt;br /&gt;
&lt;br /&gt;
=== Installing nodejs and npm on the robot ===&lt;br /&gt;
For the dashboard software to function it is important to make sure that node.js and npm is installed on the robot. To check this run the following code in the terminal&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
npm -v&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
node -v&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If npm and node is not installed, install them using the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt install -y nodejs npm&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== File placement ===&lt;br /&gt;
&lt;br /&gt;
To make the dashboard software functional we need to transfer the necessary files. It is important that the files are in the correct placement with the correct names for the software to start when the system boots.&lt;br /&gt;
&lt;br /&gt;
When transferring the files locate the path:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
/home/local/svn/robobot/&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a folder named &amp;quot;Browser-based-dashboard-for-autonomous-robots&amp;quot; such that the folder path looks like this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
/home/local/svn/robobot/Browser-based-dashboard-for-autonomous-robots&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this folder we will transfer the back-end and the front-end. It is important that the back-end folder is called &amp;quot;back-end-node-js&amp;quot; as this name is used for the software to start when the system boots. Otherwise you will need to change the work directory in the upcomming service file.&lt;br /&gt;
&lt;br /&gt;
When the back-end and front-end have been transferred to the robot in the &amp;quot;Browser-based-dashboard-for-autonomous-robots&amp;quot; folder, the following commands will be needed for each folder.&lt;br /&gt;
&lt;br /&gt;
==== back-end ====&lt;br /&gt;
In the back-end run the following commands to make sure every needed package is installed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install&lt;br /&gt;
npm install socket.io-client&lt;br /&gt;
npm audit fix&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== front-end ====&lt;br /&gt;
In the front-end run the following commands to make sure every needed package is installed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install&lt;br /&gt;
npm audit fix&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Making the software start when the system boots  ===&lt;br /&gt;
The first thing is to make sure the robot will start the dashboard software on boot up. To do this we will use the editing software to create a service file using the command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo nano /etc/systemd/system/webapp.service&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will create a file named &amp;quot;webapp.service&amp;quot;, which is responsible for ensuring that the dashboard software starts automatically when the system boots.&lt;br /&gt;
&lt;br /&gt;
In this file write the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Unit]&lt;br /&gt;
Description=Webapp starter that waits for network and MQTT&lt;br /&gt;
Wants=network-online.target&lt;br /&gt;
After=network-online.target&lt;br /&gt;
StartLimitIntervalSec=0&lt;br /&gt;
&lt;br /&gt;
[Service]&lt;br /&gt;
Type=simple&lt;br /&gt;
User=local&lt;br /&gt;
#Change to the backend folder path&lt;br /&gt;
WorkingDirectory=/home/local/svn/robobot/Browser-based-dashboard-for-autonomous-robots/back-end-node-js&lt;br /&gt;
Environment=NODE_ENV=production&lt;br /&gt;
Environment=ROBOT_PORT=9090&lt;br /&gt;
&lt;br /&gt;
#Wait for network&lt;br /&gt;
ExecStartPre=/bin/bash -c &#039;\&lt;br /&gt;
  echo &amp;quot;Waiting for network...&amp;quot;; \&lt;br /&gt;
  until hostname -I &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; do \&lt;br /&gt;
    echo &amp;quot;No IP yet. Retrying...&amp;quot;; \&lt;br /&gt;
    sleep 2; \&lt;br /&gt;
  done; \&lt;br /&gt;
  echo &amp;quot;Network ready.&amp;quot; \&lt;br /&gt;
&#039;&lt;br /&gt;
&lt;br /&gt;
#Start Node with dynamically set ROBOT_HOST&lt;br /&gt;
ExecStart=/bin/bash -c &#039;ROBOT_HOST=$(hostname -I | awk &amp;quot;{print $1}&amp;quot;); \&lt;br /&gt;
        ROBOT_HOST=$(echo &amp;quot;$ROBOT_HOST&amp;quot; | xargs); \&lt;br /&gt;
        echo &amp;quot;Starting web app with ROBOT_HOST=$ROBOT_HOST&amp;quot;; \&lt;br /&gt;
        export ROBOT_HOST; exec /usr/bin/node server.js \&lt;br /&gt;
&#039;&lt;br /&gt;
&lt;br /&gt;
Restart=always&lt;br /&gt;
RestartSec=5&lt;br /&gt;
TimeoutStartSec=120&lt;br /&gt;
&lt;br /&gt;
[Install]&lt;br /&gt;
WantedBy=multi-user.target&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After writing this code save it and exit. To activate this service file run the following sequence of code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo systemctl enable webapp.service&lt;br /&gt;
sudo systemctl restart webapp.service&lt;br /&gt;
journalctl -u webapp.service -f &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this you should be able to access the dashboard at http://&amp;lt;IP ADRESS&amp;gt;:9090&lt;br /&gt;
&lt;br /&gt;
== Back-end ==&lt;br /&gt;
[[Backend]] &lt;br /&gt;
&lt;br /&gt;
== Front-end ==&lt;br /&gt;
&lt;br /&gt;
[[Frontend]]&lt;br /&gt;
&lt;br /&gt;
= Users note =&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9205</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9205"/>
		<updated>2026-10-13T09:55:10Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Environment Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The backend contains two &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (&amp;lt;code&amp;gt;back-end-node-js/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Scripts directory (&amp;lt;code&amp;gt;back-end-node-js/scripts/.env&amp;lt;/code&amp;gt;):&#039;&#039;&#039; Contains environment variables used specifically by scripts and test files within the &amp;lt;code&amp;gt;scripts/&amp;lt;/code&amp;gt; directory. These settings are separate from the main backend configuration.&lt;br /&gt;
&lt;br /&gt;
===== Main Backend Environment Variables =====&lt;br /&gt;
&lt;br /&gt;
The main backend &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the bcrypt-hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. The new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
====  Authentication and Session Configuration ==== &lt;br /&gt;
Explain which authentication and session settings&lt;br /&gt;
can be modified.&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
To change the password:&lt;br /&gt;
&lt;br /&gt;
# Generate a new bcrypt hash using the desired password.&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Replace the existing &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; value with the newly generated hash.&lt;br /&gt;
# Save the file and restart the backend server for the changes to take effect.&lt;br /&gt;
# Verify that the new password works by logging into the dashboard.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The password must be hashed using bcrypt. Do not store the password in plaintext.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9204</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9204"/>
		<updated>2026-10-13T09:54:28Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Environment Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables: &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
The backend contains two `.env` files located in different directories. Each file serves a different purpose and contains configuration settings used by the application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. When updating it, the new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
The backend contains two .env files located in different directories, each serving a different purpose:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (back-end-node-js/.env):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including AdminPassword and SessionSecret. These variables are responsible for authentication and session management.&lt;br /&gt;
*&#039;&#039;&#039;scripts directory (back-end-node-js/scripts/.env):&#039;&#039;&#039;  Contains environment variables used specifically by scripts and test files within the scripts/ directory. These settings are separate from the main backend configuration. &lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
====  Authentication and Session Configuration ==== &lt;br /&gt;
Explain which authentication and session settings&lt;br /&gt;
can be modified.&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
To change the password:&lt;br /&gt;
&lt;br /&gt;
# Generate a new bcrypt hash using the desired password.&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Replace the existing &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; value with the newly generated hash.&lt;br /&gt;
# Save the file and restart the backend server for the changes to take effect.&lt;br /&gt;
# Verify that the new password works by logging into the dashboard.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The password must be hashed using bcrypt. Do not store the password in plaintext.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9203</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9203"/>
		<updated>2026-10-13T09:53:31Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Environment Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables: &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
The backend contains two `.env` files located in different directories. Each file serves a different purpose and contains configuration settings used by the application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Root directory (back-end-node-js/.env):&#039;&#039;&#039; Contains the environment variables used by the main backend application, including AdminPassword and SessionSecret. These variables are responsible for authentication and session management.&lt;br /&gt;
*&#039;&#039;&#039;scripts directory (back-end-node-js/scripts/.env):&#039;&#039;&#039;  Contains environment variables used specifically by scripts and test files within the scripts/ directory. These settings are separate from the main backend configuration. &lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. When updating it, the new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
====  Authentication and Session Configuration ==== &lt;br /&gt;
Explain which authentication and session settings&lt;br /&gt;
can be modified.&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
To change the password:&lt;br /&gt;
&lt;br /&gt;
# Generate a new bcrypt hash using the desired password.&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Replace the existing &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; value with the newly generated hash.&lt;br /&gt;
# Save the file and restart the backend server for the changes to take effect.&lt;br /&gt;
# Verify that the new password works by logging into the dashboard.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The password must be hashed using bcrypt. Do not store the password in plaintext.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9202</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9202"/>
		<updated>2026-10-13T09:50:31Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Environment Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables: &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
The backend contains two `.env` files located in different directories. Each file serves a different purpose and contains configuration settings used by the application.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;`.env` in the backend root directory:&#039;&#039;&#039; [Explain its purpose and variables.]&lt;br /&gt;
*&#039;&#039;&#039;`.env` in the scripts directory:&#039;&#039;&#039; [Explain its purpose and variables.]&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. When updating it, the new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
====  Authentication and Session Configuration ==== &lt;br /&gt;
Explain which authentication and session settings&lt;br /&gt;
can be modified.&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
To change the password:&lt;br /&gt;
&lt;br /&gt;
# Generate a new bcrypt hash using the desired password.&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Replace the existing &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; value with the newly generated hash.&lt;br /&gt;
# Save the file and restart the backend server for the changes to take effect.&lt;br /&gt;
# Verify that the new password works by logging into the dashboard.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The password must be hashed using bcrypt. Do not store the password in plaintext.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9201</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9201"/>
		<updated>2026-10-13T09:49:34Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Environment Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables: &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
The backend contains two `.env` files located in different directories. Each file serves a different purpose and contains configuration settings used by the application.&lt;br /&gt;
&lt;br /&gt;
- *`.env` in the backend root directory:** [Explain its purpose and variables.]&lt;br /&gt;
- *`.env` in the scripts directory:** [Explain its purpose and variables.]&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. When updating it, the new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
====  Authentication and Session Configuration ==== &lt;br /&gt;
Explain which authentication and session settings&lt;br /&gt;
can be modified.&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
To change the password:&lt;br /&gt;
&lt;br /&gt;
# Generate a new bcrypt hash using the desired password.&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Replace the existing &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; value with the newly generated hash.&lt;br /&gt;
# Save the file and restart the backend server for the changes to take effect.&lt;br /&gt;
# Verify that the new password works by logging into the dashboard.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The password must be hashed using bcrypt. Do not store the password in plaintext.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9200</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9200"/>
		<updated>2026-10-13T09:49:25Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Environment Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables: &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
The backend contains two `.env` files located in different directories. Each file serves a different purpose and contains configuration settings used by the application.&lt;br /&gt;
&lt;br /&gt;
- **`.env` in the backend root directory:** [Explain its purpose and variables.]&lt;br /&gt;
- **`.env` in the scripts directory:** [Explain its purpose and variables.]&lt;br /&gt;
&lt;br /&gt;
When modifying environment variables, ensure that the correct file is updated, as changes to one file may not affect the other.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. When updating it, the new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
====  Authentication and Session Configuration ==== &lt;br /&gt;
Explain which authentication and session settings&lt;br /&gt;
can be modified.&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
To change the password:&lt;br /&gt;
&lt;br /&gt;
# Generate a new bcrypt hash using the desired password.&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Replace the existing &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; value with the newly generated hash.&lt;br /&gt;
# Save the file and restart the backend server for the changes to take effect.&lt;br /&gt;
# Verify that the new password works by logging into the dashboard.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The password must be hashed using bcrypt. Do not store the password in plaintext.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9199</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9199"/>
		<updated>2026-10-13T09:48:09Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Environment Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables: &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. When updating it, the new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
For instructions on modifying these settings, see [[#Authentication and Session Configuration|Authentication and Session Configuration]].&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
====  Authentication and Session Configuration ==== &lt;br /&gt;
Explain which authentication and session settings&lt;br /&gt;
can be modified.&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
To change the password:&lt;br /&gt;
&lt;br /&gt;
# Generate a new bcrypt hash using the desired password.&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Replace the existing &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; value with the newly generated hash.&lt;br /&gt;
# Save the file and restart the backend server for the changes to take effect.&lt;br /&gt;
# Verify that the new password works by logging into the dashboard.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The password must be hashed using bcrypt. Do not store the password in plaintext.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9198</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9198"/>
		<updated>2026-10-13T09:46:09Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Environment Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables: &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. When updating it, the new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
Please read more on: [[#Authentication and Session Configuration|Authentication and Session Configuration]]&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
====  Authentication and Session Configuration ==== &lt;br /&gt;
Explain which authentication and session settings&lt;br /&gt;
can be modified.&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
To change the password:&lt;br /&gt;
&lt;br /&gt;
# Generate a new bcrypt hash using the desired password.&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Replace the existing &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; value with the newly generated hash.&lt;br /&gt;
# Save the file and restart the backend server for the changes to take effect.&lt;br /&gt;
# Verify that the new password works by logging into the dashboard.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The password must be hashed using bcrypt. Do not store the password in plaintext.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9197</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9197"/>
		<updated>2026-10-13T09:44:44Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Environment Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables: &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. When updating it, the new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
Please read more on: #Authentication and Session Configuration&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
====  Authentication and Session Configuration ==== &lt;br /&gt;
Explain which authentication and session settings&lt;br /&gt;
can be modified.&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
To change the password:&lt;br /&gt;
&lt;br /&gt;
# Generate a new bcrypt hash using the desired password.&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Replace the existing &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; value with the newly generated hash.&lt;br /&gt;
# Save the file and restart the backend server for the changes to take effect.&lt;br /&gt;
# Verify that the new password works by logging into the dashboard.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The password must be hashed using bcrypt. Do not store the password in plaintext.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9196</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9196"/>
		<updated>2026-10-13T09:44:32Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Environment Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables: &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. When updating it, the new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
Please read more on: ##Authentication and Session Configuration&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
====  Authentication and Session Configuration ==== &lt;br /&gt;
Explain which authentication and session settings&lt;br /&gt;
can be modified.&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
To change the password:&lt;br /&gt;
&lt;br /&gt;
# Generate a new bcrypt hash using the desired password.&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Replace the existing &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; value with the newly generated hash.&lt;br /&gt;
# Save the file and restart the backend server for the changes to take effect.&lt;br /&gt;
# Verify that the new password works by logging into the dashboard.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The password must be hashed using bcrypt. Do not store the password in plaintext.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9195</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9195"/>
		<updated>2026-10-13T09:44:21Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Environment Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables: &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. When updating it, the new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
Please read more on: ## Authentication and Session Configuration&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
====  Authentication and Session Configuration ==== &lt;br /&gt;
Explain which authentication and session settings&lt;br /&gt;
can be modified.&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
To change the password:&lt;br /&gt;
&lt;br /&gt;
# Generate a new bcrypt hash using the desired password.&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Replace the existing &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; value with the newly generated hash.&lt;br /&gt;
# Save the file and restart the backend server for the changes to take effect.&lt;br /&gt;
# Verify that the new password works by logging into the dashboard.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The password must be hashed using bcrypt. Do not store the password in plaintext.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9194</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9194"/>
		<updated>2026-10-13T09:40:47Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Environment Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables: &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. When updating it, the new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
Please read more on: [Authentication and Session Configuration](#authentication-and-session-configuration)&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
====  Authentication and Session Configuration ==== &lt;br /&gt;
Explain which authentication and session settings&lt;br /&gt;
can be modified.&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
To change the password:&lt;br /&gt;
&lt;br /&gt;
# Generate a new bcrypt hash using the desired password.&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Replace the existing &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; value with the newly generated hash.&lt;br /&gt;
# Save the file and restart the backend server for the changes to take effect.&lt;br /&gt;
# Verify that the new password works by logging into the dashboard.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The password must be hashed using bcrypt. Do not store the password in plaintext.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Robot_dashboard&amp;diff=9193</id>
		<title>Robot dashboard</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Robot_dashboard&amp;diff=9193"/>
		<updated>2026-10-13T09:40:21Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Requirements */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard is a browser-based application developed to provide a centralized interface for monitoring and interacting with autonomous robots but as fo. The dashboard enables users to visualize real-time robot data, monitor system status, and interact with different robot components through a customizable interface.&lt;br /&gt;
&lt;br /&gt;
The application was developed as part of a bachelor&#039;s project at the Technical University of Denmark (DTU) in Spring 2026. Its main objective was to create a flexible and user-friendly platform that simplifies robot monitoring and interaction without requiring users to work directly with the underlying communication systems.&lt;br /&gt;
&lt;br /&gt;
The dashboard is specifically designed for the type &#039;Robobot&#039; and is currently only compatible with this robot type. While the system has a modular architecture that allows for future extensions, supporting other robot types would require additional development and modifications to the existing implementation.&lt;br /&gt;
&lt;br /&gt;
The dashboard consists of a frontend built with React, TypeScript, and Tailwind CSS, and a backend developed using Node.js and Express. Communication between the dashboard and the robots is handled through MQTT, while Socket.IO enables real-time updates between the backend and frontend.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Key Features&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Real-time monitoring:&#039;&#039;&#039; Displays live robot information, including position, status, and sensor data.&lt;br /&gt;
*&#039;&#039;&#039;Customizable dashboard:&#039;&#039;&#039; Allows users to organize and interact with different widgets across multiple tabs.&lt;br /&gt;
* &#039;&#039;&#039;Robot interaction:&#039;&#039;&#039; Provides an interface for monitoring and interacting with robot components.&lt;br /&gt;
* &#039;&#039;&#039;Widget-based interface:&#039;&#039;&#039; Includes widgets for robot information, position, driver controls, edge sensors, and debugging.&lt;br /&gt;
* &#039;&#039;&#039;User authentication:&#039;&#039;&#039; Restricts dashboard access through a password-based login system.&lt;br /&gt;
&lt;br /&gt;
The dashboard is designed to provide a foundation for future development, allowing additional widgets and functionalities to be integrated as needed.&lt;br /&gt;
&lt;br /&gt;
= Developers note =&lt;br /&gt;
&lt;br /&gt;
This following section is for developers, it goes through the set up procedure and how the back-end and front-end is set up for further development. &lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
For further development of the dashboard these are the requirements to have.&lt;br /&gt;
* Have installed Node.js&lt;br /&gt;
* Have installed npm&lt;br /&gt;
* Have a code editor (VScode or other)&lt;br /&gt;
&lt;br /&gt;
== Set up ==&lt;br /&gt;
&lt;br /&gt;
Before setting up the robot dashboard two necessary software programs is required.&lt;br /&gt;
&lt;br /&gt;
# A file management software (Windows: RealFTP, Mac: FileZilla)&lt;br /&gt;
# A file editing software (Windows: PuTTY, Mac: Terminal)&lt;br /&gt;
&lt;br /&gt;
=== Installing nodejs and npm on the robot ===&lt;br /&gt;
For the dashboard software to function it is important to make sure that node.js and npm is installed on the robot. To check this run the following code in the terminal&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
npm -v&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
node -v&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If npm and node is not installed, install them using the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt install -y nodejs npm&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== File placement ===&lt;br /&gt;
&lt;br /&gt;
To make the dashboard software functional we need to transfer the necessary files. It is important that the files are in the correct placement with the correct names for the software to start when the system boots.&lt;br /&gt;
&lt;br /&gt;
When transferring the files locate the path:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
/home/local/svn/robobot/&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a folder named &amp;quot;Browser-based-dashboard-for-autonomous-robots&amp;quot; such that the folder path looks like this.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
/home/local/svn/robobot/Browser-based-dashboard-for-autonomous-robots&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this folder we will transfer the back-end and the front-end. It is important that the back-end folder is called &amp;quot;back-end-node-js&amp;quot; as this name is used for the software to start when the system boots. Otherwise you will need to change the work directory in the upcomming service file.&lt;br /&gt;
&lt;br /&gt;
When the back-end and front-end have been transferred to the robot in the &amp;quot;Browser-based-dashboard-for-autonomous-robots&amp;quot; folder, the following commands will be needed for each folder.&lt;br /&gt;
&lt;br /&gt;
==== back-end ====&lt;br /&gt;
In the back-end run the following commands to make sure every needed package is installed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install&lt;br /&gt;
npm install socket.io-client&lt;br /&gt;
npm audit fix&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== front-end ====&lt;br /&gt;
In the front-end run the following commands to make sure every needed package is installed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
npm install&lt;br /&gt;
npm audit fix&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Making the software start when the system boots  ===&lt;br /&gt;
The first thing is to make sure the robot will start the dashboard software on boot up. To do this we will use the editing software to create a service file using the command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo nano /etc/systemd/system/webapp.service&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will create a file named &amp;quot;webapp.service&amp;quot;, which is responsible for ensuring that the dashboard software starts automatically when the system boots.&lt;br /&gt;
&lt;br /&gt;
In this file write the following code:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Unit]&lt;br /&gt;
Description=Webapp starter that waits for network and MQTT&lt;br /&gt;
Wants=network-online.target&lt;br /&gt;
After=network-online.target&lt;br /&gt;
StartLimitIntervalSec=0&lt;br /&gt;
&lt;br /&gt;
[Service]&lt;br /&gt;
Type=simple&lt;br /&gt;
User=local&lt;br /&gt;
#Change to the backend folder path&lt;br /&gt;
WorkingDirectory=/home/local/svn/robobot/Browser-based-dashboard-for-autonomous-robots/back-end-node-js&lt;br /&gt;
Environment=NODE_ENV=production&lt;br /&gt;
Environment=ROBOT_PORT=9090&lt;br /&gt;
&lt;br /&gt;
#Wait for network&lt;br /&gt;
ExecStartPre=/bin/bash -c &#039;\&lt;br /&gt;
  echo &amp;quot;Waiting for network...&amp;quot;; \&lt;br /&gt;
  until hostname -I &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; do \&lt;br /&gt;
    echo &amp;quot;No IP yet. Retrying...&amp;quot;; \&lt;br /&gt;
    sleep 2; \&lt;br /&gt;
  done; \&lt;br /&gt;
  echo &amp;quot;Network ready.&amp;quot; \&lt;br /&gt;
&#039;&lt;br /&gt;
&lt;br /&gt;
#Start Node with dynamically set ROBOT_HOST&lt;br /&gt;
ExecStart=/bin/bash -c &#039;ROBOT_HOST=$(hostname -I | awk &amp;quot;{print $1}&amp;quot;); \&lt;br /&gt;
        ROBOT_HOST=$(echo &amp;quot;$ROBOT_HOST&amp;quot; | xargs); \&lt;br /&gt;
        echo &amp;quot;Starting web app with ROBOT_HOST=$ROBOT_HOST&amp;quot;; \&lt;br /&gt;
        export ROBOT_HOST; exec /usr/bin/node server.js \&lt;br /&gt;
&#039;&lt;br /&gt;
&lt;br /&gt;
Restart=always&lt;br /&gt;
RestartSec=5&lt;br /&gt;
TimeoutStartSec=120&lt;br /&gt;
&lt;br /&gt;
[Install]&lt;br /&gt;
WantedBy=multi-user.target&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After writing this code save it and exit. To activate this service file run the following sequence of code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
sudo systemctl enable webapp.service&lt;br /&gt;
sudo systemctl restart webapp.service&lt;br /&gt;
journalctl -u webapp.service -f &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this you should be able to access the dashboard at http://&amp;lt;IP ADRESS&amp;gt;:9090&lt;br /&gt;
&lt;br /&gt;
== Back-end ==&lt;br /&gt;
[[Backend]] &lt;br /&gt;
&lt;br /&gt;
== Front-end ==&lt;br /&gt;
&lt;br /&gt;
[[Frontend]]&lt;br /&gt;
&lt;br /&gt;
= Users note =&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9192</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9192"/>
		<updated>2026-10-13T09:32:51Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Environment Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables: &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. When updating it, the new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
Plese read [[Authenticaion and Session configuration]]&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
====  Authentication and Session Configuration ==== &lt;br /&gt;
Explain which authentication and session settings&lt;br /&gt;
can be modified.&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
To change the password:&lt;br /&gt;
&lt;br /&gt;
# Generate a new bcrypt hash using the desired password.&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Replace the existing &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; value with the newly generated hash.&lt;br /&gt;
# Save the file and restart the backend server for the changes to take effect.&lt;br /&gt;
# Verify that the new password works by logging into the dashboard.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The password must be hashed using bcrypt. Do not store the password in plaintext.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
	<entry>
		<id>https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9191</id>
		<title>Backend</title>
		<link rel="alternate" type="text/html" href="https://rsewiki.electro.dtu.dk/index.php?title=Backend&amp;diff=9191"/>
		<updated>2026-10-13T09:31:09Z</updated>

		<summary type="html">&lt;p&gt;Spring2026: /* Authentication and Session Configuration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Backend ==&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
=== Introduction ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the robot and the web application, processing incoming robot data and forwarding relevant information to the dashboard.&lt;br /&gt;
&lt;br /&gt;
The backend consists of several files and components, each serving a specific purpose. &#039;&#039;&#039;Some files can be modified to customize the dashboard&#039;s functionality, while others contain core functionality and should generally remain unchanged&#039;&#039;&#039; to ensure the system operates correctly.&lt;br /&gt;
&lt;br /&gt;
This section provides an overview of the backend architecture, its file structure, and guidelines for configuring and modifying the system.&lt;br /&gt;
&lt;br /&gt;
== Backend Architecutre ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;Express:&#039;&#039;&#039; Handles HTTP requests, including user authentication and session management.&lt;br /&gt;
#&#039;&#039;&#039;MQTT:&#039;&#039;&#039; Enables communication between the backend and the Tuype robot through a publish-subscribe messaging system.&lt;br /&gt;
# &#039;&#039;&#039;Socket.IO:&#039;&#039;&#039; Establishes real-time, bidirectional communication between the backend and frontend, allowing robot data to be displayed without manually refreshing the page.&lt;br /&gt;
&lt;br /&gt;
=== Communication Flow ===&lt;br /&gt;
&lt;br /&gt;
The backend acts as an intermediary between the frontend and Robobot.&lt;br /&gt;
&lt;br /&gt;
# The Robobot publishes data to specific MQTT topics through an MQTT broker.&lt;br /&gt;
# The backend subscribes to relevant topics and receives incoming robot data.&lt;br /&gt;
# The backend processes the received messages and forwards relevant information to the frontend using Socket.IO.&lt;br /&gt;
# The frontend receives these updates and displays them in the corresponding dashboard widgets.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== Model-View-Controller===&lt;br /&gt;
&lt;br /&gt;
The Robot Dashboard was designed using the Model–View–Controller (MVC) architectural pattern to separate the application&#039;s user interface, application logic, and communication handling.&lt;br /&gt;
&lt;br /&gt;
The architecture consists of three main components:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Model:&#039;&#039;&#039; Represents the backend logic and is responsible for processing data and managing the application&#039;s functionality.&lt;br /&gt;
*&#039;&#039;&#039;View:&#039;&#039;&#039; Represents the frontend user interface, where users can interact with the dashboard and visualize real-time robot data.&lt;br /&gt;
*&#039;&#039;&#039;Controller:&#039;&#039;&#039; Acts as an intermediary between the Model, View, and Tuype robot. It handles communication through REST APIs, Socket.IO, and MQTT, as well as session management.&lt;br /&gt;
&lt;br /&gt;
[[file: ModelViewController.png | 700px]]&lt;br /&gt;
&lt;br /&gt;
When a user interacts with the dashboard, the input is sent from the View to the Controller. The Controller processes the request and communicates with the Model when application logic or data processing is required.&lt;br /&gt;
&lt;br /&gt;
For robot-related interactions, the Controller communicates with the Tuype robot through MQTT. The robot publishes data to MQTT topics, which the backend subscribes to and forwards to the frontend through Socket.IO.&lt;br /&gt;
&lt;br /&gt;
The Controller is also responsible for sending updates back to the View, allowing the dashboard to display real-time information without requiring the user to refresh the page.&lt;br /&gt;
&lt;br /&gt;
=== Authentication and Session Management ===&lt;br /&gt;
&lt;br /&gt;
The backend implements a password-based authentication system to restrict access to the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
User authentication is handled through Express, where the provided password is verified against a stored password hash using bcrypt. Upon successful authentication, a session is established using &lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
express-session&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The session is maintained through a cookie, allowing the backend to recognize authenticated users across subsequent requests without requiring them to log in repeatedly.&lt;br /&gt;
&lt;br /&gt;
The current implementation uses a single shared password rather than individual user accounts.&lt;br /&gt;
&lt;br /&gt;
== Backend Codebase Overview ==&lt;br /&gt;
&lt;br /&gt;
The backend source code of the Robot Dashboard is located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory, which serves as the root directory of the backend application.&lt;br /&gt;
&lt;br /&gt;
The codebase is organized into several directories and files, each responsible for specific functionality, including API handling, MQTT communication, security, and real-time communication. This separation helps developers navigate the codebase, understand the responsibilities of individual modules, and identify relevant files for maintenance or further development.&lt;br /&gt;
&lt;br /&gt;
The following sections provide an overview of the backend directory structure and the responsibilities of its main files and modules.&lt;br /&gt;
&lt;br /&gt;
=== Configuration and Customization ===&lt;br /&gt;
&lt;br /&gt;
The backend contains several configuration settings that allow developers to adapt the system to different requirements.&lt;br /&gt;
&lt;br /&gt;
Some settings can be modified without affecting the underlying application logic, while others require changes across multiple files to maintain proper communication between the frontend, backend, and Robobot&lt;br /&gt;
&lt;br /&gt;
This section outlines the available configuration options, their purposes, and the considerations developers should be aware of before making changes.&lt;br /&gt;
&lt;br /&gt;
==== Environment Variables ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file contains two environment variables: &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt;. These variables are used for authentication and session management.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;AdminPassword:&#039;&#039;&#039; Stores the hashed administrator password. This value should only be modified when changing the dashboard&#039;s login password. When updating it, the new password must first be hashed using bcrypt before replacing the existing value.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;SessionSecret:&#039;&#039;&#039; Used to sign session cookies and protect their integrity. This value should generally remain unchanged, as modifying it may invalidate existing user sessions. It should only be changed when necessary, such as when rotating a compromised secret.&lt;br /&gt;
&lt;br /&gt;
Both variables contain sensitive information and should not be publicly shared or included in version control.&lt;br /&gt;
&lt;br /&gt;
====  MQTT Configuration ==== &lt;br /&gt;
Explain how to configure the MQTT broker,&lt;br /&gt;
connection settings, and topics.&lt;br /&gt;
&lt;br /&gt;
====  API Configuration ==== &lt;br /&gt;
Explain configurable API settings and endpoints.&lt;br /&gt;
&lt;br /&gt;
==== Socket.IO Configuration ==== &lt;br /&gt;
Explain real-time communication settings.&lt;br /&gt;
&lt;br /&gt;
====  Authentication and Session Configuration ==== &lt;br /&gt;
Explain which authentication and session settings&lt;br /&gt;
can be modified.&lt;br /&gt;
=== Authentication and Session Configuration ===&lt;br /&gt;
&lt;br /&gt;
This section explains how to modify the authentication settings used by the Robot Dashboard.&lt;br /&gt;
&lt;br /&gt;
==== Changing the Administrator Password ====&lt;br /&gt;
&lt;br /&gt;
The administrator password is stored as a bcrypt hash in the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
To change the password:&lt;br /&gt;
&lt;br /&gt;
# Generate a new bcrypt hash using the desired password.&lt;br /&gt;
# Open the &amp;lt;code&amp;gt;.env&amp;lt;/code&amp;gt; file located in the &amp;lt;code&amp;gt;back-end-node-js/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
# Replace the existing &amp;lt;code&amp;gt;AdminPassword&amp;lt;/code&amp;gt; value with the newly generated hash.&lt;br /&gt;
# Save the file and restart the backend server for the changes to take effect.&lt;br /&gt;
# Verify that the new password works by logging into the dashboard.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; The password must be hashed using bcrypt. Do not store the password in plaintext.&lt;br /&gt;
&lt;br /&gt;
==== Session Secret ====&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;SessionSecret&amp;lt;/code&amp;gt; variable is used to sign session cookies. It should not be modified during normal configuration.&lt;br /&gt;
&lt;br /&gt;
If the secret needs to be rotated, replace it with a new, securely generated random value. Changing the secret may invalidate existing sessions, requiring users to log in again.&lt;br /&gt;
&lt;br /&gt;
== Core files and Restrictions ==&lt;br /&gt;
&lt;br /&gt;
== Running the backend ==&lt;/div&gt;</summary>
		<author><name>Spring2026</name></author>
	</entry>
</feed>