In this master thesis we present the development of architecture and application that enables secure and private communication of Internet of Things (IoT) devices and web applications. The aim of this thesis is to design, develop and evaluate an architecture that would allow users and their data complete security and privacy when using an application built on this architecture. In the theoretical part of this thesis we present Internet of Things, basic architecture and building blocks, Ad Hoc networks, IoT device security and different application layer protocols used in IoT. After the field introduction, eight protocols are explained that are used for these kinds of applications. WebSocket (WS) is chosen as the most appropriate. A solution using the WS protocol is presented in the practical part of this thesis. It represents a relatively new approach to using WebSocket protocol when connecting devices and applications, since there is no need for advanced server for data acquisition. The only thing needed is a simple broker that runs on any computer hardware as simple program, broker connects devices on this application network. This architecture is one that allows the workings of an Ad Hoc network and applications that do not require advanced network infrastructure and are also simple with regard to the development and communication. To demonstrate this architecture, we develop three devices: a broker, an IoT microcontroller device and an IoT Web application. For architecture to work properly a communication protocol needed to be developed, one that would work with the broker and between application devices themselves. This architecture concept and broker represent the backbone to any future system or application that requires security and privacy.