When designing a system, especially with sensitive data, it is important tounderstand the potential threats to that system, and use appropriate defensetechniques. It is important to design security model of the product at thevery beginning of the development cause finding, eliminating and preventingappearance of possible ways by which attacker might be able to break intothe system helps us to secure from data leaks.3 In order to optimize securitybest practices, it is recommended that a typical IoT architecture is dividedinto several zones.3 These zones are described fully throughout this sectionand include:– device– field gateway– cloud gateways– protocol of data transferThis fragmentation allows us to effectively segment infrastructure, allowingeach element to apply to it’s own authentication and authorization require-ments as well as secure data individually. Positive side effect of this approachis failure and breach isolation and restricting it’s consequences to particulartrust level. 3 Inside of these zones we can highlight such types of attacks: 3-Spoofing-Denial of Service-Tampering-Information Disclosure-Elevation of PrivilegeBut this is still actual, if we are talking about classical IoT model, that requirescloud-based back-end. While using blockchain and having serverless back-endwe can solve several issues:– reduce costs and capacity as there is no need for a centralized entity: devicescan communicate securely, exchange value with each other, and executeactions through smart contracts– secure messaging between devices: the validity of a devices identity is ver-ified, and transactions are signed and verified cryptographically to ensurethat only a messages originator could have sent it and as a result we canget secure from distributed denial-of-service attacks.– As there is no single point of failure system is safe from downtime – recordsare on many computers and devices that hold identical informationThe most vulnerable part of every modern system is data transfer as it isperformed through public networks which might be compromised and are vul-nerable to man-in-the-middle security attacks.To isolate sensitive information transfer and prevent cloud storage of deanon-imized data we suggest splitting architecture into loosely coupled layers withstrong cohesion inside each level. This approach forces us to partly processprivate data on the edge of the infrastructure and expose only generalized andanonimised data to the cloud storage system.System consists of following layers as shown on Fig. 1:– Expert Layer – is the physician assigned to patient, capable for assigningtreatment approving analysis layer’s recommendations.– Cloud layer – capable for data gathering, storage, analysis and integrationwith external data. While being scalable, cost and productivity-efficient,enhancing ease-of-access to the information it is very vulnerable to mostkinds of attacks from denial-of-service (DDOS) to person-directed hack-ing.2– Private client’s layer consisting of mist-computing BSN layer, cloud gate-way and user interaction (UI) layer. These sublayers are capable, namely,for processing sensor output and retrieving context, integrating with cloudand providing feedback to and from the patient.User’s smartphone is usually used as cloud gateway as it provides availabil-ity of internet connection with cloud layer and BlueTooth for communicationwith sensor networks coupled with enough computing power for data process-ing and is always aware of user’s location and other context data.Basic data gathering and processing is being performed on the smart sen-sors reducing network load and eliminating security and privacy issues. More-over, modern smart phones can even take part in analysis process5. For ex-ample using the pre-trained deep learning model we can acquire human breathfrequency only from one one accelerometer sensor output with 90 percent prob-ability which can assist us in asthmatic attack detection and prevention. Withmost edge devices being context-aware, this opens wide range of possibilitiesfor further integration with smart-city health care modules (e.g. automati-cally call closest ambulance on heart attack event, find the drugstore with theneeded treatment available).Cross-layer communication is performed in hierarchical fashion with anexception for urgent situations (exacerbation of the disease, attacks and otherdefined events) where user can communicate directly to the assigned expert.Protocol peculiarities for data privacy and security are further described insections 4 and 5.