Skip to content

TapanTalukdar004/Krishi-Setu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Krishi-Setu 🌾 - AI-Powered Agricultural Intelligence Platform

Flutter Dart Riverpod Supabase License: MIT

πŸ“‹ Table of Contents

🌟 Overview

Krishi-Setu (meaning "Farmer's Bridge" in Hindi) is a comprehensive agricultural intelligence platform built with Flutter that empowers farmers with AI-driven insights. The application provides real-time disease detection, soil health analysis, market intelligence, weather forecasting, and yield prediction to enhance agricultural productivity and decision-making.

🎯 Vision

To bridge the gap between traditional farming practices and modern technology, making agricultural intelligence accessible to every farmer.

πŸš€ Key Value Propositions

  • Real-time Disease Detection: Instant plant disease identification using computer vision
  • Soil Health Analytics: Comprehensive soil diagnostics with actionable recommendations
  • Market Intelligence: Real-time commodity prices and trend analysis
  • Hyperlocal Weather: Accurate weather forecasts for specific farm locations with reverse geocoding
  • Yield Prediction: ML-based yield forecasting for better planning
  • Crop Management: Complete crop cycle tracking and timeline management
  • AI Agricultural Consultant: Context-aware AI assistant with hyper-local weather intelligence

✨ Features

🏠 Dashboard & Navigation

  • Interactive Dashboard: Personalized overview with weather, soil health, market trends, and crop status
  • Bottom Navigation: Four main sections - Home, Crops, Health, Market
  • App Shell: Consistent navigation structure with stateful shell routing
  • Theme Support: Light/dark mode with dynamic theme switching

🌱 Crop Management

  • Crop Selection: Multi-crop support with detailed information
  • Crop Timeline: Visual crop cycle tracking with growth stages
  • Yield Prediction: Machine learning-based yield forecasting
  • Crop Rotation Suggestions: AI-powered crop rotation recommendations

🩺 Health & Diagnostics

  • Soil Health Analysis: Comprehensive soil diagnostics with NPK values, pH, organic matter
  • Disease Detection: Real-time plant disease identification using camera
  • Krishi Lens: Custom computer vision module for plant scanning
  • Health Reports: Detailed diagnostic reports with recommendations

πŸ“Š Market Intelligence

  • Real-time Prices: Live commodity prices from agricultural markets
  • Price Trends: Historical price analysis and trend visualization
  • Market Alerts: Price change notifications and alerts
  • Demand Forecasting: Market demand predictions

🌀️ Weather Services

  • Hyperlocal Forecast: Weather predictions for specific farm locations using Open-Meteo API
  • Reverse Geocoding: Converts GPS coordinates to human-readable location names (village/town/city)
  • Rainfall Prediction: Precipitation forecasts for irrigation planning
  • Weather Alerts: Severe weather warnings and notifications
  • Historical Data: Past weather patterns analysis

πŸ€– AI & Recommendations

  • Setu AI Assistant: AI-powered agricultural consultant with hyper-local context
  • Personalized Recommendations: Context-aware farming recommendations using location-specific data
  • Deep Scan Analysis: Advanced analysis using multiple data sources
  • Learning System: AI that learns from user interactions and outcomes
  • Real-time Weather Intelligence: AI uses location names for precise weather queries

πŸ‘€ User Management

  • Authentication: Email/Google sign-in with Supabase Auth
  • User Profiles: Complete farmer profiles with farm details
  • Farm Management: Multiple farm support with geolocation
  • Data Synchronization: Offline-first with PowerSync real-time sync

πŸ“± Screens & Navigation

Authentication Flow

  1. Splash Screen (/splash) - App initialization and branding
  2. Onboarding Screen (/onboarding) - Feature introduction and walkthrough
  3. Auth Screen (/auth) - Login/Signup with email or Google
  4. Profiling Screen (/profiling) - Initial user and farm setup

Main App Navigation (Shell)

The app uses a stateful shell with 4 main sections:

🏠 Home/Dashboard Branch

  • Dashboard Screen (/dashboard) - Main overview with widgets
  • Weather Screen (/weather) - Detailed weather forecasts with hyper-local location display
  • Crop Timeline Screen (/crop-timeline) - Visual crop cycle tracking
  • Yield Prediction Screen (/yield-prediction) - Yield forecasting
  • Crop Selection Screen (/crop-selection) - Crop management

🌱 Crops Branch

  • Crop Selection Screen (/crops) - Crop management and selection

