Keywords
soil analysis, precision agriculture, machine learning, Flutter, Gemini AI, physicochemical properties, soil fertility, decision support system
This article is included in the Agriculture, Food and Nutrition gateway.
The analysis and interpretation of agricultural soils presents significant limitations due to the lack of accessible technological tools that facilitate the understanding of laboratory results. This situation affects agronomic decision-making and, consequently, the productivity and sustainability of agricultural systems. In response to this problem, the present research proposes TERRAGEM, an AI-based mobile application that automates the interpretation of soil physicochemical parameters and generates personalized management recommendations.
The system was developed under the agile Rapid Application Development (RAD) methodology, structured in five phases: requirements gathering, prototype design, AI API integration, functional validation with 29 real soil analysis reports, and deployment in an emulated test environment. The MBaaS architecture uses Supabase as the backend, enabling efficient data management and authentication, while facilitating integration with external APIs for agricultural decision-making.
TERRAGEM demonstrated correct operation in all evaluated use cases, generating automated interpretations of soil physicochemical parameters and personalized agronomic recommendations for the four crop types analyzed (grape, avocado, corn, and sweet potato).
TERRAGEM represents a significant contribution toward agricultural digitalization, facilitating the use of data for sustainable decision-making and contributing to the Sustainable Development Goals (SDG 2: Zero Hunger, and SDG 15: Life on Land).
soil analysis, precision agriculture, machine learning, Flutter, Gemini AI, physicochemical properties, soil fertility, decision support system
In recent years, the agricultural and food sector in Latin America has undergone significant transformations driven by the rapid expansion of digital technologies.1 Globally, agriculture has been at the forefront of adopting innovations aimed at optimizing processes and improving decision-making, a phenomenon widely documented under the concept of Agriculture 4.0.2 Artificial intelligence (AI)-based mobile applications have emerged as fundamental tools for information provision, improving operational efficiency and user experience in agricultural contexts.3,4 As noted by De León and Victorino,5 technology has enabled agriculture to adopt more modern approaches, moving away from conventional decision-making methods. In this context, smartphone-based tools for soil analysis have gained considerable relevance, allowing farmers to collect key information about soil conditions directly in the field.6 Soil analyses, conducted by trained laboratory personnel, remain crucial for informed decisions regarding fertilizer management and crop selection.7,8
Despite significant technological advances in Asia and Europe, important challenges persist in Latin American agriculture, including high soil diversity and the lack of standardization in data collection methods across the region.9 In South America, emerging technologies such as sensors and drones have begun to be adopted, primarily in Argentina; however, these efforts still face limitations related to the analysis of soil chemical properties.10 At a global scale, digital agricultural tools and data-driven farming remain largely inaccessible to smallholder farmers in low- and middle-income countries, where mobile connectivity and digital infrastructure are frequently insufficient.11 This technological gap in soil analysis and interpretation is especially critical in the context of climate change, which directly threatens agricultural productivity and food security.12
Previous research has addressed various aspects of soil analysis tool development. For example, Arce et al.13 developed C.suelos software, enabling automated soil classification using granulometry, Atterberg limits, and hydrometry. In Spain, spectral indices were analyzed to estimate post-fire sediment losses14; another study examined soil profile degradation15; and in Mexico, a soil quality index was constructed.16 A recent study by Bai et al.17 analyzed the relationship between land cover and water quality using AI. Similarly, the use of AI in desertification research has optimized natural resource management.18 However, none of these tools integrates accessible automatic interpretation of physicochemical parameters within a mobile platform oriented toward farmers.
Based on the above, TERRAGEM was developed as an AI-based mobile application for the interpretation of agricultural soil analyses. The primary objective of this research is to implement a mobile application that uses AI to interpret soil analysis results and facilitate agricultural decision-making. Unlike previous studies, TERRAGEM combines the Gemini AI language model with an MBaaS architecture and a Flutter interface, offering comprehensive analysis of edaphic parameters and aligning its functionalities with the Sustainable Development Goals.
This section describes the study design, data source and parameterization, technical implementation of the system, and the operational workflow of the TERRAGEM tool for automated agricultural soil analysis and interpretation.
This work corresponds to an applied study with a quantitative approach, oriented toward the development and validation of an automated agricultural soil interpretation tool. The TERRAGEM mobile application was designed to interpret soil analyses using artificial intelligence and generate personalized management recommendations according to crop type. System verification was carried out through functional testing with 29 real soil analysis reports, confirming that the application correctly processes the entered data and generates interpretations through the Gemini API.
The dataset comprises 29 soil characterization analyses corresponding to crops from the province of Cañete (grape, avocado, corn, and sweet potato), obtained from agricultural laboratory reports provided by collaborators of the Universidad Nacional de Cañete for academic purposes. These reports were structured in digital format and used exclusively as functional test cases for the system, in order to verify that the application correctly processes the entered physicochemical parameters and generates coherent interpretations through the Gemini API. Each analysis includes relevant physicochemical variables such as pH, electrical conductivity, organic matter, nitrogen, phosphorus, potassium, calcium, and magnesium. Agronomic experts from the Faculty of Agronomy of the Universidad Nacional de Cañete reviewed the AI-generated interpretations for the test cases, confirming that the recommendations were consistent with the crop type and the entered values.
The reference value ranges by parameter and crop type, used as the basis for the system’s interpretations, are presented in Table 1 (grape), Table 2 (avocado), Table 3 (corn), and Table 4 (sweet potato):
Technologies and libraries
The TERRAGEM mobile application was developed in the Dart language using the Flutter framework (v3.24.3/Dart ≥3.0.0), enabling the construction of a modern, intuitive, and cross-platform interface oriented toward the automated interpretation of soil analyses. Development and testing were carried out on a Lenovo Ideapad Slim 3i laptop (Intel Core i5-12450H, 16 GB RAM, 512 GB SSD), using the Android x64 Medium Phone emulator (API 36.1) to validate functionality in real mobile environments.
The system connects to a cloud database via Supabase, a platform used for user management, storage of soil analyses, and interpretation history. Automated interpretation of results is performed through the Gemini API (Google AI), which processes the analysis data and generates technical descriptions with agronomic recommendations. Integration with the OpenWeatherMap API provides real-time climate data, enriching the interpretation of soil conditions.
The main project dependencies, with their versions recorded in the repository’s pubspec.yaml file, are as follows: supabase_flutter ^2.10.1, google_generative_ai ^0.4.3, http ^1.5.0, geolocator ^12.0.0, google_maps_flutter ^2.6.0, pdf ^3.10.6, path_provider ^2.1.3, open_filex ^4.3.2, permission_handler ^12.0.1, flutter_dotenv ^6.0.0, google_fonts ^6.1.0, cupertino_icons ^1.0.8. These libraries enable communication with external APIs, geographic location services, PDF report generation, file opening, Android permission management, typographic customization, and environment variable loading.
Development methodology (RAD)
The agile Rapid Application Development (RAD) methodology was used, enabling rapid and effective software implementation through iterative, user-centered cycles. The process was structured in five phases, whose lifecycle is illustrated in Figure 1.
▪ Phase 1: Requirements gathering
In this phase, the functional and non-functional requirements tables were developed, identifying the needs of the end user: primarily farmers and soil specialists. The essential system modules were defined (user registration, soil analysis upload, AI interpretation, and results visualization), and the acceptance criteria and technical specifications were established to ensure system scalability and reliability. The identified functional requirements are detailed in Table 5, while the non-functional requirements are presented in Table 6.
▪ Phase 2: Prototype design
During this phase, interface prototypes were developed in Figma, prioritizing user experience and ease of navigation. The design contemplates a logical flow from analysis upload to visualization of the AI-generated interpretation. This process provided a clear visual representation of the system prior to technical implementation, facilitating validation of the application’s structure and aesthetics.
▪ Phase 3: AI API integration
This stage comprised the implementation of the Gemini API from Google Generative AI, responsible for interpreting data from soil analyses. In parallel, Supabase was integrated for database management and the OpenWeatherMap API was incorporated to complement interpretations with climate information. The entire environment was developed in Flutter, enabling the creation of a cross-platform application with an adaptable and efficient design.
▪ Phase 4: Functional validation
In this phase, functional tests were conducted using 29 real soil analysis reports as test cases, verifying that the system correctly processes the entered parameters and generates interpretations through the Gemini API. Agronomic experts from the Faculty of Agronomy of the Universidad Nacional de Cañete participated in this testing process, confirming that the generated responses were comprehensible and appropriate for the agricultural context.
▪ Phase 5: Deployment in emulated test environment
Finally, the system was executed in an emulated Android environment (Medium Phone API 36.1, Android x64 Emulator) to test its performance, stability, and component interactions. Once validated, the APK file was generated, prepared for future pilot testing with real users.

