Skip to content

amankrmj09/farmers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

54 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Farmers - Smart Greenhouse Management System

Empowering farmers with IoT-driven precision agriculture for optimized greenhouse management


πŸ“– Table of Contents


🌱 Overview

Farmers is a comprehensive IoT-enabled mobile application designed to revolutionize greenhouse management for modern agriculture. Built with Flutter and powered by AWS services, this application enables farmers to:

  • Monitor multiple greenhouses in real-time
  • Manage IoT sensor devices for environmental tracking
  • Control automated systems (irrigation, ventilation, lighting)
  • Receive AI-powered insights and recommendations
  • Track crop growth stages and optimize farming practices

The app connects to IoT devices through AWS IoT Core using secure MQTT protocol, providing real-time data synchronization and remote device control capabilities.


✨ Key Features

🏑 Multi-Greenhouse Management

  • Create and manage multiple greenhouses
  • Track greenhouse location, crop type, and planting dates
  • View comprehensive greenhouse analytics and insights
  • Configure automation settings per greenhouse

πŸ“‘ IoT Device Integration

  • Connect multiple IoT devices to each greenhouse
  • Real-time sensor data monitoring:
    • Temperature (Β°C)
    • Humidity (%)
    • Soil Moisture (%)
    • pH Levels
    • Nitrogen (N) levels
  • Device status tracking (online/offline, battery level, last seen)
  • Secure device authentication using AWS IoT certificates

πŸ”§ Automated Control Systems

  • Remote device control via MQTT
  • Automated irrigation based on soil moisture
  • Climate control (ventilation, temperature regulation)
  • Configurable target parameters for each greenhouse
  • Real-time command execution and status updates

πŸ€– AI-Powered Assistance

  • AWS Lex Integration: Conversational AI chatbot for farming queries
  • Perplexity AI Integration: Advanced fertilizer recommendations based on:
    • Current crop stage
    • Sensor readings (temperature, humidity, soil conditions)
    • Days since planting
    • VPD (Vapor Pressure Deficit) calculations
    • Evapotranspiration (ETβ‚€) metrics

πŸ“Š Advanced Analytics

  • Real-time sensor data visualization with charts
  • Historical data analysis and trends
  • Crop stage tracking with growth insights
  • Environmental condition monitoring
  • Fertilizer recommendations tailored to crop needs

🌀️ Weather Integration

  • Real-time weather data using WeatherAPI
  • 7-day weather forecasts
  • Air quality index (AQI) monitoring
  • Weather alerts and notifications

πŸ‘€ User Management

  • Secure authentication with AWS Cognito
  • User profile management with cloud storage
  • Multi-device synchronization
  • Custom notification preferences

πŸ—οΈ Architecture

The application follows Clean Architecture principles with clear separation of concerns:

β”œβ”€β”€ Domain Layer (Business Logic)
β”‚   β”œβ”€β”€ Entities (Core business models)
β”‚   β”œβ”€β”€ Repositories (Abstract interfaces)
β”‚   └── Use Cases (Business rules)
β”‚
β”œβ”€β”€ Data Layer (Data Management)
β”‚   β”œβ”€β”€ Data Sources (Remote/Local data sources)
β”‚   β”œβ”€β”€ Models (Data transfer objects)
β”‚   β”œβ”€β”€ Repositories (Implementation)
β”‚   └── Services (Business services)
β”‚
β”œβ”€β”€ Presentation Layer (UI)
β”‚   β”œβ”€β”€ BLoC (State management)
β”‚   β”œβ”€β”€ Pages (Screen widgets)
β”‚   └── Widgets (Reusable UI components)
β”‚
└── Config Layer
    β”œβ”€β”€ Dependency Injection (GetIt)
    β”œβ”€β”€ Routing (GoRouter)
    └── Theme

State Management: BLoC (Business Logic Component) pattern Dependency Injection: GetIt for service locator pattern


πŸ› οΈ Technical Stack