🩺 Health Branch

  • Soil Health Screen (/health) - Soil diagnostics and analysis
  • Disease Landing Screen (/scan-crop) - Disease detection interface
  • Lens Screen (/camera-viewfinder) - Camera-based plant scanning

πŸ“Š Market Branch

  • Market Screen (/market) - Market intelligence and prices

Additional Screens

  • Profile Screen (/profile) - User profile and settings
  • Farm Update Screen (/farm-update) - Farm details management
  • AI Recommendations Screen (/recommendations) - AI-powered farming advice
  • Creators Screen (/creators) - Team and contributors information

πŸ—οΈ Architecture

Clean Architecture Pattern

The app follows a modified Clean Architecture with clear separation of concerns:

Presentation Layer (UI)
β”œβ”€β”€ Screens
β”œβ”€β”€ Widgets
└── Providers (Riverpod)

Domain Layer (Business Logic)
β”œβ”€β”€ Models
β”œβ”€β”€ Use Cases
└── Interfaces

Data Layer (Data Sources)
β”œβ”€β”€ Repositories
β”œβ”€β”€ Local (SQLite)
└── Remote (Supabase, APIs)

State Management

  • Riverpod 3.3.1: Modern, reactive state management
  • Provider Scope: Global provider scope at root level
  • State Notifiers: For complex state management
  • Async Value: Handling loading, error, and data states

Navigation

  • Go Router: Declarative routing with nested navigation
  • Stateful Shell: Bottom navigation with preserved state
  • Route Guards: Authentication and profile completion guards
  • Deep Linking: Support for deep links and URL navigation

πŸ› οΈ Tech Stack

Frontend

  • Flutter 3.9.2: Cross-platform UI framework
  • Dart 3.9.2: Programming language
  • Riverpod 3.3.1: State management
  • Go Router 17.1.0: Navigation and routing

Backend & Database

  • Supabase: Backend-as-a-Service (PostgreSQL, Auth, Storage, Edge Functions)
  • PowerSync 1.18.0: Real-time data synchronization
  • SQLite Async 0.13.1: Local database operations
  • PostgreSQL: Primary database with Row Level Security

UI & Design

  • Material Design 3: Modern design system
  • Google Fonts: Custom typography
  • Lottie 3.3.2: Animations and illustrations
  • Flutter Map 8.2.2: Interactive maps
  • FL Chart 0.70.2: Data visualization

APIs & Services

  • Dio 5.9.2: HTTP client for API calls
  • Camera 0.12.0+1: Camera access for disease detection
  • Image Picker 1.2.1: Image selection and capture
  • Google Sign-In 6.2.4: Authentication
  • URL Launcher 6.3.0: External link handling
  • Open-Meteo API: Weather forecasting service
  • OpenStreetMap Nominatim API: Reverse geocoding service
  • Tavily API: Real-time agricultural search and intelligence
  • OpenRouter API: LLM-powered AI recommendations

Development Tools

  • Build Runner: Code generation
  • Envied: Environment variable management
  • Flutter Launcher Icons: App icon generation
  • Flutter Lints 5.0.0: Code quality and linting

πŸ“ Project Structure

krishi_setu/
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ core/                    # Core application infrastructure
β”‚   β”‚   β”œβ”€β”€ router/             # Navigation and routing (app_router.dart)
β”‚   β”‚   β”œβ”€β”€ theme/              # App themes and design tokens
β”‚   β”‚   β”œβ”€β”€ utils/              # Utilities and helpers
β”‚   β”‚   └── widgets/            # Reusable widgets (app_shell.dart)
β”‚   β”‚
β”‚   β”œβ”€β”€ data/                   # Data layer
β”‚   β”‚   β”œβ”€β”€ models/             # Data models (DTOs)
β”‚   β”‚   └── repositories/       # Repository implementations
β”‚   β”‚
β”‚   β”œβ”€β”€ domain/                 # Business logic layer
β”‚   β”‚   └── models/             # Domain models
β”‚   β”‚
β”‚   β”œβ”€β”€ features/               # Feature modules
β”‚   β”‚   └── krishi_lens/        # Computer vision feature
β”‚   β”‚       β”œβ”€β”€ models/         # Vision models
β”‚   β”‚       β”œβ”€β”€ presentation/   # UI screens
β”‚   β”‚       β”œβ”€β”€ providers/      # State management
β”‚   β”‚       β”œβ”€β”€ services/       # Business logic
β”‚   β”‚       └── utils/          # Utilities
β”‚   β”‚
β”‚   β”œβ”€β”€ presentation/           # UI layer
β”‚   β”‚   β”œβ”€β”€ ai_recommendations/ # AI recommendations
β”‚   β”‚   β”œβ”€β”€ auth/              # Authentication screens
β”‚   β”‚   β”œβ”€β”€ crops/             # Crop management
β”‚   β”‚   β”œβ”€β”€ dashboard/         # Dashboard and home
β”‚   β”‚   β”œβ”€β”€ health/            # Health and diagnostics
β”‚   β”‚   β”œβ”€β”€ market/            # Market intelligence
β”‚   β”‚   β”œβ”€β”€ onboarding/        # Onboarding flow
β”‚   β”‚   β”œβ”€β”€ profile/           # User profile
β”‚   β”‚   β”œβ”€β”€ profiling/         # Initial setup
β”‚   β”‚   β”œβ”€β”€ splash/            # Splash screen
β”‚   β”‚   β”œβ”€β”€ weather/           # Weather forecasts
β”‚   β”‚   └── yield/             # Yield prediction
β”‚   β”‚
β”‚   β”œβ”€β”€ providers/             # Riverpod providers
β”‚   β”‚   β”œβ”€β”€ location_provider.dart      # Reverse geocoding and location display
β”‚   β”‚   β”œβ”€β”€ market_intelligence_provider.dart
β”‚   β”‚   β”œβ”€β”€ onboarding_provider.dart
β”‚   β”‚   β”œβ”€β”€ profile_completion_provider.dart
β”‚   β”‚   β”œβ”€β”€ recommendation_provider.dart
β”‚   β”‚   β”œβ”€β”€ setu_ai_provider.dart
β”‚   β”‚   β”œβ”€β”€ soil_diagnostic_provider.dart
β”‚   β”‚   β”œβ”€β”€ theme_provider.dart
β”‚   β”‚   β”œβ”€β”€ user_data_provider.dart
β”‚   β”‚   └── weather_provider.dart
β”‚   β”‚
β”‚   └── main.dart              # Application entry point
β”‚
β”œβ”€β”€ assets/                    # Static assets
β”‚   β”œβ”€β”€ images/               # Images and icons
β”‚   β”‚   β”œβ”€β”€ onboarding/       # Onboarding illustrations
β”‚   β”‚   └── app_icon.jpg     # Application icon
β”‚   └── lotties/             # Lottie animations
β”‚       β”œβ”€β”€ Scan.json        # Scanning animation
β”‚       └── plantscan.json   # Plant scan animation
β”‚
β”œβ”€β”€ supabase/                 # Backend configuration
β”‚   β”œβ”€β”€ functions/           # Edge Functions
β”‚   β”‚   β”œβ”€β”€ ai-consultant/   # AI consultation service with hyper-local context
β”‚   β”‚   β”œβ”€β”€ analyze-soil-health/ # Soil analysis
β”‚   β”‚   β”œβ”€β”€ calculate-yield/ # Yield calculation
β”‚   β”‚   β”œβ”€β”€ generate-crop-timeline/ # Crop timeline
β”‚   β”‚   β”œβ”€β”€ get-weather/     # Weather data from Open-Meteo API
β”‚   β”‚   β”œβ”€β”€ krishi-lens-proxy/ # Vision API proxy
β”‚   β”‚   β”œβ”€β”€ krishi-recommendations/ # Recommendations
β”‚   β”‚   β”œβ”€β”€ reverse-geocode/ # Reverse geocoding service (new)
β”‚   β”‚   └── sync-global-market-data/ # Market data synchronization
β”‚   β”œβ”€β”€ migrations/          # Database migrations
β”‚   └── config.toml          # Supabase configuration
β”‚
β”œβ”€β”€ android/                  # Android-specific files
β”œβ”€β”€ ios/                     # iOS-specific files
β”œβ”€β”€ web/                     # Web-specific files
β”œβ”€β”€ windows/                 # Windows-specific files
β”œβ”€β”€ linux/                   # Linux-specific files
β”œβ”€β”€ macos/                   # macOS-specific files
β”‚
β”œβ”€β”€ pubspec.yaml             # Dependencies and metadata
β”œβ”€β”€ pubspec.lock             # Locked dependencies
β”œβ”€β”€ analysis_options.yaml    # Static analysis rules
└── README.md                # Project documentation

πŸš€ Installation & Setup

