### Infrastructure Design

---

As for our project, we've made the following design choices for our infrastructure.
We've decided to implement a NodeJS server on a Raspberry Pi, which will handle the requests for retrieving exercises.
This server will communicate with a MariaDB database, which contains the exercise data.
The Pepper robot will host a web server, which will handle the incoming rotational data from an ESP8266.
This data will then be processed by a motion processor class, `InputProcessor`, which will compare the rotational data 
to the data of the current exercise and show how well the user is performing.

Down below is a visual representation of how this infrastructure will look like.

### General Infrastructure Diagram
```mermaid

graph TB
    subgraph "Raspberry Pi"
        server[NodeJS Server\n\nHandles requests for\nretrieving exercises]
        db[Database - MariaDB\n\nContains exercise data]
        server --Fetch database entry--> db
        db --Return retrieved entry--> server
        
    end

    subgraph "Pepper Robot"
        webServer[Web Server\n\nHandles incoming rotational data\nfrom ESP8266]
        motionProcessor[Motion Processor\n\nProcesses rotational data,\ncompares it to the current exercise\nand shows the statistics on the screen]
        ui[User Interface\n\nShows the current exercise,\nhow to perform it and the\nstatistics of the user's performance]
        motionProcessor --Send HTTP GET for Exercise--> server
        server --Send exercise data\nin JSON format--> motionProcessor
        webServer --Process rotational data--> motionProcessor
        motionProcessor --Show statistics\non the UI--> ui
    end

    subgraph "Motion Sensing Device"
        esp[ESP8266\n\nMeasures sensor data\nand sends it to the web server]
        gyro[Gyroscope\n\nMeasures rotational data\n&#40Rx, Ry, Rz&#41]
        esp --Send rotational data\nto Pepper Web Server--> webServer
        gyro <---> esp
    end

```

### Database Diagram

For the design of our database, we've decided to only add a single table named `Exercise`.
This table contains all the information needed for the exercises.
```mermaid
classDiagram
    class Exercise {
        +ExerciseId : INT
        +Name : VARCHAR
        +Description : VARCHAR
        +ShortDescription : VARCHAR
        +ImageURL : VARCHAR
        +VideoURL : VARCHAR
        +MuscleGroup : VARCHAR
        +Path : VARCHAR
    }
```