The Internet of Things (IoT) integrates a large number of heterogeneous and pervasive objects that continuously generate information about the physical world. These objects, through standard communication protocols and unique addressing schemes provide services to the final users or systems. IoT is envisioned to bring together billions of devices, also denoted as smart objects, by connecting them in an Internet-like structure, allowing them to communicate and exchange information and to enable new forms of interaction among things and people. Given the distributed nature of IoT applications, it is often the case that the application is modeled, developed and tested on each compute node, and connected to other nodes in the application network for achieving the end result. Therefore the deployment of application is also, more or less, done on each individual compute node. In this paper we propose an approach where the IoT application can be modeled in one place, where after modeling, the different pieces of application are annotated with location information, and based on this annotation, the application is decomposed into fragments that are deployed to corresponding individual compute nodes, automatically generating code to remotely connect the application fragments to other application fragments on other compute nodes in the edge or in the cloud.