CROPGUARD
AI-Powered Agricultural Intelligence Platform
Overview
CropGuard is a fully deployed, comprehensive mobile application designed to revolutionize crop disease management for Sri Lankan farmers. By leveraging edge AI (TensorFlow Lite), the application provides instant, on-device disease detection and actionable treatment protocols without requiring an internet connection. The platform also serves as a complete farm management ecosystem, integrating real-time weather forecasting, community-driven outbreak tracking, and an automated offline-first synchronization engine to ensure seamless usability in remote agricultural zones.
The Problem It Solves
A major challenge in rural agriculture is ensuring data consistency and disease diagnosis in areas with zero internet connectivity. CropGuard solves this by implementing a flawless offline-first experience with a custom OutboxProcessor. It guarantees robust data syncing while running heavy image classification models on low-end devices without overheating or UI stutter.
Application Preview
Built With a Practical Stack
Frontend & UI
Backend & AI
Database & Local
Key Features & Core Functionalities
Real-Time Edge AI Diagnosis
Seamlessly uses the device's camera stream to run a highly optimized TensorFlow Lite model, instantly identifying plant diseases with high confidence scores and drawing animated bounding boxes.
Offline-First Synchronization
Farmers can log field data entirely offline. An intelligent background processor securely queues these actions and automatically syncs them with the cloud once a stable network is detected.
Trilingual Localization Engine
Fully localized in English, Sinhala, and Tamil. The system dynamically translates complex agricultural terms, disease names, and chemical treatments on the fly based on user preference.
Interactive Disease Radar & Maps
Utilizes GPS and interactive mapping to visualize regional disease outbreaks, allowing farmers to take preventive measures based on community-reported data.
Comprehensive Farm Analytics
Features an interactive dashboard with dynamic charts tracking farm health trends, crop yields, and task completion rates over time, alongside a searchable digital treatment catalogue.
Engineering Complexities & Challenges
Architecting a Flawless Offline-First Experience
A major challenge was ensuring data consistency in rural areas with zero internet. This was solved by implementing a custom OutboxProcessor paired with Drift (SQLite). Every user action is intercepted and written to a local queue. A background isolate listens to network state changes via connectivity_plus. Upon reconnection, it executes a robust sync algorithm with exponential backoff and retry mechanisms.
Optimizing Edge AI for Low-End Devices
Running a heavy image classification model on older smartphones required significant optimization. The engineering solution involved binding the native camera byte stream directly to the tflite_flutter interpreter. By utilizing custom isolates for frame processing and strategically managing memory allocation, the app achieves real-time inference (60fps) without overheating the device.
High-Performance Custom Rendering
The design required complex visual elements, including dynamic blurs, gradients, and animated AI reticles. Implementing these using standard Flutter widgets caused frame drops. This was overcome by writing custom CustomPainter classes for the camera overlays and heavily optimizing the BackdropFilter implementations by utilizing const constructors and minimizing shader repaints.
The Architecture
- Feature-Driven Clean Architecture for long-term maintainability
- Reactive State Management decoupled from UI layers
- Type-Safe Routing with secure parameter passing
- Repository & Queue Patterns abstracting the remote and local databases