# ICD for Feelit Azure Architecture


[Azure Tire pricing](https://azure.microsoft.com/en-au/pricing/details/event-hubs/)
[Azure Tires limits](https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-quotas#:~:text=Common%20limits%20for%20all%20tiers%20%20%20,%20%2012%20%209%20more%20rows%20)
## Cloud Components:
### 1. IoT-hub/Event-hub:
* #### Description:
* Receives incoming messages to the cloud.
* Triggers Azure function to parse the data.
* Since we are aiming to Azure event hub Standard tire, we must take into accout the limitations, mainly message size(max 1mb) & rate( 1000 events/second)
* #### Input:
* Array of JSON objects:
```
[
{
id: "F90004CD00002693",
stamp: "2021-06-02T10:01:07.003Z",
context: "4959554B093791B6",
mac: "F0A74B1ED90E",
len: 54,
data: "A55A00000000007D0008007D004801491AB200016AD66C906F947167722E729272B472BA6ACB6CA46F9971577233729172B572CA00000000",
calc60: null,
calc61: null,
calc62: null,
calc63: null,
calc64: null,
sitename: "[Feel-IT PoC_EasyIoT 047394065db37b9f]",
sn: "047394065DB37B9F",
},
...
]
```
* #### Output:
* Triggers Azure function.
---
### 2. Azure function:
* #### Description:
* Bind to IoT-hub/event-hub.
* Will be triggeried when message received.
* Parses the messages the it gets on trigger.
* Store parsed data in blob storage.
* #### Input:
* Array of JSON objects:
```
[
{
id: "F90004CD00002693",
stamp: "2021-06-02T10:01:07.003Z",
context: "4959554B093791B6",
mac: "F0A74B1ED90E",
len: 54,
data: "A55A00000000007D0008007D004801491AB200016AD66C906F947167722E729272B472BA6ACB6CA46F9971577233729172B572CA00000000",
calc60: null,
calc61: null,
calc62: null,
calc63: null,
calc64: null,
sitename: "[Feel-IT PoC_EasyIoT 047394065db37b9f]",
sn: "047394065DB37B9F",
},
...,
]
```
* #### Output:
* Array of JSON objects per mac:
```
[
{
measurement: "F0A74B1ED90E",
tags: {
gwSn:"047394065DB37B9F",
stamp:"2021-06-02T10:01:07.003Z",
id: "F90004CD00002693",
sitename: "[Feel-IT PoC_EasyIoT 047394065db37b9f]",
serial:A55A,
},
felieds: {
s0:0000,
s1:0000,
s2:0000,
s3:0000,
s4:0000,
s5:0000,
s6:0000,
s7:0000,
}
timestamp:1626341446000000000
},
.
.
.
]
```
---
### 3. Blob Storage:
* #### Description:
* Data Storage component that store the data of parsed messages & analyzed data.
* #### Inputs:
1. Array of JSON objects per mac:
```
[
{
measurement: "F0A74B1ED90E",
tags: {
gwSn:"047394065DB37B9F",
stamp:"2021-06-02T10:01:07.003Z",
id: "F90004CD00002693",
sitename: "[Feel-IT PoC_EasyIoT 047394065db37b9f]",
serial:A55A,
},
felieds: {
s0:0000,
s1:0000,
s2:0000,
s3:0000,
s4:0000,
s5:0000,
s6:0000,
s7:0000,
}
timestamp:1626341446000000000
},
.
.
.
]
```
2. Docker container analysis resultss:
```
TBD
```
### 4. Docker Container:
* #### Description:
* Runs on intervals.
* Query new data stored in blob storage.
* Analyze queried data.
* Store results in blob storage.
* Store data and results to influx DB.
### 5. Influx DB
* #### Description:
* TimeSeries database to store data for further R&D.
* #### Input:
* Array of JSON objects per mac of the raw data:
```
[
{
measurement: "F0A74B1ED90E",
tags: {
gwSn:"047394065DB37B9F",
stamp:"2021-06-02T10:01:07.003Z",
id: "F90004CD00002693",
sitename: "[Feel-IT PoC_EasyIoT 047394065db37b9f]",
serial:A55A,
},
felieds: {
s0:0000,
s1:0000,
s2:0000,
s3:0000,
s4:0000,
s5:0000,
s6:0000,
s7:0000,
}
timestamp:1626341446000000000
},
.
.
.
]
```
* Array of JSON objects per mac of the analyzied data:
```
[
{
measurement: "F0A74B1ED90E",
tags: {
gwSn:"047394065DB37B9F",
stamp:"2021-06-02T10:01:07.003Z",
id: "F90004CD00002693",
sitename: "[Feel-IT PoC_EasyIoT 047394065db37b9f]",
serial:A55A,
},
felieds: {
temp:"30"
}
timestamp:1626341446000000000
},
.
.
.
]
```
* Or I can add the temp the for the fileds of the record with the same timestamp
### 6. Grafana
* #### Description:
* Data visualization tool.