---
# System prepended metadata

title: Gateway

---

# Gateway

```mermaid
graph TD;
A(Gateway) --> B(SensorManager)
A(Gateway) --> C(SecurityManager)
A(Gateway) --> D(DataManager)
A(Gateway) --> E(CommunicationManager)
A(Gateway) --> F(SystemManager)
A(Gateway) --> G(UIManager)
A(Gateway) --> H(EmergencyPredictionManager)
A(Gateway) --> I(AdditionalDataSourcesManager)
```

## SensorManager

- collect data from the sensors
- package the data
- sends to `CommunicationManager` to be send to the PMS (according to configured transmission rate)

## SecurityManager

- check origin of sensor data (sensor identifiers)
  
- store credentials (both to check the sensors and to send to the PMS)
  
- generate identifying tokes to send over the wire (no need to auth explicitly, gateway devive itself is proof of patient's identity)
  
- username and password of API token
  
- authentication for opening the app
  
- new user registration process (check with PMS for account validity before storing credentials)
  
- able to log off from PMS
  

## DataManager

- store data when going into degraded mode (sensor + notifications)

## CommunicationManager

- communicate with PMS
  
- authenticate using credentials form the `SecurityManager`
  
  - prove gateway identity
    
  - prove sensor identities
    
- detect failures in the communication
  
- controll switching between normal and degraded mode
  
- organise synchronisation of data stored by `DataManager` when connection restored
  
- keep track of duration of degraded mode
  
- switch to alternative channels when they do work (abstraction of different channels)
  
- ensure data confidentiality & integrity?
  
- make the communication unforgeable/uneditable when going over the wire
  
- can receive a request from the PMS for current data
  

## SystemManager

- measure battery level
  
- measure storage level (for when in degraded mode)
  
- notify `UIManager` when reaching limits
  

## UIManager

- interface for UI
  
- push notifications to UI / OS API
  
- receive credentials for authentication and forward to `SecurityManager`
  
- modifiable credential input for external sources (auth token)
  

## EmergencyPredictionManager

- use sensor data as input for local emergency MLModel
  
- push notification to `CommunicationManager` in case of an emergency
  

## AdditionalDataSourcesManager

- allow user to give the PMS the permission to use external data sources (fitness trackers)
  
- give listing of possible / supported external sources