Source: Own elaboration. Note: The five phases follow an iterative cycle: requirements gathering, prototype design, AI API integration, functional validation, and deployment in emulated environment.
Graphical interface and processing workflow
The TERRAGEM application features an interactive and intuitive interface that allows the farmer to manually register soil analysis results by entering the physicochemical parameters obtained from the laboratory. Once the data is entered, the system executes an automatic validation process that verifies the coherence of the values and the completeness of the information.
The validated data is processed by the Gemini AI API, which generates an automated interpretation of the soil status, identifying possible deficiencies and providing management recommendations. Additionally, the application integrates the OpenWeatherMap API to display current weather conditions and the Google Maps API to visualize nearby agricultural stores.
The results are presented in a simple visual interface that displays the entered quantitative information alongside the AI-generated interpretation, facilitating understanding of the soil status diagnosis. From this same view, the user can generate a PDF report and access their previous analysis history. Figure 2 schematically illustrates the application’s processing workflow, from user interaction to the return of the AI-generated interpretation.
The TERRAGEM mobile application is designed to run on Android devices with an internet connection, as its operation depends on external cloud services (Supabase, Gemini AI, and OpenWeatherMap). The minimum requirements for the end user and the local development environment are detailed below.
Minimum mobile device requirements (end user)
o Operating system: Android 10 (API 29) or higher.
o RAM: minimum 2 GB (recommended 4 GB).
o Storage: at least 150 MB free for APK installation.
o Connectivity: stable internet access for use of the Gemini, Supabase, and OpenWeatherMap APIs.
o Required permissions: location (GPS) to display nearby agricultural stores, and storage access for PDF report generation and download.
Local development environment requirements (developer)
o Operating system: Windows 10 or higher, macOS 13 or higher, or Ubuntu 22.04.
o Processor: Intel Core i5 or equivalent.
o RAM: minimum 8 GB (recommended 16 GB).
o Storage: at least 10 GB free on SSD.
o Development environment: Flutter with Dart SDK ≥3.0.0, with Android Studio or Visual Studio Code configured.
o Emulator: Android x64 (API 29 or higher).
User workflow (end user)
Once the application is installed, the user registers or logs in, then accesses the main screen where the current weather conditions of their location are automatically displayed. The user then selects the crop type and registers their plot data. In the analysis module, the physicochemical soil values obtained from the laboratory are manually entered (pH, nitrogen, phosphorus, potassium, organic matter, electrical conductivity, and calcium). The system sends this data to the Gemini API, which generates an automated interpretation with agronomic recommendations. The user can view the result on screen, generate a PDF report, and consult their previous analysis history.
Execution in development environment
To run the application in development mode, a terminal must be opened in the project directory and the command flutter run executed. Either the Android x64 emulator (API 29 or higher) or a physical device connected via USB with debugging enabled can be used. The environment variables required for the APIs must be previously configured in the project’s.env file, following the structure defined in the repository.
The TERRAGEM project used data from real soil analyses supplied by agricultural laboratories in the province of Cañete, ensuring the confidentiality and anonymity of the sources at all times. The data were used exclusively for academic and research purposes, respecting the principles of transparency, integrity, and responsible use of information. The system was designed as a technical support tool, not as a substitute for the professional judgment of the specialist. The AI-generated interpretations were validated by faculty members and agronomic engineers from the Faculty of Agronomy of UNDC. Ethical approval was not required for this study, as the research involved only anonymized physicochemical data obtained from agricultural soil analysis reports and did not involve human participants, biological samples, or personal data. The soil data were provided voluntarily by collaborators of the Universidad Nacional de Cañete for academic purposes. No human participants were enrolled in this study; therefore, informed consent was not applicable.
To evaluate the practical performance of the TERRAGEM system, controlled tests were conducted on the Android Medium Phone API 36.1 (x64) emulator. These tests simulated real agricultural use scenarios to verify the application’s ability to assist the farmer in the process of registration, analysis, and soil interpretation using artificial intelligence.
After authenticating in the application ( Figure 3), the user accesses the main screen, where the system automatically displays the current weather conditions of their location via the OpenWeatherMap API ( Figure 4). The farmer then selects the crop type to be analyzed ( Figure 5) and registers the plot size in hectares or square meters ( Figure 6). Finally, the predominant soil type in their plot is selected — sandy loam, clay, or silty — ( Figure 7), configuring the basic parameters of the analysis environment.

Source: Screenshot of the TERRAGEM app in Android emulated environment. Note: The login screen allows access via registered email and password, with an option to create a new account.

Source: Screenshot of the TERRAGEM app in Android emulated environment. Note: The app automatically detects the user’s location and displays temperature, humidity, wind speed, and thermal sensation to complement soil interpretation.

Source: Screenshot of the TERRAGEM app in Android emulated environment. Note: The user selects from four available crops: Sweet Potato, Corn, Avocado, or Grape, which determines the reference parameters used for interpretation.

Source: Screenshot of the TERRAGEM app in Android emulated environment. Note: The user enters the plot size in hectares or square meters to contextualize the agronomic recommendations.
The user accesses the analysis module and manually registers the soil physicochemical values — pH, phosphorus, potassium, nitrogen, organic matter, cation exchange capacity, and electrical conductivity — as shown in Figure 8. Once entered, the system sends them to the Gemini API, which generates a detailed response including the evaluation of the current soil status, identification of nutritional deficiencies, and technical recommendations tailored to the selected crop. The interpretation is presented in a visual and interactive format with explanatory text and visual indicators of critical values, as shown in Figure 9.

Source: Screenshot of the TERRAGEM app in Android emulated environment. Note: Parameters entered include pH, electrical conductivity, organic matter, available phosphorus and potassium, exchangeable cations, and micronutrients.
The user can generate a PDF report containing the complete interpretation performed by Gemini, the analysis data, the date, and the analyzed crop ( Figure 10). These reports are stored in the user’s history, accessible from the main menu ( Figure 11). The system also offers a geolocation feature that allows nearby fertilizer and agricultural product stores to be visualized ( Figure 12), providing practical options for applying the report’s recommendations.

Source: Screenshot of the TERRAGEM app in Android emulated environment. Note: The report includes producer information, crop type, plot area, soil type, analysis date, and the full AI-generated interpretation.

Source: Screenshot of the TERRAGEM app in Android emulated environment. Note: The history module stores all previous analyses, allowing the user to review and compare past interpretations.

Source: Screenshot of the TERRAGEM app in Android emulated environment. Note: The map displays nearby agricultural supply stores to facilitate the purchase of recommended fertilizers and amendments.
Together, the described use cases represent the integral workflow of the TERRAGEM system, from user authentication and agricultural environment configuration, through to automatic interpretation and final report generation, demonstrating the efficiency and practical applicability of the system as an intelligent support tool for the sustainable management of agricultural soils.
The TERRAGEM mobile application, based on Gemini AI, demonstrated its ability to automatically interpret soil physicochemical parameters and generate personalized agronomic recommendations, as evidenced by the presented use cases. Agronomic experts from the Universidad Nacional de Cañete participated in the functional testing of the system, confirming that the interpretations generated by Gemini were comprehensible and appropriate for the four crop types included in the test cases. This result is consistent with findings reported by Awais et al.,19 who demonstrated that AI and machine learning algorithms — including neural networks, random forests, and SVM — present significant potential for the analysis of soil physicochemical parameters such as electrical conductivity, texture, and nutrient content, surpassing conventional statistical methods in accuracy. Similarly, Muthulakshmi et al.20 reported that ML models applied to soil fertility prediction achieve accuracy levels exceeding 91%, supporting the viability of integrating such models into agricultural decision-support tools.
TERRAGEM performed most consistently in soils with representative values of pH, organic matter, and phosphorus. According to Trontelj and Chambers,21 the ability of AI models to predict soil nutrient availability depends on the homogeneity of training data and adequate model calibration; in particular, these authors found that accuracy improves significantly when data come from local environments with homogeneous textures and micronutrient variations. Slight fluctuations were observed in soils with atypical characteristics, confirming the class imbalance effect documented by Miftahushudur et al.,22 who indicate that this phenomenon represents one of the main challenges in applying ML models to precision agriculture and soil management.
The graphical interface developed in Flutter enabled intuitive interaction between the user and the system, facilitating real-time interpretation of results. This approach aligns with the findings of Caffaro et al.,23 who demonstrated that perceived ease of use and perceived usefulness are the determining factors in farmers’ adoption of digital technologies, highlighting the importance of accessible interface design for increasing technology adoption in the agricultural sector. Furthermore, Tzachor et al.24 evidenced that large language models (LLMs) have transformative potential in agricultural extension services, generating comprehensible and contextualized technical advice for farmers, which supports TERRAGEM’s approach of using the Gemini AI API for generating personalized interpretations and recommendations.
The results are consistent with the research of Sinclair et al.,25 who evaluated mobile applications for soil property estimation and noted that current tools present significant limitations in terms of accuracy and integration with AI models, identifying the development of apps with greater automated interpretation capacity as a future direction. The use of AI in agriculture, as affirmed by Zhang et al.,26 contributes to optimizing the nutrient cycle, fertilizer application, and soil health, favoring more sustainable food production aligned with global food security objectives.
Study limitations include the small dataset size (29 records), the absence of formal quantitative validations, and the lack of testing under diverse edaphoclimatic conditions. For future work, it is recommended to expand the database with records from different regions of Peru, implement a formal metric evaluation protocol with real farmers, and incorporate IoT sensors for automatic capture of edaphic parameters in the field.
The present study demonstrated the technical feasibility of TERRAGEM, an AI-based mobile application supported by an MBaaS architecture, as a support tool for the automated interpretation of agricultural soil analyses. Functional tests conducted with 29 real soil analysis reports showed that the system correctly processes the entered parameters and generates comprehensible interpretations through the Gemini API, confirmed as appropriate by agronomic specialists from the Universidad Nacional de Cañete.
The integration of Flutter as the development framework, together with cloud services (Supabase, Gemini AI, and OpenWeatherMap), enabled the translation of AI algorithms into a practical, intuitive, and accessible environment. This implementation demonstrates the feasibility of linking large language models with mobile platforms, fostering the adoption of digital technologies in agriculture and contributing to sustainable data-driven decision-making.
Despite the positive results, limitations are acknowledged relating to the small dataset size (29 records), the absence of a formal quantitative metric evaluation, and the lack of validation under diverse edaphoclimatic conditions. To strengthen the system’s robustness, it is recommended to expand the database with samples from different regions, implement an evaluation protocol with real users, and integrate IoT sensors for the automatic capture of edaphic parameters in the field.
TERRAGEM represents a significant step toward the intelligent automation of soil analysis, consolidating itself as a technical support tool that enhances efficiency, precision, and sustainability in modern agricultural management, and marks a firm step toward the digitalization of the Peruvian agricultural sector.
Zenodo: TERRAGEM – Soil Physicochemical Analysis Dataset. https://doi.org/10.5281/zenodo.19103772.27
The project contains the following underlying data:
• terragem_dataset.csv (29 anonymized soil physicochemical analysis records used as functional test cases for the TERRAGEM system, including granulometry, electrical conductivity, pH, organic matter, macronutrients, exchangeable cations, micronutrients, and textural classification).
Data are available under the terms of the Creative Commons Attribution 4.0 International license (CC-BY 4.0).
Zenodo: TERRAGEM – Extended Data: Reference Parameters and System Requirements. https://doi.org/10.5281/zenodo.19423285.28
This project contains the following extended data:
• terragem_extended_data.xlsx (reference physicochemical parameter ranges by crop type — grape, avocado, corn, and sweet potato — established through consensus with agronomic specialists from the Universidad Nacional de Cañete; and functional and non-functional system requirements identified through expert interviews with agronomists from the Faculty of Agronomy of UNDC).
Data are available under the terms of the Creative Commons Zero “No rights reserved” data waiver (CC0 1.0 Public domain dedication).
Source code available from: https://github.com/CarolayDS/TERRAGEM_APP
Archived source code at time of publication: https://doi.org/10.5281/zenodo.19423347.29
License: https://opensource.org/license/MIT
Sincere thanks are extended to the Universidad Nacional de Cañete, to the faculty members and agronomic specialists from the Faculty of Agronomy who participated in the system validation, and to the collaborators who provided the soil analysis data used in this research.
| Views | Downloads | |
|---|---|---|
| F1000Research | - | - |
|
PubMed Central
Data from PMC are received and updated monthly.
|
- | - |
Provide sufficient details of any financial or non-financial competing interests to enable users to assess whether your comments might lead a reasonable person to question your impartiality. Consider the following examples, but note that this is not an exhaustive list:
Sign up for content alerts and receive a weekly or monthly email with all newly published articles
Already registered? Sign in
The email address should be the one you originally registered with F1000.
You registered with F1000 via Google, so we cannot reset your password.
To sign in, please click here.
If you still need help with your Google account password, please click here.
You registered with F1000 via Facebook, so we cannot reset your password.
To sign in, please click here.
If you still need help with your Facebook account password, please click here.
If your email address is registered with us, we will email you instructions to reset your password.
If you think you should have received this email but it has not arrived, please check your spam filters and/or contact for further assistance.
Comments on this article Comments (0)