An AI-powered mobile application designed to revolutionize farming practices for Ethiopian farmers
Features β’ Installation β’ Architecture β’ API Documentation β’ Contributing
- Overview
- Features
- Technology Stack
- Architecture
- Installation & Setup
- Configuration
- Project Structure
- Core Modules
- API Documentation
- Database Schema
- Localization
- Security
- Testing
- Deployment
- Troubleshooting
- Roadmap
- Contributing
- License
Smart Gebere (α΅ααα΅ αα α¬ - "Smart Farmer" in Amharic) is a comprehensive agricultural assistant application built with Flutter. It leverages artificial intelligence, GPS technology, and real-time weather data to provide Ethiopian farmers with personalized crop recommendations, disease detection, yield predictions, and farm management tools.
To empower Ethiopian farmers with cutting-edge technology, enabling data-driven decisions that increase crop yields, reduce losses, and promote sustainable farming practices.
- π― Personalized Recommendations: AI-powered crop suggestions based on location, climate, and soil conditions
- π¬ Disease Detection: Image-based plant disease diagnosis using computer vision
- π Smart Planning: Week-by-week farming guides tailored to specific crops and fields
- π Yield Prediction: AI-powered harvest forecasting and market value estimation
- πΊοΈ Field Mapping: GPS-based land measurement and management
- π Multi-language Support: Available in English, Amharic (α ααα), and Afaan Oromo
The central hub of the application featuring:
| Component | Description |
|---|---|
| Weather Widget | Real-time weather data for the farmer's location |
| Quick Actions | One-tap access to key features |
| Created Tasks | Slideshow of active crop plans with progress |
| Expected Events | Upcoming farming tasks and deadlines |
| Navigation Drawer | Access to all app features |
Location Data β Weather API β Elevation API β Gemini AI β Personalized Crop List
How it works:
- Fetches current GPS coordinates
- Retrieves elevation data from Open-Elevation API
- Gets real-time weather from OpenWeather API
- Optionally includes user's mapped field data (size, soil type)
- Sends comprehensive data to Gemini AI
- Returns ranked crop suggestions with suitability scores
Output includes:
- Crop name and description
- Suitability percentage (0-100%)
- Climate suitability analysis
- Soil requirements
- Water needs assessment
- Elevation factor analysis
- Seasonal growth patterns
An intelligent chat assistant for farming questions and plant diagnosis.
Capabilities:
- Real-time chat with Gemini AI
- Photo-based plant disease diagnosis
- Pest control advice (organic methods prioritized)
- Irrigation and fertilization guidance
- Crop-specific question answering
- Multi-language responses
Technical Implementation:
// Image-based diagnosis
Content.multi([
TextPart(prompt),
DataPart('image/jpeg', imageBytes),
])
// Text-based chat
ChatSession.sendMessage(Content.text(userQuery))Advanced image analysis for plant disease identification.
Features:
- Camera and gallery image input
- Real-time disease detection
- Confidence score display
- Treatment recommendations
- Detection history
- Share results functionality
AI Prompt Structure:
Analyze this plant image and provide:
1. Plant identification
2. Disease/problem detection
3. Severity assessment
4. Treatment recommendations
5. Prevention tips
Week-by-week farming guides generated by AI.
Data Structure:
{
"week": 1,
"date_range": ["2025-01-01", "2025-01-07"],
"stage": "Land Preparation",
"tasks": [
"Test soil pH and adjust as necessary",
"Plow the field to a depth of 15 cm",
"Add organic compost"
],
"completedTasks": [0, 2]
}Stages Covered:
- ποΈ Land Preparation
- π± Planting/Sowing
- π Growth & Maintenance
- πΈ Flowering
- πΎ Harvest
AI-powered harvest forecasting system.
Inputs:
- Selected crop
- Land size (hectares/acres/timad)
- Seed amount
- Fertilizer used
- Field data (if mapped)
Outputs:
{
"estimated_yield_min": 1500,
"estimated_yield_max": 2500,
"yield_per_hectare": 2000,
"confidence_percentage": 85,
"market_value_estimate_min": 45000,
"market_value_estimate_max": 75000,
"harvest_quality_prediction": "good",
"optimal_harvest_timing": "When 90% of grains are golden",
"factors_affecting_yield": [...],
"recommendations": [...]
}Precise land measurement using GPS coordinates.
Features:
- Real-time GPS tracking
- Walk-the-boundary mapping
- Automatic area calculation (Shoelace formula)
- Multiple soil type options
- Save and manage multiple fields
- Integration with crop recommendations
Area Calculation:
// Shoelace formula for polygon area
double _calculatePolygonArea(List<LatLng> points) {
double area = 0;
for (int i = 0; i < n; i++) {
int j = (i + 1) % n;
area += x1 * y2 - x2 * y1;
}
return (area.abs() / 2) / 10000; // hectares
}Supported Soil Types:
- Loam
- Clay
- Sandy
- Silt
- Vertisol (Black Cotton)
- Nitosol (Red)
- Andosol
Real-time agricultural commodity prices.
Features:
- Price trends visualization
- Historical data charts
- Regional price comparison
- Price alerts (planned)
Comprehensive weather information for farming decisions.
Data Provided:
- Current temperature
- Humidity levels
- Weather conditions
- 7-day forecast
- Farming recommendations based on weather
Educational content for farmers.
Categories:
- Crop guides
- Pest management
- Soil health
- Water management
- Post-harvest handling
- Market information
Digital record-keeping for farm activities.
Record Types:
- Planting records
- Harvest records
- Input purchases
- Sales records
- Expense tracking
User profile and farm information management.
Profile Data:
- Personal information
- Farm location
- Land holdings
- Crop history
- Preferences
| Technology | Purpose | Version |
|---|---|---|
| Flutter | Cross-platform UI framework | 3.x |
| Dart | Programming language | 3.x |
| Provider | State management | 6.x |
| Google Fonts | Typography | 6.x |
| FL Chart | Data visualization | 0.69.x |
| Service | Purpose |
|---|---|
| Firebase Auth | User authentication |
| Cloud Firestore | NoSQL database |
| Google Gemini AI | AI/ML capabilities |
| OpenWeather API | Weather data |
| Open-Elevation API | Elevation data |
dependencies:
# Firebase
firebase_core: ^3.12.1
firebase_auth: ^5.5.1
cloud_firestore: ^5.6.5
# AI & ML
google_generative_ai: ^0.4.6
# Location
geolocator: ^13.0.2
# Media
image_picker: ^1.1.2
# UI
google_fonts: ^6.2.1
fl_chart: ^0.69.2
awesome_dialog: ^3.2.1
# Storage
shared_preferences: ^2.x
hive: ^2.x
hive_flutter: ^1.x
# Utilities
http: ^1.3.0
intl: ^0.19.0
flutter_dotenv: ^5.2.1
provider: ^6.1.2
uuid: ^4.5.1βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β PRESENTATION LAYER β
β βββββββββββ βββββββββββ βββββββββββ βββββββββββ β
β β Pages β β Widgets β β Dialogs β β Cards β β
β ββββββ¬βββββ ββββββ¬βββββ ββββββ¬βββββ ββββββ¬βββββ β
βββββββββΌββββββββββββΌββββββββββββΌββββββββββββΌββββββββββββββββββ
β β β β
βΌ βΌ βΌ βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β BUSINESS LAYER β
β ββββββββββββββ ββββββββββββββ ββββββββββββββ β
β β Services β β Providers β β Models β β
β βββββββ¬βββββββ βββββββ¬βββββββ βββββββ¬βββββββ β
ββββββββββΌβββββββββββββββΌβββββββββββββββΌβββββββββββββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DATA LAYER β
β βββββββββββββ βββββββββββββ βββββββββββββ βββββββββββββ β
β β Firebase β β Gemini AI β β Weather β β Local β β
β β Firestore β β API β β API β β Storage β β
β βββββββββββββ βββββββββββββ βββββββββββββ βββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
User Action
β
βΌ
βββββββββββββββ
β Widget β ββββ State Management (Provider/setState)
ββββββββ¬βββββββ
β
βΌ
βββββββββββββββ
β Service β ββββ Business Logic
ββββββββ¬βββββββ
β
βΌ
βββββββββββββββ
β External β ββββ Firebase / APIs / AI
β Service β
ββββββββ¬βββββββ
β
βΌ
Response
β
βΌ
UI Update
The app uses a combination of:
- Provider - For app-wide state (settings, user info)
- StatefulWidget - For local component state
- FutureBuilder/StreamBuilder - For async data
// Global state example
class AppSettings extends ChangeNotifier {
Locale _locale = const Locale('en');
Locale get locale => _locale;
Future<void> setLocale(Locale newLocale) async {
_locale = newLocale;
await _persistLocale(newLocale);
notifyListeners();
}
}- Flutter SDK 3.x or higher
- Dart SDK 3.x or higher
- Android Studio / VS Code
- Firebase CLI
- Git
git clone https://github.com/your-org/smart-gebere.git
cd smart-gebere/Smart_Gebereflutter pub get- Create a Firebase project at Firebase Console
- Enable Authentication (Email/Password)
- Enable Cloud Firestore
- Download configuration files:
google-services.jsonβandroid/app/GoogleService-Info.plistβios/Runner/
Create .env file in project root:
# API Keys
API_KEY=your_gemini_api_key
GEMINI_API_KEY=your_gemini_api_key
OPENWEATHER_API_KEY=your_openweather_api_key
# Model Configuration
GEMINI_MODEL=gemini-1.5-flash# Development
flutter run
# Web
flutter run -d chrome
# Android
flutter run -d android
# iOS
flutter run -d ios
# Build APK
flutter build apk --release
# Build iOS
flutter build ios --release| Variable | Description | Required |
|---|---|---|
API_KEY |
Gemini AI API key | β |
GEMINI_API_KEY |
Alternative Gemini key | β |
OPENWEATHER_API_KEY |
Weather API key | β |
GEMINI_MODEL |
AI model name | β (default: gemini-1.5-flash) |
Firestore Security Rules:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Users collection
match /users/{userId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
// Farmers collection
match /Farmers/{userId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
// Public content
match /content/{document=**} {
allow read: if request.auth != null;
allow write: if false;
}
}
}Smart_Gebere/
βββ android/ # Android-specific code
βββ ios/ # iOS-specific code
βββ web/ # Web-specific code
βββ lib/
β βββ main.dart # Application entry point
β β
β βββ auth/ # Authentication
β β βββ login/
β β β βββ login.dart # Login page
β β βββ signup/
β β βββ sign_up.dart # Registration page
β β
β βββ Home/ # Home module
β β βββ Home.dart # Main dashboard
β β βββ task_creation.dart # Task creation cards
β β βββ created_task.dart # Active crops display
β β βββ expected_event.dart # Upcoming tasks
β β βββ cropdetailpage.dart # Crop details
β β βββ weeklydetailpage.dart # Weekly details
β β
β βββ Disease_page/ # Disease detection
β β βββ DiseaseDetection.dart
β β
β βββ geo_Location/ # Location services
β β βββ location.dart # GPS & weather
β β
β βββ scheduling/ # Crop planning
β β βββ schedule.dart # Week-by-week planner
β β
β βββ task_management/ # Task management
β β βββ descrition.dart # Agriculture intro page
β β βββ list_suggestion.dart # Crop suggestions
β β
β βββ features/ # Feature modules
β β βββ ai_doctor/
β β β βββ ai_crop_doctor_page.dart
β β βββ yield_prediction/
β β β βββ yield_prediction_page.dart
β β βββ field_mapping/
β β β βββ field_mapping_page.dart
β β βββ market_prices/
β β β βββ market_prices_page.dart
β β βββ weather_advisor/
β β β βββ weather_advisor_page.dart
β β βββ farm_records/
β β β βββ farm_records_page.dart
β β βββ farm_profile/
β β β βββ farm_profile_page.dart
β β βββ knowledge_base/
β β β βββ knowledge_base_page.dart
β β βββ privacy/
β β βββ privacy_page.dart
β β
β βββ core/ # Core services
β β βββ services/
β β β βββ connectivity_service.dart
β β β βββ connectivity_io.dart
β β β βββ connectivity_web.dart
β β β βββ connectivity_stub.dart
β β β βββ offline_storage.dart
β β β βββ ai_reliability.dart
β β β βββ content_service.dart
β β βββ models/
β β βββ farm_profile.dart
β β βββ farm_record.dart
β β βββ market_price.dart
β β βββ knowledge_article.dart
β β βββ detection_history.dart
β β
β βββ settings/ # App settings
β β βββ app_settings.dart
β β βββ settings_page.dart
β β βββ locale_store.dart
β β βββ locale_store_io.dart
β β βββ locale_store_web.dart
β β βββ locale_store_stub.dart
β β
β βββ l10n/ # Localization
β β βββ app_localizations.dart
β β βββ fallback_localizations.dart
β β βββ app_en.arb
β β βββ app_am.arb
β β βββ app_om.arb
β β
β βββ stream/ # Auth state
β β βββ stream_provider.dart
β β
β βββ splash/ # Splash screen
β β βββ splash_screen.dart
β β
β βββ onboarding/ # Onboarding
β β βββ onboarding_page.dart
β β
β βββ Loading/ # Loading states
β βββ loading.dart
β
βββ assets/ # Static assets
β βββ image_1.jpg
β βββ ...
β
βββ .env # Environment variables
βββ pubspec.yaml # Dependencies
βββ firestore.rules # Firestore rules
βββ firebase.json # Firebase config
βββ README.md # This file
Location: lib/auth/
Handles user authentication using Firebase Auth.
// Login
await FirebaseAuth.instance.signInWithEmailAndPassword(
email: email,
password: password,
);
// Signup
await FirebaseAuth.instance.createUserWithEmailAndPassword(
email: email,
password: password,
);
// Logout
await FirebaseAuth.instance.signOut();Features:
- Email/password authentication
- Password visibility toggle
- Form validation
- Error handling with user-friendly messages
- Animated transitions
Location: lib/geo_Location/location.dart
Provides GPS coordinates, elevation, and weather data.
class LocationService {
// Get current location with all data
Future<Map<String, dynamic>> getCurrentLocation();
// Get elevation for coordinates
Future<double> getElevation(double lat, double lon);
// Get weather data
Future<Map<String, dynamic>> getWeather(double lat, double lon);
// Generate AI crop suggestions
Future<List<Map<String, dynamic>>> generateCropSuggestions(
Map<String, dynamic> locationData, {
Map<String, dynamic>? fieldData,
});
}Multiple AI-powered features using Gemini:
// Initialize model
final model = GenerativeModel(
model: 'gemini-1.5-flash',
apiKey: apiKey,
safetySettings: [...],
systemInstruction: Content.text('...'),
);
// Text generation
final response = await model.generateContent([Content.text(prompt)]);
// Image analysis
final response = await model.generateContent([
Content.multi([
TextPart(prompt),
DataPart('image/jpeg', imageBytes),
])
]);
// Chat session
final chatSession = model.startChat();
final response = await chatSession.sendMessage(Content.text(message));Location: lib/core/services/offline_storage.dart
Local data persistence using Hive.
class OfflineStorage {
Future<void> init();
Future<void> saveCrops(List<Map<String, dynamic>> crops);
Future<List<Map<String, dynamic>>> getCrops();
Future<void> savePendingSync(Map<String, dynamic> data);
Future<List<Map<String, dynamic>>> getPendingSync();
}Location: lib/core/services/connectivity_service.dart
Cross-platform network status monitoring.
abstract class ConnectivityService {
Stream<bool> get onConnectivityChanged;
Future<bool> isConnected();
}
// Platform-specific implementations
// - connectivity_io.dart (Mobile/Desktop)
// - connectivity_web.dart (Web)Endpoint: https://generativelanguage.googleapis.com/v1beta/
Authentication: API Key
Models Used:
gemini-1.5-flash(primary)gemini-2.5-flash(preferred, with fallback)
Usage Examples:
// Crop recommendations
String prompt = """
Based on the following location data, provide crop recommendations:
- Latitude: ${lat}
- Longitude: ${lon}
- Elevation: ${elevation}m
- Temperature: ${temp}Β°C
...
""";
// Disease detection
String prompt = """
Analyze this plant image and provide:
1. Plant identification
2. Disease detection
3. Treatment recommendations
...
""";Endpoint: https://api.openweathermap.org/data/2.5/weather
Parameters:
lat- Latitudelon- Longitudeappid- API keyunits- metric
Response:
{
"main": {
"temp": 25.5,
"humidity": 65
},
"weather": [{
"description": "scattered clouds"
}]
}Endpoint: https://api.open-elevation.com/api/v1/lookup
Request:
{
"locations": [
{"latitude": 9.0, "longitude": 38.75}
]
}Response:
{
"results": [{
"elevation": 2355
}]
}interface Farmer {
// Profile
name?: string;
phone?: string;
region?: string;
// Fields (mapped GPS fields)
fields?: Field[];
// Crops (active crop plans)
crops?: Crop[];
}
interface Field {
id: string;
name: string;
soilType: string;
areaHectares: number;
points: {lat: number, lng: number}[];
createdAt: string;
}
interface Crop {
id: string;
name: string;
weeks: Week[];
progressPercentage: number;
daysSinceFirstPlanting: number;
createdAt: string;
fieldId?: string;
fieldName?: string;
fieldAreaHectares?: number;
soilType?: string;
}
interface Week {
week: number;
date_range: [string, string];
stage: string;
tasks: string[];
completedTasks?: number[];
}interface User {
email: string;
createdAt: Timestamp;
lastLogin: Timestamp;
settings?: UserSettings;
}
interface UserSettings {
language: string;
notifications: boolean;
}| Language | Code | Status |
|---|---|---|
| English | en |
β Complete |
| Amharic (α ααα) | am |
β Complete |
| Afaan Oromo | om |
β Complete |
Location: lib/l10n/
Usage:
final l10n = AppLocalizations.of(context);
Text(l10n.welcomeMessage);
Text(l10n.createTask);Adding New Strings:
- Add to
app_en.arb:
{
"newString": "English text"
}- Add to
app_am.arb:
{
"newString": "α¨α ααα α½αα"
}- Add to
app_om.arb:
{
"newString": "Afaan Oromo text"
}- Add to
AppLocalizationsclass:
String get newString => _localizedValues[locale.languageCode]?['newString'] ?? 'Default';// In SettingsPage
await settings.setLocale(Locale('am')); // Switch to Amharic- Firebase Authentication with email/password
- Secure token management
- Session persistence
- Firestore security rules enforce user-level access
- No cross-user data access
- API keys stored in
.env(not committed)
- API Keys: Never commit
.envfiles - User Data: Encrypt sensitive local storage
- Network: All API calls over HTTPS
- Validation: Server-side validation in Firestore rules
// Only authenticated users can access their own data
match /Farmers/{userId} {
allow read, write: if request.auth != null
&& request.auth.uid == userId;
}flutter testflutter test integration_test/testWidgets('Login button works', (tester) async {
await tester.pumpWidget(MyApp());
await tester.tap(find.text('Login'));
await tester.pump();
expect(find.text('Welcome'), findsOneWidget);
});# Generate release APK
flutter build apk --release
# Generate App Bundle
flutter build appbundle --releaseOutput: build/app/outputs/flutter-apk/app-release.apk
flutter build ios --releaseThen archive and upload via Xcode.
flutter build web --releaseOutput: build/web/
Deploy to Firebase Hosting:
firebase deploy --only hostingError: Unable to load asset: "AssetManifest.json"
Solution:
flutter clean
flutter pub get
flutter run -d chromeError: PERMISSION_DENIED
Solution:
- Deploy Firestore rules:
firebase deploy --only firestore:rules - Verify user is authenticated
- Check collection path matches rules
Error: model is not found
Solution:
- Update
GEMINI_MODELin.envtogemini-1.5-flash - The app has automatic fallback to this model
Solution:
- Android: Check
AndroidManifest.xmlpermissions - iOS: Check
Info.plistusage descriptions - Request permission in app before accessing location
MissingPluginException: No implementation found
Solution:
- For
shared_preferences: App uses cross-platformLocaleStore - For
connectivity_plus: App uses platform-specific implementations - Ensure
flutter pub getand full restart
- User authentication
- GPS-based crop recommendations
- Disease detection
- Crop planning/scheduling
- Multi-language support
- AI Crop Doctor chat
- Yield prediction
- GPS field mapping
- Task completion tracking
- Progress calculation
- Push notifications
- Offline-first mode
- Voice input for chat
- Community forums
- Expert consultation
- IoT sensor integration
- Drone imagery support
- Marketplace integration
- Government scheme information
- Insurance integration
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow Dart style guide
- Use meaningful variable names
- Add comments for complex logic
- Write tests for new features
feat: add yield prediction feature
fix: resolve login error on iOS
docs: update API documentation
style: format code with dartfmt
refactor: simplify location service
test: add unit tests for auth
This project is licensed under the MIT License - see the LICENSE file for details.
Smart Gebere Development Team
- Project Lead
- Flutter Developers
- UI/UX Designers
- AI/ML Engineers
- QA Engineers
For support, please:
- Check the Troubleshooting section
- Search existing Issues
- Create a new issue with:
- Device/platform information
- Steps to reproduce
- Expected vs actual behavior
- Screenshots if applicable
- Flutter Team for the amazing framework
- Firebase for backend services
- Google AI for Gemini AI capabilities
- OpenWeather for weather data
- Ethiopian farming community for domain expertise
Made with β€οΈ for Ethiopian Farmers
πΎ Smart Gebere - α΅ααα΅ αα α¬ πΎ
Developer docs live in docs/:
