**4. Data processing in fog and cloud instances**

To execute the health services, we plan to use two functionalities: (i) serverless computing; and (ii) vertical elasticity. In serverless computing, the user is in charge of submitting a collection of functions to the cloud using the HTTP protocol. Thus, the cloud, in its turn, is responsible for allocating an adequate number of virtual instances (containers or virtual machines) to execute the functions correctly. The name "Serverless," therefore, refers to the ability of the user does not take care of the number and configuration of resources to execute their demands. Vertical elasticity is used to reconfigure the resources with resizing. Taking as a starting point the physical resources, we can slice them into virtual parts (vCPU, vDisk, vMem, for example). The main with vertical elasticity is to adapt this virtual slice at runtime, allocating more or fewer resources by the demand. This strategy is pertinent to use the resources better, enabling us to pass resources from one health service to another (for example, from one that does not require so much processing power to another that is CPU hungry).

In addition to serverless computing and vertical elasticity, our architecture also uses data compression. Here, we employ two types of compression. First, we perform the following tasks: dynamic tune the interval for data collection for each person and each observed vital sign; adapt the changes on captured values to postpone data acquiring, so saving network latency. For example, the times to take data from an older adult could be different from a mid-age one. Also, if a person has a particular chronic disease or is passing through a health treatment, the time interval to analyze their vital signs should be reduced compared to that of healthy people. In addition to this first type of compression, we employ traditional lossless data compression. This compression is taken at the border to the Edge Controller. Considering that we are encapsulating vital sign data in JSON format, which is ASCII-based clear text, it is possible to use either LWW or Huffman Code algorithm to reduce the number of bytes transmitted through the network. These last two examples are known in the literature as being very efficient in dealing with text messages.

Privacy is another concern handled in the project. Our architecture deals with privacy by using federated learning and homomorphic cryptography concepts. With federated learning, data always stays close to the users. The user is in charge of training the ML algorithm, and only the gradients (the result of the ML model) are passed through the network. We can tune and update a global machine-learning model by collecting all user gradients. Homomorphic cryptography, in its turn, helps perform some action with a vector of data without exposing names or character data inside the vector. Homomorphic encryption can only be used over integer data by performing a particular arithmetic formula (for example, mean, maximum, and minimum, standard deviation). Thus, we can create insights into a specific district of a city. For instance, we can verify the number of people with fever, the mean temperature of a collection of people, and if they have heart disorders.

Our organization for information data flow is presented in **Figure 3b**. We can use a single board computer (such as Arduino or Raspberry Pi) to collect data from a family or people that work in a company. Also, the own smartphone can act as a gateway since it is commonly employed to collect that from smart bands. Employing an SBC or a smartphone depends on the use case. An SBC sends data to the internet via connectivity or an ISP provider and can interact with as many sensors as available at the patient's house. The smartphone has the advantage of online monitoring no matter where the patient is. At any moment, the user can receive notifications regarding their health status. The main idea here is to enable a proactive architecture, where we can alert the users about an eventual problem in the future, allowing them to seek timely treatment.