Frontend

  • Framework: Flutter 3.24.4 (Stable)
  • Language: Dart 3.5.4
  • UI Components: Material Design 3
  • State Management: flutter_bloc 9.1.1
  • Navigation: go_router 16.2.5
  • Local Storage: Isar 3.1.0

Backend & Cloud Services

  • Authentication: AWS Amplify Auth (Cognito)
  • Database: AWS Amplify DataStore (DynamoDB)
  • API: AWS Amplify API (AppSync GraphQL)
  • IoT: AWS IoT Core with MQTT
  • Storage: AWS S3 (via Amplify Storage)
  • AI Services:
    • AWS Lex (Conversational AI)
    • Perplexity AI (Agricultural recommendations)

Communication Protocols

  • MQTT: Secure IoT device communication (mqtt_client 10.11.1)
  • REST API: HTTP requests (dio 5.9.0)
  • GraphQL: AWS AppSync for data synchronization
  • WebSocket: Real-time data streaming

Build Tools

  • Android: Gradle 8.x with Kotlin DSL
  • iOS: CocoaPods (native dependencies)
  • Amplify: AWS Amplify Gen 2 with TypeScript

☁ AWS Services Integration

1. AWS IoT Core

  • Secure MQTT broker for device-to-cloud communication
  • Device certificate management and authentication
  • Topic-based pub/sub messaging
  • Real-time sensor data streaming

Implementation Details:

- Endpoint: AWS IoT Core endpoint (region: ap-southeast-1)
- Protocol: MQTT over TLS (port 8883)
- Authentication: X.509 certificates per device
- Topics: Custom topics based on device keywords

2. AWS Cognito

  • User authentication and authorization
  • Email-based sign-up and sign-in
  • Password reset and account recovery
  • JWT token management for API access

3. AWS AppSync (GraphQL)

  • Real-time data synchronization
  • Offline-first capabilities
  • Automatic conflict resolution
  • Fine-grained authorization rules

Data Models:

  • UserProfile: User account and preferences
  • Greenhouse: Greenhouse configurations
  • Device: IoT device metadata and certificates
  • SensorReading: Time-series sensor data

4. Amazon DynamoDB

  • NoSQL database for structured data
  • Global Secondary Indexes (GSI) for efficient queries
  • Time-series data storage for sensor readings
  • Automatic scaling and high availability

5. AWS Lex

  • Conversational AI for farming assistance
  • Natural language understanding (NLU)
  • Context-aware responses
  • Integration with greenhouse data for personalized advice

6. Amazon S3

  • Profile image storage
  • Document uploads
  • Backup and archival storage

πŸ“ Project Structure

lib/
β”œβ”€β”€ config/                          # App configuration, DI, routing, theme
β”œβ”€β”€ core/                            # Core utilities, error handling, base classes
β”œβ”€β”€ data/                            # Data layer implementation
β”‚   β”œβ”€β”€ datasources/                 # API, AWS services, IoT communication
β”‚   β”œβ”€β”€ models/                      # Data models
β”‚   β”œβ”€β”€ repositories/                # Repository implementations
β”‚   └── services/                    # Business services
β”œβ”€β”€ domain/                          # Business logic layer
β”‚   β”œβ”€β”€ entities/                    # Core business entities
β”‚   β”œβ”€β”€ repositories/                # Repository interfaces
β”‚   └── usecases/                    # Business use cases
β”œβ”€β”€ presentation/                    # UI layer
β”‚   β”œβ”€β”€ blocs/                       # State management (BLoC)
β”‚   β”œβ”€β”€ pages/                       # Screen widgets
β”‚   └── widgets/                     # Reusable UI components
β”œβ”€β”€ amplify_outputs.dart             # Auto-generated Amplify config
└── main.dart                        # App entry point

amplify/                             # AWS Amplify backend configuration
β”œβ”€β”€ auth/                            # Cognito auth setup
β”œβ”€β”€ data/                            # AppSync GraphQL schema
└── backend.ts                       # Backend definition


πŸ“± IoT Device Integration

Device Requirements

IoT devices must support:

  • MQTT protocol over TLS
  • X.509 certificate authentication
  • JSON payload format
  • Sensor data publishing

Device Registration

  1. Add Device in App

    • Navigate to greenhouse detail page
    • Tap "Add Device" button
    • Enter device name and pub/sub keyword
    • Device certificates are automatically generated
  2. Configure Device Certificates

    • Device receives CA certificate, device certificate, and private key
    • Store certificates securely on the device
    • Use certificates for AWS IoT Core connection
  3. MQTT Topics

    Publish (Device β†’ Cloud): <pubsubKeyword>/sensor_data
    Subscribe (Cloud β†’ Device): <pubsubKeyword>/commands
    

Sensor Data Format

Devices should publish JSON payloads:

{
  "deviceId": "device-uuid",
  "greenhouseId": "greenhouse-uuid",
  "temperature": 25.5,
  "humidity": 65.0,
  "soilMoisture": 45.0,
  "phLevel": 6.8,
  "nitrogen": 120.0,
  "timestamp": "2025-12-06T10:30:00Z"
}

Command Format

App sends control commands:

{
  "command": "irrigate",
  "duration": 120,
  "timestamp": "2025-12-06T10:30:00Z"
}

πŸ“– Usage

1. Authentication

  • Sign up with email and password
  • Verify email with OTP
  • Sign in to access dashboard

2. Create Greenhouse

  • Tap "Add Greenhouse" from dashboard
  • Fill in greenhouse details (name, location, crop type)
  • Set automation preferences
  • Configure target environmental parameters

3. Add IoT Devices

  • Open greenhouse detail page
  • Add device with unique pub/sub keyword
  • Device certificates are generated automatically
  • Configure device with certificates

4. Monitor Real-Time Data

  • View live sensor readings on greenhouse page
  • Switch between Overview, Analytics, and Insights tabs
  • Monitor device status (online/offline)
  • View historical data with charts

5. Control Devices

  • Send manual commands to devices
  • Enable/disable automation rules
  • Configure irrigation schedules
  • Adjust climate control settings

6. AI Assistance

  • Open chat page for AI farming advisor
  • Ask questions about crop management
  • Get personalized recommendations
  • View fertilizer suggestions based on current data

7. Weather Monitoring

  • Check current weather conditions
  • View 7-day forecast
  • Monitor air quality
  • Plan farming activities accordingly

πŸ§ͺ Key Dependencies

Package Version Purpose
flutter_bloc ^9.1.1 State management
get_it ^8.2.0 Dependency injection
go_router ^16.2.5 Navigation
amplify_flutter ^2.7.0 AWS Amplify SDK
mqtt_client ^10.11.1 MQTT communication
dio ^5.9.0 HTTP client
isar ^3.1.0 Local database
fl_chart ^1.1.1 Data visualization
perplexity_flutter ^2.0.4 Perplexity AI integration
equatable ^2.0.7 Value equality
dartz ^0.10.1 Functional programming

πŸ“Έ Screenshots

Authentication

Sign In Screen OTP Screen

Dashboard

Dashboard Overview Dashboard Analytics

Greenhouse Management

Add Greenhouse Greenhouse Details Greenhouse Controls

IoT Device Integration

Add Device Device Configuration Device Dashboard

AI Chatbot

AI Chatbot Interface

Weather Monitoring

Weather Overview Weather Forecast

User Profile

User Profile Edit Profile


πŸ“„ License

This project is licensed under the Creative Commons Attribution-NonCommercial 4.0 International License.

  • βœ… You can use, copy, and modify the code for non-commercial purposes
  • βœ… You must give appropriate credit
  • ❌ You cannot use this project for commercial purposes without permission

For full license details, see LICENSE.md or visit: https://creativecommons.org/licenses/by-nc/4.0/


Made with ❀️ for farmers worldwide

Version 1.0.0 | December 2025

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages