AutoIoT-a Framework Based On User-Driven MDE For Generating IoT Applications
AutoIoT-a Framework Based On User-Driven MDE For Generating IoT Applications
ABSTRACT 1 INTRODUCTION
Developing an Internet of Things (IoT) system requires knowledge Over the past years, the interest in the Internet of Things (IoT)
in many different technologies like embedded programming, web technologies has grown both in industry and academia due to its
technologies, and data science. Model-Driven Engineering (MDE) wide range of applications, including smart homes, smart healthcare,
techniques have been used as a concrete alternative to boost IoT smart grids, smart cities, and smart factories [16]. IoT projects
application development. However, the current MDE-to-IoT solu- usually share some essential features, such as sending and receiving
tions require expertise from the end-users in MDE concepts and data to/from devices, analyzing and visualizing data, and providing
sometimes even in specific tools, such as the Eclipse Modelling a user management system [2].
Framework, which may hinder their adoption in a broader context. A complete IoT system is composed of four different layers [10]:
To tackle this problem, this work proposes AutoIoT, a framework device layer, gateway, a server-side application, and data analysis.
for creating IoT applications based on a user-driven MDE approach. The usual data flow in an IoT system starts when a device sends it’s
The proposed framework allows users to model their IoT systems sensor data using low-level communication protocols (e.g., sock-
using a simple JSON file and, through internal model-to-model and ets) to a gateway. Then, the gateway transforms the binary data
model-to-text transformations, generates a ready-to-use IoT server- received into a more human readable format (e.g., JSON) and sends
side application. The proposed approach was evaluated through it to the server-side application, which is responsible for collecting
an experiment, in which 54 developers used AutoIoT to create a and storing the data in a database. Additionally, the server applica-
server-side application for a real-world IoT scenario and answered tion can also provide features like a virtual representation of the
a post-study questionnaire. The experiment reports the efficacy of devices, a Graphical User Interface (GUI) to visualize the data, a
AutoIoT and user satisfaction of more than 80% through 6 out of 7 user management system, and ways to share collected data with
evaluated criteria. third-party systems (e.g., via an API or a message queue). Finally,
the data analysis subsystem accesses the data stored and produces
CCS CONCEPTS useful insights to help the users of the IoT system to understand
their data and to take decisions accordingly.
• Computer systems organization → Sensors and actuators; •
In some cases, an IoT system does not need all four layers. Ex-
Software and its engineering → Software prototyping;
amples include (i) when devices are powerful enough to support
internet protocols a gateway is not needed; (ii) in prototypes or
KEYWORDS simpler systems the data analysis layer is not required; and (iii) in
Code Generation, User-driven, MDE, IoT application some cases, even the server-side application is not needed, since
devices can communicate directly between them autonomously.
ACM Reference Format: Developing a complete IoT system requires expertise in many
Thiago Nepomuceno, Tiago Carneiro, Paulo Henrique Maia, Muhammad different technologies like embedded programming, web technolo-
Adnan, Thalyson Nepomuceno, and Alexander Martin. 2020. AutoIoT: a gies, and data science. Given the complexity of the task, some tools
Framework based on User-driven MDE for Generating IoT Applications. In and platforms have been created to support developers. The better
Proceedings of . ACM, New York, NY, USA, 10 pages. well-known solutions are the platforms created by big companies
like Google1 , Amazon2 , and Microsoft3 . However, costs associated
,, 1 https://cloud.google.com/iot-core/
© 2 https://aws.amazon.com/iot/
3 https://azure.microsoft.com/en-us/services/iot-hub/
,, T. Nepomuceno et al.
with the provided services, as well as the vendor lock-in, may hin- The remainder of this document is organized as follows: Section 2
der the adoption of such solutions for some smaller or more specific presents the most related work. Section 3 introduces the AutoIoT
IoT projects. Framework, describing the user-driven process and implementation
Alternatively, Model-Driven Engineering (MDE) has been gain- details. Next, Section 4 details the evaluation of AutoIoT in an
ing attention from both academia and industry in recent years as a industrial use case and its findings and Section 5 briefly discuss how
concrete solution to ease the development of IoT systems through to use AutoIoT in more complex use cases. Finally, the conclusions
automatic code generation to different hardware devices [12] and are outlined in Section 6.
server-side application platforms [3, 6, 11, 13]. Nonetheless, most
of those approaches to build IoT applications present at least one of 2 RELATED WORK
the following drawbacks: (i) they are based on a strong modeling
Previous work have already used MDE technologies to ease the
phase with complex meta-models that are designed to cover a wide
development of IoT server-side applications. We describe some of
range of different scenarios, hence requiring time and modeling
these approaches as follows.
expertise; (ii) they generate only boilerplate code of the application,
Brambilla, Umuhoza, and Acerbis [3] propose a model-driven
demanding developers to write most of the application logic by
approach to design IoT Graphical User Interfaces (GUI). The work
hand; and (iii) they require expertise in tools that are standard in
defines both specific components and design patterns using a visual
the MDE community, but not well known in the industry, like the
modeling language for IoT applications and discusses the impor-
Eclipse Modeling Framework (EMF) suite.
tance of having good GUI to improve the acceptance of the IoT
According to a definition given by Abrahão et. al. [1], those
system and to model the user interactions with the GUI. The paper
work are considered as technology-driven approaches, in which
discusses the back-end software and how it stores and retrieves in-
the primary goal is to improve existing MDE techniques, usually
formation from a database, but it is not clear whether the proposed
making them more general in order to cover a broader range of
approach also generates those components or not. The approach
use cases, and not to improve the usability or to ease the adoption
requires users to have expertise in MDE and Interaction Flow Mod-
by a general target audience. Most of those works require their
eling Language (IFML).
audience to became MDE experts, learning theory and techniques
ThingML (Internet of Things Modeling Language) [11] is an
commonly used in the MDE field. On the other hand, in a user-
MDE approach that aims to cover a considerable amount of IoT
driven approach [1], the user knowledge and necessities guide the
use cases. It is already in a more advanced stage of development
development of the new MDE approach. This way, such approach
when compared with other MDE-to-IoT solutions and is especially
should provide tools that help to bridge the gap between what its
attractive to teams with MDE experts. According to the authors, the
users already know and what is expected from them to know to
main contribution of the project is a code generation framework
use the new tools/methods, making the adoption easier.
and an associated methodology to give practitioners full control
Previous work have already followed the premise behind user-
of the code by letting them easily customize compilers for their
driven MDE approaches. GenApp [15], for example, is a tool for
needs. To accomplish this, expertise in MDE and Domain Specific
building entirely functioning science gateways and standalone GUI
Language (DSL) is required.
applications from collections of definition files and libraries of code
Pramudianto et al. [13, 14] proposes IoTLink, which aims to
fragments, and Json-GUI [5] is an AngularJS front-end module that
hide many of the required expertise to develop an IoT server-side
dynamically allows data scientists and web form users to generate
application behind a Flow-Based Programming interface. It targets
form-based web interfaces. However, to the best of our knowledge,
inexperienced developers entering the IoT development, allowing
we have not found any work that applies the concepts of user-driven
them to create a ready-to-use application in minutes. While IoTLink
MDE for the design and development of IoT applications. This kind
makes an important step and is aware of the limited expertise of
of approach would benefit not only experienced IoT developers to
developers, it still requires developers to learn new skills to get
boost the application creation by reducing development time, but
started with the tool, like Flow-Based Programming and the Eclipse
also introducing new ways to build IoT systems to developers and
Modeling Framework. Additionally, the resulting system lacks some
practitioners by decreasing the technology learning curve.
essential features usually requested in an IoT application, like a
In this realm, this work proposes a framework, called AutoIoT,
GUI.
for generating IoT server-side applications that relies on a user-
All aforementioned work require some level of MDE expertise
driven MDE approach. This way, AutoIoT allows users to model
to create IoT applications, which may hinder their adoption. In
their IoT system using a simple JSON file and through internal
contrast, AutoIoT has been designed based on a user-driven MDE
model-to-model transformation and code generation techniques, to
approach and uses only technologies that its target audience al-
create automatically the IoT server-side application. Furthermore,
ready knows, like JSON representation and a general programming
IoT developers that have some expertise in MDE can extend Au-
language4 . This way, IoT and Web developers with no or little
toIoT by creating specific components, called Specialized Builders,
knowledge in MDE techniques can design and generate ready-to-
that are responsible for generating the source code of specific IoT
use IoT server-side applications, thus reducing development effort
applications. The proposed framework is evaluated with users with
and the technology learning curve.
different backgrounds who modeled and developed a real IoT server-
side application. The results indicate that the users were able to
create the application correctly and in a short time with no or little 4 Currently
the AutoIoT framework is available only in Python, but ports to other
knowledge in MDE. programming languages are planned
AutoIoT: a Framework based on User-driven MDE for Generating IoT Applications ,,
Developer
Yes
Figure 2: The developer starts the process by creating the model that represents the IoT scenario. It can be done using a GUI,
programming library or a simple JSON file. The defined model is the input for a Specialized Builder that, through M2M and
M2T transformation, generates the IoT server-side application source code. Optionally, the developer can also extend the
generated application to fulfill further requirements.
Project
project + name : EString
project
+ description : EString
+ app_port : EInteger
project project
topics
* component
* Endpoint
* sensors sensor_fields
Topic + path : EString
parameters
Sensor SensorField
+ topic : EString + type : EEnum sensor
* *
+ name : EString Parameter
+ code : EString + code : EString
sensor + name : EString
sensor_data_fields
SensorDataField + value : EEnum
*
Figure 3: The meta-model that defines an IoT project and its components. Components represented by continuous line are
obligatory and need to be present in the model created based on this meta-model. Components represented by dotted line are
optional and will be generated using a model-to-model transformation (M2M) (explained in Section 3.2).
most of the General Programming Languages have native support 3.2.2 Generating server-side application code. After the modeling
to JSON. phase is finished, the created model is used as input to a Special-
After the modeling is completed, AutoIoT loads the content of ized Builder that starts an M2M transformation. Then, the extended
the model file using a function. The first step is to validate and model goes to an M2T transformation phase that generates the
transform the JSON file into Python objects using the Pydantic5 source code of an IoT server-side application. The type of applica-
library. After that, the framework finally delivers these objects to tion generated depends on the Builder used. This work implements
the appropriated Builder that will generate the application code. the Prototype Builder (PB), a Specialized Builder that produces an
IoT system to manage IoT devices. The PB, the M2M, and the M2T
5 https://github.com/samuelcolvin/pydantic transformations are detailed in Section 3.3.
AutoIoT: a Framework based on User-driven MDE for Generating IoT Applications ,,
The build method is responsible for applying the M2M and M2T
transformation to the model created by the load_project method.
In turn, the parameters of the build method are the chosen Spe-
Specialized Builders
cialized Builder, the output folder and a dictionary with additional
configuration. In this example the Prototype Builder is used, and Prototype
Builder
Device Twin
Builder
Flutter App
Builder
the Docker6 deployment is set to false.
3.2.3 Extending the generated code. After the source code gener-
ation, the developer has the choice to extend it to fulfill further Prototype application to
A microservice that Flutter App source code
requirements of the project or use the generated application as is. manage different IoT
provides a REST API and
create an abstraction of
that can be compiled to
devices Android or iOS
The generated application is already ready-to-use, and it can be IoT devices
3.3 Prototype Builder Figure 4: A developer can create Specialized Builders extend-
AutoIoT provides an implemented Specialized Builder called Proto- ing the abstract class Builder provided by AutoIoT. Each
type Builder (PB). It has been chosen as the first Specialized Builder Builder receives the same model but produces different ap-
due to its wide use as a server-side application in several IoT plications. The generated application can follows a mono-
projects, since every project usually needs a prototype and most lith architecture like the application generated by the Proto-
IoT scenarios need to communicate with and manage IoT devices. type Builder, a microservice architecture like one generated
6 Docker
by the Device Twin Builder or even create a complete mobile
is a tool designed to make easier to deploy, run and maintain applications by
using containers technology. application if the Flutter App Builder is used.
,, T. Nepomuceno et al.
(Section 3.3.1 and Section 3.3.2). Following the transformations pages. Since developers are already familiar with its syntax, they
executed by the PB are detailed. can easily change the templates if there is a need for it.
To help developers implement both transformations (M2M and
3.3.1 M2M Transformation. When the model defined by the user M2T), the Builder class provides a function that goes through the
is loaded by AutoIoT (line 5 of Listing 2) it is validated, processed whole model and triggers functions depending on the type of the
and stored in memory as a graph, whose nodes are components component found during the search as already described in Sec-
of the model. The M2M transformation consists of visiting each tion 3.3. After the implementation of the callback functions, which
node of the graph and checking its type. Examples of types include are triggered when the search find each type of component, the
Project, MQTT, Database, Device and Sensor. For each type of com- Specialized Builder became very simple as shown in Listing 3.
ponent, the transformation creates specific dotted-line components
and attaches them to the input model. For example, whenever the
transformation finds a Device component in the original model, it 1 from .callback_functions import found_device, found_project,
creates a Topic, HTTP API, WebSocket and Dashboard components ,→ found_database
and includes them in the original model. 2
3 class MySpecializedBuilder(Builder):
3.3.2 M2T Transformation. Similar to the process described in the 4
5 def __init__(self, project, output_path, config):
M2M transformation (Section 3.3.1), in the M2T transformation the 6 self.project = project
PB also visits each node of the graph and checks its type. For each 7 self.output_path = output_path
8 self.config = config
different type, it triggers a different function that generates source 9
code for the application using the templating technique. The default 10 def extend(self):
templating engine used by AutoIoT is Jinja8 , commonly used inside 11 self.register_callback(Project, found_project)
12
the Flask Framework to render HTML content. 13 self.search()
Each triggered function receives as input a component defined 14
def generate(self):
in the model and generates part of the IoT application source code. 15
16 self.register_callback(Device, found_device)
For example, whenever the search finds a Device type component, 17 self.register_callback(Database, found_database)
the found_device function is triggered. It receives the Device object 18
19 self.search()
as input and generates a Python class that represents this type of
Device. Furthermore, the found_device function also generates a
controller class to feed the GUI with information from the database Listing 3: A simplified example of a Specialized Builder class.
concerning this type of device. Additionally, it also generates HTML This is not a working source code, some parts like libraries
files that list the devices stored in the database and performs the importing and inheritance specific details were removed to
CRUD operations (Create, Read, Update and Delete). However, in increase the overall readability.
case the graph search finds a Dashboard instead of a Device, it trig-
gers a different function that generates HTML, CSS, and Javascript
files that compounds the GUI. Other Specialized Builders can be created by developers and in-
At the end of the M2T transformation process, the PB generates corporated to AutoIoT (as shown in Figure 4). The only restriction
the source code of a Flask project. This project is written in Python, is that it receives as input a JSON object containing a model that
HTML, CSS, and Javascript, communicates with IoT devices, and follows the proposed meta-model as shown in Listing 2. There are
stores its sensor data in a database. The Flask project supports differ- no restrictions about the type of system the Specialized Builder
ent communication protocols (e.g., HTTP, Web Sockets and MQTT) can generate (Web, Mobile or Desktop) or the underlying program-
that allows third-party systems to communicate using various web ming language used to implement it. Even that anyone can create
technologies. Furthermore, it provides a GUI that can be used to a Builder and incorporate to AutoIoT, in a normal workflow devel-
manage the IoT devices, and visualizes sensor data using tables, opers do not need to create any Specialized Builders since most of
charts, and maps updated in real time. Finally, it also provides a user the Builders are provided by the AutoIoT Framework itself or its
management system to allows different levels of access to the stored community, similar to how it happens when choosing a third-party
data. Figure 5 depicts a dashboard page of the system generated for programming library.
the smart container motivating example.
4 EVALUATION
3.4 Implementation Details To evaluate the AutoIoT framework an experiment has been con-
AutoIoT Framework is implemented using Python 3 and uses the ducted. It consists of using AutoIoT to generate the server-side
Pydantic library to provide model (JSON file) validation and pro- application of an IoT use case, extracted from one of our industrial
cessing. projects. After trying AutoIoT, the developers answered a post-
The Jinja is the default template engine used for the M2T transfor- study questionnaire to evaluate their experience. This helps us to
mation (but other options can be used). It is the standard template understand what technologies should be used when developing
engine used by the Flask framework, which is used to render HTML tools for this target audience: IoT and Web developers.
In the rest of this section the use case, the experiment, and the
8 http://jinja.pocoo.org/ results are detailed.
AutoIoT: a Framework based on User-driven MDE for Generating IoT Applications ,,
Figure 5: A dashboard page of the prototype application generated by the Prototype Builder for the motivating scenario. It
allows visualisation of the data sent by a container, including basic information about the container and its sensor data (tem-
perature, position and filing status).
4.1 Experiment the same scenario introduced in Section 3.1. This very simple sce-
To evaluate the proposed framework an experiment was conducted. nario was chosen to make the evaluation process simpler, since
First, 5 developers from both academy and industry were invited to some of the participants are Web developers with no expertise in
use AutoIoT to develop the application for the use case described IoT, a simpler use case allows them to understand and evaluate
in Section 3.1 and answer the post-study questionnaire (available the framework better. In Section 5 is discussed briefly how to use
on Google Forms9 ). This initial phase was used to improve both AutoIoT in more complex IoT use cases.
the experiment and the questionnaire itself. The tutorial also describe the steps required to accomplish the
In the second phase of the experiment, developers from different task. The task consists of (i) using AutoIoT to generate the applica-
companies and research labs around the world were invited to try tion source code for the given scenario, (ii) running the generated
AutoIoT. The only requirement needed was to have previous experi- software and (iii) simulate the smart containers through the pro-
ence with IoT or Web development. In total, 54 developers finished vided Simulator software.
the experiment and completed the questionnaire. The evaluation After completing the tutorial, the participants were asked to
was performed by 17 − 56 years old participants (Mdn = 28.81, answer a post-study questionnaire. The questions are presented as
Std = 7.56), with qualification ranging from Doctorate to no tech- statements (S1-7) and are divided into two groups. The first group
nical qualification at all. The two most common qualification levels evaluates AutoIoT itself, and the participants should choose the
have a Bachelor and Master degree, corresponding to 62% of the answer from a five-point Likert scale ranging from agree to disagree.
total of participants (17 participants has each qualification). Most of
the participants declared to have between 5 to 8 years of experience • S1 - The system generated by AutoIoT cover the require-
in programming (38.89% of the participants). ments of the scenario.
The experiment consisted of downloading a zip file containing • S2 - After reading the project description file I could easily
AutoIoT, a device Simulator software and a tutorial that describes change the configuration to cover a scenario with different
IoT devices.
• S3 - I would spend more than 40 working hours to manually
9 https://forms.gle/m2BBKmWJfNxiiexA6 codify the same system generated by AutoIoT.
,, T. Nepomuceno et al.
4.2 Results
Since the group of developers that participated in the experiment
consists of professional Web developers and IoT researchers, it was
expected that most of them show expertise in General Programming
Languages and Internet of Things technologies as depicted in Figure 6.
Few developers reported expertise in Domain Specific Languages Figure 9: Questionnaire results from the participants with
and Model-Driven Engineering. This finding supports our choice of expertise in IoT.
not including any of these technologies, at least not in a way visible
to developers. Results also show that few developers have expertise To better understand the groups with different expertise, the
in Flow-Based programming, a technology commonly employed to participants were divided in three groups (with possible intersec-
quickly model the behavior of a system (used by Pramudianto [14] tions): (i) participants with no expertise in MDE, (ii) participants
and Node-Red, for example). with expertise in MDE and (iii) IoT experts.
AutoIoT: a Framework based on User-driven MDE for Generating IoT Applications ,,
The participants with no expertise in MDE represent 86% of It is possible that the participants were already considering tools
the total and reacted positively to all aspects evaluated. 97% of the that they know that could speed up the development process. This
participants agreed that the system generated by AutoIoT cover is a preliminary result, only 8 out of the 54 participants that partici-
the requirements of the scenario (S1) and all of them agreed that pated in the experiment declared to have expertise in MDE. This
using AutoIoT to generate the server application was easy (S6), as is expected since MDE experts are not the target audience for this
can be seen in Figure 7. In turn, 71.73% of the participants agreed work. To better understand this group, further studies including
that it is easy to use AutoIoT in a different IoT scenario (S2) and more MDE experts are needed.
84.78% agreed that they could use AutoIoT in a future IoT project The group with expertise in IoT mostly contains no MDE ex-
(S7). Only 4.34% and 6.52% of the participants had difficulties in perts, so its evaluation is very similar to the first group. The main
understanding the generated code (S4) and changing the behavior difference between both groups is that IoT developers are familiar
of the generated system (S5), respectively. Finally, 93.47% of the with the difficulties of developing the application to the proposed
participants agree that AutoIoT saves development time and that scenario. All of them agreed that they would take more than 40
replicating the software produced by AutoIoT manually would cost hours of work to implement the application generated by AutoIoT.
them more than 40 hours of work (S3). This work also shows that Web and IoT developers do not have
No participants of the group containing MDE experts disagreed expertise in many of the technologies required to use conventional
with S1, S4, S6, and S7, but 12.5% of them disagree about the time MDE-to-IoT approaches. This finding goes in accordance with [7],
necessary to create the same application generated by AutoIoT (S3), which found that less than 11% of a total of 3785 surveyed pro-
the easiness of change the JSON file for a different scenario (S2) and fessional developers use any form of modeling (even sketches in
about how easy would be to change the behaviour of the generated a whiteboard) during the development, and most of them do not
system (S5). know or do not remember formal notations, like UML.
In the last group (Figure 9), containing participants with expertise Finally, it is important to highlight that none of the developers
in IoT development, 96.55% of them agreed that the generated had any assistance other than the step-by-step tutorial provided
application cover all requirements of the scenario (S1). All of them during the experiment. Personal assistance or further documenta-
agreed that develop the generated system manually would take tion about AutoIoT were not provided. The lack of documentation
more than 40 hours (S3) and that use AutoIoT was easy (S6). 93.10% may be the reason behind some of the participants (7.40% of all
of them agreed that they would easily apply AutoIoT in a scenario participants) were not sure about how to extend the generated code
with different devices (S2) and 89.65% agreed that they could use (S5).
AutoIoT in future IoT projects (S7). Finally, only 3.44% thinks that
the generated code was not well organized (S4), and 6.89% of them
5 MORE COMPLEX USE CASES
were not able to extend the generated system (S5).
The system generated by the Prototype Builder (PB) is excellent for
prototyping development or scenarios that are very similar to the
4.3 Discussion one presented in Section 3.1, but since it is based on a monolith
Overall, all participants were satisfied with the system generated architecture, it would be hard to adapt its source code to more
by AutoIoT and its easy(and ready)-to-use feature. The results of complex IoT scenarios.
the evaluation show that the user-driven approach proposed by In bigger IoT projects, it is common to use a microservice archi-
this work and the AutoIoT framework accomplish its goals, pro- tecture [17], in which the complete system is composed of multiple
viding a tool that helps developers quickly create IoT server-side small independent services that communicate to each other using
applications with no need to learn new technologies, as shown by lightweight mechanisms. In those scenarios, AutoIoT could be used
the group with no MDE expertise (Figure 7). to generate some of these services, like a Device Twin Service, MQTT
The experiment also shows that the group with MDE expertise Message Processing Service, Report Generator Service or a GUI, for
is slightly more resistant to the AutoIoT approach (as shown in example. This way, the complete solution would be composed by
Figure 8), 12.5% of them had difficulties changing the model (the manually written software in conjunction with the ones generated
JSON file) and extending the generated source code. This probably automatically by AutoIoT.
happens because they are used to other kind of model representa- The main advantage in use AutoIoT compared to hand-written
tion and it is not common, in a traditional MDE approach, to ask software is that AutoIoT automatically adapts to the characteris-
users to change the generated source code. Usually the user rarely tics of the devices and sensors that are going to be used in the
update the generate code and, if a different output is desired, the new project. This means that changing one file (the JSON file that
models or the transformation usually need to be changed. contains the model) AutoIoT is able to generate multiple ready-
While working with models is natural to system designers and to-use microservices that can be automatically incorporated into
MDE experts, it is mainly avoided by common developers. Mostly the new project, with little-to-no change in the generated source
of the participants of the experiment showed no modeling expertise code. Without AutoIoT, either the microservices would need to be
and are used to work in the source code directly (Figure 6), using implemented or previous source code would need to be adapted,
AutoIoT as a tool to speed up the development in the initial phase increasing the cost of the project.
of the project. Additionally, 12.5% of the participants with MDE Furthermore, the microservices created by the Specialized Builders
expertise disagree that they would take more than 40 hours of work could also work in collaboration with other open-source projects
to manually develop the system generated by AutoIoT. like Node-RED, Eclipse Hono and Eclipse Ditto, for example.
,, T. Nepomuceno et al.
10 https://github.com/AutoIoT