- Overview
- Features
- Screens & Navigation
- Architecture
- Tech Stack
- Project Structure
- Installation & Setup
- Environment Configuration
- API Documentation
- Supabase Backend
- Development Guide
- Testing
- Deployment
- Contributing
- License
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.
To bridge the gap between traditional farming practices and modern technology, making agricultural intelligence accessible to every farmer.
- 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
- 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 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
- 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
- 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
- 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
- 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
- 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
- Splash Screen (
/splash) - App initialization and branding - Onboarding Screen (
/onboarding) - Feature introduction and walkthrough - Auth Screen (
/auth) - Login/Signup with email or Google - Profiling Screen (
/profiling) - Initial user and farm setup
The app uses a stateful shell with 4 main sections:
- 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
- Crop Selection Screen (
/crops) - Crop management and selection
- 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 Screen (
/market) - Market intelligence and prices
- 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
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)
- 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
- 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
- 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
- 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
- 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
- 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
- Build Runner: Code generation
- Envied: Environment variable management
- Flutter Launcher Icons: App icon generation
- Flutter Lints 5.0.0: Code quality and linting
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
- 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)
git clone https://github.com/TapanTalukdar004/Krishi-Setu.git
cd Krishi-Setu/krishi_setuflutter pub get# For Android
flutter run
# For iOS
flutter run -d ios
# For Web
flutter run -d chrome# Android APK
flutter build apk --release
# Android App Bundle
flutter build appbundle --release
# iOS
flutter build ios --release
# Web
flutter build web --releaseCreate 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- Copy the example environment file:
cp .env.example .env
- Update the values with your actual API keys
- Run code generation:
flutter pub run build_runner build --delete-conflicting-outputs
- Endpoint:
/ai-consultant - Method: POST
- Description: AI-powered agricultural consultant that uses location-specific context for weather and farming advice
- Features: Uses
location_namefrom 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" }
- 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 } }
- 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
- 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 } }
- Endpoint:
/calculate-yield - Method: POST
- Description: Predicts crop yield based on various factors
- Endpoint:
/generate-crop-timeline - Method: POST
- Description: Generates crop growth timeline based on crop type and region
- Endpoint:
/krishi-lens-proxy - Method: POST
- Description: Proxy for computer vision plant disease detection
- Endpoint:
/sync-global-market-data - Method: POST
- Description: Synchronizes global market data for commodities
- 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
The application uses PostgreSQL with the following main tables:
profiles: Extended user profiles with farm detailsauth.users: Supabase Auth managed users
farms: Farm details with geolocation (latitude, longitude, district, location_name)farm_crops: Crops grown on each farmcrop_cycles: Crop growth cycle tracking
soil_health_logs: Historical soil test resultssoil_diagnostic_reports: Detailed diagnostic reports
market_prices: Commodity price dataprice_alerts: User price alerts
weather_forecasts: Cached weather forecastsweather_alerts: Severe weather alerts
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
soil-reports: Soil health report PDFscrop-images: Plant disease imagesfarm-documents: Farm-related documents
- Follow Dart style guide (effective-dart)
- Use meaningful variable and function names
- Add comments for complex logic
- Write unit tests for business logic
- Create feature module in
lib/features/ - Add models in
lib/data/models/andlib/domain/models/ - Create repository in
lib/data/repositories/ - Add provider in
lib/providers/ - Create screens in
lib/presentation/[feature]/ - Update routing in
lib/core/router/app_router.dart
- Use
ConsumerWidgetfor simple state consumption - Use
ConsumerStatefulWidgetfor complex state - Keep providers focused and single-responsibility
- Use family providers for parameterized state
- Use named routes defined in
app_router.dart - Pass data via route parameters or provider state
- Use
GoRouterfor navigation operations - Implement proper route guards for protected routes
# Run all unit tests
flutter test
# Run tests for specific file
flutter test test/unit/soil_health_test.dart# Run widget tests
flutter test test/widget_test.dart# Run integration tests
flutter test integration_test/app_test.dart# Generate test coverage report
flutter test --coverage
genhtml coverage/lcov.info -o coverage/html- Update
android/app/build.gradle.ktswith proper signing config - Generate signed APK/AAB:
flutter build appbundle --release
- Upload to Google Play Console
- Update iOS bundle identifier in
ios/Runner/Info.plist - Configure code signing in Xcode
- Build and archive:
flutter build ios --release
- Upload to App Store Connect
- Build for production:
flutter build web --release
- Deploy
build/webto hosting service (Netlify, Vercel, Firebase)
- Apply database migrations:
supabase db push
- Deploy edge functions:
supabase functions deploy [function-name]
We welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch
git checkout -b feature/amazing-feature
- Commit your changes
git commit -m 'Add some amazing feature' - Push to the branch
git push origin feature/amazing-feature
- Open a Pull Request
- Follow the existing code style and architecture
- Write tests for new features
- Update documentation accordingly
- Ensure no breaking changes without migration plan
This project is licensed under the MIT License - see the LICENSE file for details.
- 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
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"
- 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
- 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
- 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