Prerequisites

  • Flutter SDK 3.9.2 or later
  • Dart SDK 3.9.2 or later
  • Android Studio / VS Code with Flutter extension
  • Git
  • Supabase CLI (for backend deployment)

Clone the Repository

git clone https://github.com/TapanTalukdar004/Krishi-Setu.git
cd Krishi-Setu/krishi_setu

Install Dependencies

flutter pub get

Run the Application

# For Android
flutter run

# For iOS
flutter run -d ios

# For Web
flutter run -d chrome

Build for Release

# Android APK
flutter build apk --release

# Android App Bundle
flutter build appbundle --release

# iOS
flutter build ios --release

# Web
flutter build web --release

πŸ”§ Environment Configuration

Required Environment Variables

Create a .env file in the project root with the following variables:

# Supabase Configuration
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_ANON_KEY=your-anon-key

# API Keys (Optional for development)
OPENROUTER_API_KEY=your-openrouter-api-key
TAVILY_API_KEY=your-tavily-api-key

Environment Setup

  1. Copy the example environment file:
    cp .env.example .env
  2. Update the values with your actual API keys
  3. Run code generation:
    flutter pub run build_runner build --delete-conflicting-outputs

πŸ“‘ API Documentation

Supabase Edge Functions

1. AI Consultant with Hyper-local Context

  • Endpoint: /ai-consultant
  • Method: POST
  • Description: AI-powered agricultural consultant that uses location-specific context for weather and farming advice
  • Features: Uses location_name from farm data for precise weather queries, combines with district for hyper-local context
  • Request Body:
    {
      "message": "What's the weather like today?",
      "farm_id": "farm-uuid"
    }

2. Reverse Geocoding Service

  • Endpoint: /reverse-geocode
  • Method: POST
  • Description: Converts latitude/longitude coordinates to human-readable location names using OpenStreetMap Nominatim API
  • Request Body:
    {
      "lat": 26.1445,
      "lon": 91.7362
    }
  • Response:
    {
      "location_name": "Guwahati",
      "coordinates": { "lat": 26.1445, "lon": 91.7362 }
    }

3. Weather Data with Hyper-local Display

  • Endpoint: /get-weather
  • Method: POST
  • Description: Fetches hyperlocal weather data from Open-Meteo API
  • Parameters: lat, lon, days (optional)
  • Response: Includes weather forecasts, temperature, precipitation, and farming recommendations

4. Soil Health Analysis

  • Endpoint: /analyze-soil-health
  • Method: POST
  • Description: Analyzes soil samples and provides health recommendations
  • Request Body:
    {
      "crop": "rice",
      "district": "Kamrup",
      "soil_data": {
        "ph": 6.5,
        "nitrogen": 25,
        "phosphorus": 15,
        "potassium": 150,
        "organic_matter": 2.5
      }
    }

5. Yield Calculation

  • Endpoint: /calculate-yield
  • Method: POST
  • Description: Predicts crop yield based on various factors

6. Crop Timeline Generation

  • Endpoint: /generate-crop-timeline
  • Method: POST
  • Description: Generates crop growth timeline based on crop type and region

7. Krishi Lens Proxy

  • Endpoint: /krishi-lens-proxy
  • Method: POST
  • Description: Proxy for computer vision plant disease detection

8. Market Data Sync

  • Endpoint: /sync-global-market-data
  • Method: POST
  • Description: Synchronizes global market data for commodities

External APIs Used

  • Open-Meteo API: Weather data and forecasts (replaces OpenWeather)
  • OpenStreetMap Nominatim API: Reverse geocoding service
  • Tavily API: Agricultural research and real-time search
  • OpenRouter API: LLM-powered AI recommendations
  • Government APIs: Market prices and agricultural data

πŸ—„οΈ Supabase Backend

Database Schema

The application uses PostgreSQL with the following main tables:

Users & Authentication

  • profiles: Extended user profiles with farm details
  • auth.users: Supabase Auth managed users

Farm Management

  • farms: Farm details with geolocation (latitude, longitude, district, location_name)
  • farm_crops: Crops grown on each farm
  • crop_cycles: Crop growth cycle tracking

Soil Health

  • soil_health_logs: Historical soil test results
  • soil_diagnostic_reports: Detailed diagnostic reports

Market Data

  • market_prices: Commodity price data
  • price_alerts: User price alerts

Weather Data

  • weather_forecasts: Cached weather forecasts
  • weather_alerts: Severe weather alerts

Row Level Security (RLS)

All tables have RLS policies enabled for data security:

  • Users can only access their own data
  • Public read access for market data
  • Admin-only access for system tables

Storage

  • soil-reports: Soil health report PDFs
  • crop-images: Plant disease images
  • farm-documents: Farm-related documents

πŸ’» Development Guide

Code Style & Conventions

  • Follow Dart style guide (effective-dart)
  • Use meaningful variable and function names
  • Add comments for complex logic
  • Write unit tests for business logic

Adding a New Feature

  1. Create feature module in lib/features/
  2. Add models in lib/data/models/ and lib/domain/models/
  3. Create repository in lib/data/repositories/
  4. Add provider in lib/providers/
  5. Create screens in lib/presentation/[feature]/
  6. Update routing in lib/core/router/app_router.dart

State Management Best Practices

  • Use ConsumerWidget for simple state consumption
  • Use ConsumerStatefulWidget for complex state
  • Keep providers focused and single-responsibility
  • Use family providers for parameterized state

Navigation Guidelines

  • Use named routes defined in app_router.dart
  • Pass data via route parameters or provider state
  • Use GoRouter for navigation operations
  • Implement proper route guards for protected routes

πŸ§ͺ Testing

Unit Tests

# Run all unit tests
flutter test

# Run tests for specific file
flutter test test/unit/soil_health_test.dart

Widget Tests

# Run widget tests
flutter test test/widget_test.dart

Integration Tests

# Run integration tests
flutter test integration_test/app_test.dart

Test Coverage

# Generate test coverage report
flutter test --coverage
genhtml coverage/lcov.info -o coverage/html

🚒 Deployment

Android Deployment

  1. Update android/app/build.gradle.kts with proper signing config
  2. Generate signed APK/AAB:
    flutter build appbundle --release
  3. Upload to Google Play Console

iOS Deployment

  1. Update iOS bundle identifier in ios/Runner/Info.plist
  2. Configure code signing in Xcode
  3. Build and archive:
    flutter build ios --release
  4. Upload to App Store Connect

Web Deployment

  1. Build for production:
    flutter build web --release
  2. Deploy build/web to hosting service (Netlify, Vercel, Firebase)

Supabase Deployment

  1. Apply database migrations:
    supabase db push
  2. Deploy edge functions:
    supabase functions deploy [function-name]

🀝 Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch
    git checkout -b feature/amazing-feature
  3. Commit your changes
    git commit -m 'Add some amazing feature'
  4. Push to the branch
    git push origin feature/amazing-feature
  5. Open a Pull Request

Contribution Guidelines

  • Follow the existing code style and architecture
  • Write tests for new features
  • Update documentation accordingly
  • Ensure no breaking changes without migration plan

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Flutter Team for the amazing cross-platform framework
  • Supabase for the powerful backend platform
  • Riverpod for excellent state management
  • OpenStreetMap for free geocoding services
  • Open-Meteo for free weather API
  • Open Source Community for various packages and tools

πŸ“ž Support

For support, feature requests, or bug reports:

  • Open an issue on GitHub Issues
  • Email: [Your Contact Email]
  • Join our community: [Community Link]

Krishi-Setu - Bridging Farmers with Technology for Sustainable Agriculture πŸŒΎπŸš€

"Empowering every farmer with AI-driven agricultural intelligence and hyper-local weather insights"


πŸ”„ Recent Updates (April 2026)

Enhanced Location Intelligence

  • Reverse Geocoding: Added new Edge Function to convert GPS coordinates to human-readable location names
  • Hyper-local Weather Display: Weather screen now shows area name + district (e.g., "Guwahati, Kamrup, IN")
  • AI Consultant Improvements: AI now uses specific location names for weather queries, not just district-level data

Technical Improvements

  • CORS Configuration: Fixed CORS issues in Edge Functions for proper browser compatibility
  • Location Providers: Created new Riverpod providers for location name fetching and display
  • Weather API Integration: Enhanced Open-Meteo integration with better error handling

User Experience

  • More Precise Weather Data: Farmers get weather information specific to their exact location
  • Better AI Responses: AI assistant provides more relevant advice based on hyper-local context
  • Improved UI: Weather page displays both area name and district for better location context

About

Krishi Setu: A premium AI-powered agriculture platform for hyper-local farming intelligence. Features real-time plant disease detection, soil diagnostics, market intelligence with web-grounded commodity trends, and precision weather forecasting using reverse geocoding for village-level accuracy. Bridging the gap between farmers and technology.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors