Microservice architecture for a remote management platform for pastured poultry farming using Amazon Web Services and wireless mesh sensor networks

.

Microservice architecture for a remote management platform for pastured poultry farming using Amazon Web Services and wireless mesh sensor networks
Limitaciones: la selección de tecnología de arquitectura de software se basó únicamente en los servicios ofrecidos a la fecha del estudio en el nivel gratuito de la plataforma Amazon Web Service.
Limitações: A seleção da tecnologia de arquitetura de software foi baseada exclusivamente nos serviços oferecidos na data do estudo na camada gratuita da plataforma Amazon Web Service.

INTRODUCTION
The consumption of animal-based food products presents a growing demand in different latitudes of the world, therefore, livestock production industries, both on a small and large scale, play a fundamental role to be considered during the process of lecting all relevant information for production activities, efficiently managing process execution and resources, and consequently, facilitating the generation of reports and statistical projections that could help producers and industry-related stakeholders in the decision-making process. In other words, Agriculture 4.0 is a concept that involves a set of strategies for taking advantage of IoT technologies to optimize the management and execution of activities required in various stages of food production-related industries, having the ability to continuously monitor the status of the production, as well as improve the use of time and available resources, aiming to develop a truly intelligent agriculture, capable of satisfying the crescent market and public demands [3]. In this context, the poultry production industry stands out as one of the main beneficiaries of this type of technology development strategy, especially in easing supervision activities in extensive production systems, such as: free-range and pastured poultry farming where birds are raised in open fields [4], considering the economic importance that poultry products have for developing countries, as well as the lofty standards that the public expects from this industry to ensure the proper rearing and welfare conditions of commercialized birds [5].
However, the current adoption rate of these new technologies is hampered by key factors such as high entry cost of implementation, lack of awareness by producers about the benefits provided in the long term by these solutions for their business,  [6]. In this sense, the deployment of WSNs facilitates constant monitoring of food production industries, even in rural areas without the need for human intervention [7], making efficient use of limited storage capacity, battery life, and energy consumption, as well as the transmission range of the devices [8], which requires the design of specialized algorithms capable of supporting the transmission of the type of data managed by these solutions [9]. requires, as has been found in studies reporting the deployment of MSA management systems in different animal production industries such as beekeeping [11] and cattle farming [12]. The development of MSA management systems involves the use of design patterns that deconstruct the composition of systems into various components known work as microservices, each dedicated to a specific functionality or required feature [13]. In this way, systems are made up of multiple components of lesser complexity and with low interdependence among themselves, which allows for their modification and maintenance without completely affecting the global operation of the system, while speeding up the response capacity to new business requirements and goals as they arise [14]. In [15], the authors presented the development of a web and mobile platform for the remote monitoring of animal welfare conditions of farms dedicated to cattle and pig rearing, as well as poultry farming. The system integrates readings of different parameters captured through wireless devices located in the body of the livestock and in their rearing spaces, with the captured information managed on a web platform through microservices dedicated to the storage and presentation of data. This type of architecture has also been applied to the supervision of pig feed silos using wireless laser measurement devices and microservices for system user authentication and alerts, as reported in [16].
In the context of cattle farming, studies [12] and [17] described the development of two platforms for the remote monitoring of animals raised in the field. These platforms consist of specialized microservices for animal health monitoring through wireless devices located on the hoof and/or neck of a cow, accompanied by machine learning models for the classification of movement patterns and behaviors for the early detection of diseases. Similarly, [18] presented an agile approach for the development Similarly, the authors of [19] reported the design of a platform for data acquisition, storage, and digitization of companies dedicated to aquaculture. This study presents the development of wireless environmental sensors to monitor water tanks dedicated to fish production and transmit captured data to a web dashboard with services for data analysis. Similarly, a study [20] described the design of a reactive MSA to communicate the components of an environmental monitoring system based on a self-organizing WSN for aquaculture production. In addition, [21] reported the design of a system for the early detection of pathogenic bacteria in seafood using biosensors, and MSA for the management of captured parameters through a processing strategy based on state machines.
In the beekeeping industry, a study [11] described an online platform for the remote monitoring of environmental conditions in beehives for commercial honey production. This platform uses a microservice to communicate wireless sensor readings from beehives to the end user's monitoring application. In addition, a study [22] presented an MSA for processing, modeling, and integrating heterogeneous data obtained from wireless devices installed for real-time monitoring of beehives for commercial honey production.

MATERIALS AND METHODS
This study presents the design and development of a platform for remote environmental monitoring of pastured poultry farming rearing spaces, such as chicken tractors or mobile chicken coops, using WSN nodes deployed as a mesh, also known work as a WMSN. WMSN technologies allow the use of secure communication protocols for robust scalable deployments and efficient energy consumption, without the need to combine different network technologies [23], which have been tested in scenarios such as office monitoring [24], home automation [25], factory management [26], and even robot communication [27]. Figure 1 shows the design of the overall network architecture of the system and the relationships between the components.  From left to right, Section A in the diagram corresponds to the deployment of the WMSN in the poultry rearing space based on a mid-to large-sized mobile chicken tractor [28], to monitor the status of different environmental parameters on the inside.
Each node of the network is labeled with a letter specific to the type of sensor for supervised parameters, such as lighting (L), temperature (T), sound (S), relative humidity (H), and air quality (G). These nodes are arranged in a mesh topology, in which each node can take advantage of its proximity to other neighboring nodes to use them as a relay so that the information generated can be successfully transmitted to the sink node (C). The use of computing devices at the edge of the network helps reduce the information processing load that would otherwise fall on devices in the fog or cloud, speeding up the analysis of information and reducing the size of data packets transmitted by each node [29].
The sink node (C) is responsible for collecting and processing the data received by the network nodes and presents the environmental condition readings locally through an administration panel on an integrated screen. Simultaneously, this node acts as an IoT gateway to node (N) for transmission of the data generated in the rearing space over long distances. Subsequently, node (N), presented in Section B, functions as a network gateway to the Internet, communicating the received data to a cloud platform for further storage, processing, analysis, and remote management through web browsers or a mobile application.  [30] by providing useful insights to support decision-making activities in each production stage [31]. End-to-end analytics allows the effective modeling of system information distribution through its different processing stages, from data source devices to the final interaction channels used by end users, which can be represented using a data flow diagram [32]. Figure 2 presents a general view of the end-to-end data life flow of the system, taking into consideration the information processing stages from data capture origin devices, followed by local data processing stations, and arriving at the final presentation for end users' devices. The system data flow diagram comprises three integrated levels, as described below.
1. The upper level represents the different computing elements that make up the environmental monitoring system, starting with sensor nodes at the edge of the network, continuing with a hub station for the execution of fog computing mechanisms, such as on-site processing and temporary data persistence, and ending with an Internet cloud computing platform for user-friendly remote information access, long-term data analytics, and system management.

Layered microservice architecture description
For this research, the design of a multilayer MSA inspired by the proposals presented in [12] and [20] was chosen for the development of the cloud platform for the system. In this sense, a multilayered MSA allows the organization of system components around business requirements, facilitating aspects such as agile development, testing, feature deployment, and data automation [33], while providing compatibility with the scalability, elasticity, and rapid provisioning of resources through the implementation of cloud computing technologies [34]. Figure 3 shows the design of the multilayered MSA for the remote-monitoring cloud platform.     • The Domain layer is responsible for modeling and correctly representing business logic and data in the system.
-Transformation microservice: a group of tasks dedicated to processing raw data into the appropriate formats used by the system.
-Analysis microservice: is composed of specific tasks for the generation of information resulting from the processing of captured data.
-Modeling microservice: tasks oriented to the digital representation of the relationship between business entities.
• The infrastructure layer is responsible for the persistence and communication of data, as well as the configuration between the components.

Environmental data transmission
The testing process began by considering how the environmental data would be captured and the format in which this information would be structured for processing and transmission according to the data life flow stages. In this case, the dataset provided in [35] was used to represent the environmental information captured by

WMSN Gateway nodes prototypes
For the initial test process of the wireless environmental monitoring network, prototypes of fog station nodes C and N presented in Figure 1 were developed, which correspond to the WMSN gateways. Figure 4 shows the hardware components used for the initial prototyping and testing of gateway nodes. Node C is composed of a Raspberry Pi 3b+ microcomputer as the central fog computing device for the execution of the tasks described in Stages 3 and 4 in the data flow diagram presented in where the data are transmitted over a long distance to node N using LoRa communication technology. In turn, gateway node N is composed only of a Heltec WiFi Lora 32 (V2) microcontroller, which needs to be connected to a local Internet network over Wi-Fi communication to be able to send the data received via LoRa transmission from node C to the remote monitoring platform in the cloud.  Figure 5 presents a cloud platform architecture diagram for the remote monitoring system based on the implementation of resources provided by Amazon Web Services (AWS) [36], as this platform offers an ecosystem of highly configurable and reliable services applicable to animal farming, as shown work in [18]. With the intention of testing and validating the performance of the basic microservice functionalities involved in the reception of environmental data in the cloud platform according to the designed MSA, the technology selection for the proposed cloud architecture was limited to services available in the free tier offered in the AWS cloud catalog at the date of the study. For microservice development, the process was conducted using the tools The relationships between the different technologies selected are described as follows:

Cloud platform technology selected
1. First, the cloud platform can receive different calls by sending or requesting information through different communication channels, such as a mobile application, web application, and/or from the IoT gateway.
2. These calls are made using the API Gateway service, which provides defi- 4. These functionalities are designed as microservices that are independently isolated in EC2 instances using Docker containers. Each microservice has a set of specific tasks and methods programmed in a Spring Boot application.

Each microservice instance is assigned a set of Identity and Access
Management (IAM) credentials to access the DynamoDB NoSQL database service configured for data persistence.

Persistence microservice deployment
The first development and testing cycle of the designed MSA focused on validating the execution of the tasks defined for the operation of the persistence microservice presented in the infrastructure domain layer. This microservice was programmed as a single Spring Boot application using a Model-View-Controller (MVC) software design pattern to define the methods required to send and request environmental data with the database. Figure 6 shows the The only mandatory field to save a new registry in this case is the Partition key (and the Sort key in case of a composite Foreign key), and the remaining items can be stored independently or in different orders depending on the defined data transmission strategy. Figure 7 shows a screenshot of the DynamoDB table in the AWS console of this project with a list of rows of environmental data stored using the persistence microservice and a data aggregation strategy. Source: own work.

DISCUSSION
Among the main contributions of this study, a survey of the state of the art regarding the development of remote management systems in animal production industries • End-to-End scope The system design process should start from a comprehensive vision of the desired solution, avoiding any restricting focus on specific stages of the process that could prevent adequate integration of internal and external components [12], easing the support of different types of data sources that could serve as input for the system in the future [22], while considering key usability factors such as reliable information distribution channels, user-friendly interfaces for the diversity of end devices, adaptive responses to network speed availability, precise insights for decision-making support, and more [11]. This type of comprehensive vision was included in the design of the data flow presented in Figure 2 to clearly define each stage of the overall performance of the remote management system.

• Ease of customization on demand
Systems developed to address current business demands should have a flexible and agile design to adapt to the ongoing request for new features as well as changes to existing service functionalities [22]. This requires the deployment of an adaptative software architecture design strategy that enables the isolation of different system modules, facilitating the distribution of updates to specific features without affecting the performance of other modules [16], and at the same time, ensuring that different systems' components can dynamically interact with each other to generate the results expected by end users [20]. This led to the definition of the layered MSA with 4 domains, presented in Figure 3, to provide a framework that would allow the delimitation of the system domains, grouping of features, and integration of new services in line with business requirements.

• Resource management and optimization
The software architecture design process must implement the adequate strategies and tools required to reinforce the security controls over the entire system data flow [17], which includes computational stages such as on-site processing and cloud computing solutions, end-user applications, and data transmission protocols [15].
Subsequently, MSA design must rely on the implementation of proven mechanisms and reliable infrastructure to respond to the number of requests received by the system, preventing business performance from being affected by low response times [18]. This was considered during the technology selection stage for the MSA designed, as presented in Figure 5, taking advantage of consumer-grade cloud computing tools currently available in the market.

CONCLUSIONS
Reports in the scientific literature on the design of MSA for the development of remote management platforms for animal farming have grown work in recent years.
However, only a fraction of these solutions have focused on poultry production and the requirements of this specific industry, for which it has been considered important to delve into the development of technological solutions tailored towards this productive sector. This study presented the design of a multilayered MSA of a cloud platform, for a remote environmental monitoring system, for pastured poultry farming, through the implementation of wireless sensor networks, distributed in a mesh topology, in rearing spaces such as mobile chicken coops.
The designed microservice-based software architecture oversees the overall remote monitoring system data flow, from the capture stage of physical parameters through different measurement devices, to the presentation of information to end users on their preferred devices. A multilayered architecture design based on four domain layers was selected for the organization of the system functionalities, which are represented as microservices specific to the core business requirements. The fundamental performance of the system was evaluated through the implementation of technologies provided by the AWS cloud as well as communication between the system components through the Internet.
In future work, we will proceed with the development of physical devices for wireless mesh sensor networks, the development of new features for the remote monitoring cloud platform in line with the business requirements of poultry farming, and the development of a multiplatform application so that end users can easily access the system information.

ACKNOWLEDGEMENTS
J. Gonzalez is supported by a scholarship from the National Postgraduate Strengthening Program of the National Secretariat of Science, Technology, and