## 2 Materials and Methods
### System Architecture
#### 2.2.2 Frailty Insight Detection System (FIDS)  
FIDS is composed of two distinct modules that are hosted on a Virtual Private Server (VPS). A VPS is a virtualized server that acts as a dedicated server within a larger server. FIDS operates in an isolated setting, meaning that the operations do not interfere with other operations. This setup was achieved by using the operating system Ubuntu 20.04, running on a 2 GB RAM, 1 vCPU, and 50 GB storage system. The two modules and their roles are as follows:  
Figure 1: General architecture of the frailty insights detection system. Figure 2: Workflow of the smartwatch application. NodeJS CoreHub with Prediction Engine (NCHPE)  
This module acts as the core module of the FIDS. It is responsible for secured communication with the smartwatch application (SA) and comprises two back-end technologies: NodeJS and Flask. Both technologies are web frameworks used to build web applications and API services. The architecture and data workflow are presented in Figure 3.  
Upon initializing the NodeJS module, secure WebSockets over the Internet are created to receive real-time data from the smartwatch. After defining the WebSocket, this module creates a secure web server (by using an SSL certificate), defining two routes: a GET route named /getData, which can be called by other components, transmitting real-time received data, and a POST route named /insertData, which establishes a connection with an external MongoDB database. The last route takes as input the data to be inserted and the collection name to which these data belong (for example, data received directly from the bracelet are inserted into the FIDSData collection). Another important function of this module is to spawn a child process. The newly created process receives data from the main processes and formats them so that they can be used for prediction. Based on existent data, new data are computed (for example, vector magnitude for acceleration or the three Euler angles roll, pitch, and yaw) so that a new packet is formed for prediction purposes. The Flask module is responsible for loading three artificial intelligence models that are used to determine the type of movement into memory. These models were trained locally and exported using the Python joblib library. The POST route named /predict is defined such that, when receiving a dataset as input, it is processed to match the specific header for the three models. A movement-type prediction is made using the models, and the predictions are subsequently transmitted in the JSON format. Communication between the NodeJS module and the Flask module is bidirectional. Once the prediction is completed, it is transmitted to the ActivityCompute subprocess, which is responsible for creating a new packet that incorporates the prediction timestamp and inserts using /insertData into the specific collection the type of activity predicted (in this case, ActivityPrediction). Additionally, ActivityCompute adds to the new packet, based on each prediction, the number of kcal specific to the type of activity. Figure 3: NCHPE architecture. User Interface Dashboard for Frailty Insights (UIDFI)  
The User Interface Dashboard for Frailty Insights module of the system has a WordPress instance as its main component, which interacts through the API with the NCHPE module. This component of the system has as its primary function the display of the data extracted using NodeJS CoreHub with Prediction Engine in a user-friendly way, in interactive dashboards, as follows:  
* Displaying data received in real time by calling the /getData function, as well as extracting relevant insights. * Displaying self-report forms, which aim to query the user about their physical condition, mood, and body weight. * Establish a secure connection to the Fitbit cloud and obtain stored data related to heart rate values. * Composing charts to display the history of various parameters (weight, daily variation of heart rate, and determining sedentary times).