- Project Overview
- Technical Architecture
- Dependencies & Packages
- Project Structure
- Data Models
- Services Layer
- Business Logic (ViewModels)
- User Interface (Screens & Widgets)
- User Flow & Navigation
- Features & Functionality
- External Integrations
- Localization & Theming
- Firebase Configuration
- Build & Deployment
- Development Guidelines
AgrimSeller (internally named "agrimb") is a comprehensive Flutter-based mobile application designed as an agricultural marketplace platform. The app serves as a bridge between farmers and buyers, facilitating crop transactions with advanced features like crop analysis, weather integration, and structured deal management.
- App Name: Agrim Buyer
- Internal Name: agrimb
- Version: 1.0.0+1
- Flutter SDK: ^3.6.2
- Platform Support: Android, iOS, Web, Windows, macOS, Linux
- Primary Use Case: Agricultural marketplace for crop buying/selling
The application provides a complete ecosystem for agricultural commerce, featuring:
- Real-time crop listings and marketplace
- AI-powered crop quality analysis
- Weather integration for informed decisions
- Structured visit scheduling and deal management
- Multi-language support (English & Hindi)
- Comprehensive notification system
The application follows a Clean Architecture pattern with MVVM (Model-View-ViewModel) implementation using the Provider state management pattern.
- Views/Screens: UI components and user interactions
- ViewModels: Business logic and state management
- Widgets: Reusable UI components
- Repositories: Data access abstraction
- Services: External API integrations and core services
- Models: Data structures and entities
- Local Storage: SharedPreferences for app settings
- External APIs: Firebase, Weather API, ML services
- Provider Pattern: Used for dependency injection and state management
- ChangeNotifier: For reactive UI updates
- MultiProvider: Manages multiple providers at app level
cupertino_icons: ^1.0.8 # iOS-style icons
provider: ^6.1.5 # State managementflutter_svg: ^2.0.7 # SVG support
lottie: ^2.6.0 # Animations
smooth_page_indicator: ^1.2.1 # Page indicators
intl_phone_field: ^3.2.0 # Phone input widget
pin_code_fields: ^8.0.1 # PIN input fieldsshared_preferences: ^2.5.3 # Local storage
intl: ^0.19.0 # Internationalization
uuid: ^4.0.0 # UUID generation
path: ^1.8.3 # Path manipulation
path_provider: ^2.1.1 # Path provider
url_launcher: ^6.1.14 # URL launching
package_info_plus: ^8.3.0 # App info
device_info_plus: ^9.1.0 # Device info
connectivity_plus: ^4.0.2 # Network connectivitypermission_handler: ^12.0.1 # Permission management
geolocator: ^10.1.0 # GPS location
geocoding: ^2.1.1 # Address geocoding
camera: ^0.11.1 # Camera access
image_picker: ^1.1.2 # Image selectionhttp: ^1.4.0 # HTTP client
cached_network_image: ^3.3.0 # Image caching
flutter_image_compress: ^2.4.0 # Image compressionfirebase_core: ^3.14.0 # Firebase core
firebase_auth: ^5.5.2 # Authentication
google_sign_in: ^6.2.1 # Google Sign-in
firebase_app_check: ^0.3.1+7 # App Check security
cloud_firestore: ^5.6.6 # NoSQL database
firebase_storage: ^12.3.7 # File storage
firebase_messaging: ^15.2.7 # Push notifications
flutter_local_notifications: ^19.3.0 # Local notificationsflutter_lints: ^5.0.0 # Code analysis and lintinglib/
├── core/ # Core application utilities
│ ├── constants/ # App-wide constants
│ │ ├── app_assets.dart # Asset paths and references
│ │ ├── app_spacing.dart # Consistent spacing values
│ │ └── app_text_style.dart # Typography definitions
│ ├── localization/ # Internationalization
│ │ ├── app_localizations.dart
│ │ └── localization_extension.dart
│ ├── theme/ # App theming
│ │ ├── app_colors.dart # Color palette
│ │ └── app_theme.dart # Theme configuration
│ └── utils/ # Utility functions
├── data/ # Data layer
│ ├── models/ # Data models and entities
│ ├── repositories/ # Data access layer
│ └── services/ # External service integrations
├── routes/ # Navigation and routing
├── view/ # UI layer
│ ├── screens/ # App screens
│ └── widgets/ # Reusable UI components
├── view_model/ # Business logic layer
└── main.dart # App entry point
assets/
├── animations/ # Lottie animations
├── fonts/ # Custom fonts (Satoshi family)
├── icons/ # App icons
├── images/ # Static images
│ ├── crops/ # Crop-related images
│ └── weather/ # Weather condition icons
├── translations/ # Localization files
└── vectors/ # SVG vector graphics
Purpose: Represents user authentication and profile information
class UserModel {
final String uid; // Firebase UID
final String email; // User email
final String? name; // User full name
final String? phoneNumber; // Contact number
final String? address; // User address
final String? idNumber; // Government ID number
final bool isEmailVerified; // Email verification status
final String? profilePictureUrl; // Profile image URL
final bool profileVerified; // Admin verification status
final String? fcmToken; // Firebase messaging token
}Key Features:
- Firebase integration for authentication
- Profile verification workflow
- FCM token management for push notifications
- JSON serialization/deserialization
Purpose: Represents crop listings in the marketplace
class ListingModel {
final String id; // Unique listing identifier
final String farmerId; // Seller's user ID
final String name; // Crop name
final String imagePath; // Crop image URL
final String location; // Farm/pickup location
final String quantity; // Available quantity
final String price; // Offered price
final String qualityIndicator; // Quality rating
final String listingDate; // When listed
final String quality; // Quality description
final String description; // Additional details
}Purpose: Weather data integration for agricultural insights
class WeatherModel {
final String cityName; // Location name
final String stateName; // State information
final double temperature; // Current temperature
final double tempMin/Max; // Temperature range
final double feelsLike; // Perceived temperature
final int humidity; // Humidity percentage
final double windSpeed; // Wind speed
final String weatherMain; // Weather condition
final String weatherDescription; // Detailed description
final DateTime timestamp; // Data timestamp
}Purpose: In-app notification system
enum NotificationType {
visitScheduled, visitRescheduled, visitCancelled, dealFinalized, general
}
class NotificationModel {
final String id; // Notification ID
final String title; // Notification title
final String body; // Message content
final NotificationType type; // Notification category
final NotificationStatus status; // Read/unread status
final DateTime createdAt; // Creation timestamp
final Map<String, dynamic>? data; // Additional payload
}Purpose: AI-powered crop quality analysis results
class CropAnalysisModel {
final int? totalSeeds; // Total seeds detected
final int? healthySeeds; // Healthy seeds count
final int? defectiveSeeds; // Defective seeds count
final String? error; // Error message if analysis failed
final String? errorCode; // Structured error code
}Error Code System:
E001: Model initialization failedE101: No seeds detectedE201: Objects too small to analyzeE202: Objects too large to analyzeE203: Inconsistent object propertiesE301: Too few seeds detectedE999: General processing error
Purpose: Central Firebase operations management
Key Methods:
signUpWithEmail(): User registration with profile datasignInWithEmail(): Authentication and user data retrievalfetchListedCrops(): Retrieve available crop listingscreateClaimedListing(): Create visit scheduling entryupdateClaimedVisitStatus(): Update visit progressuploadProfilePicture(): Profile image managementfetchClaimedCropsForBuyer(): Get user's claimed crops
Collections Used:
buyers: User profiles and authentication datafarmers: Seller informationListed crops: Available crop listingsclaimedlist: Visit scheduling and deal trackingpending_notifications: Notification queue for backend processing
Purpose: OpenWeatherMap API integration
Features:
- Real-time weather data retrieval
- 4-day weather forecasting
- Location-based weather queries
- Automatic location detection via GPS
- Temperature unit conversion (Celsius/Fahrenheit)
- Weather condition mapping for custom icons
API Integration:
- Base URL:
https://api.openweathermap.org/data/2.5 - Endpoints:
/weather,/forecast,/forecast/daily - API Key Management: Embedded in service class
Purpose: Machine learning-powered crop analysis
Features:
- Image upload and processing
- Seed count and quality analysis
- Defect detection in agricultural products
- Error handling with user-friendly messages
API Integration:
- Endpoint:
https://wheat-seed-api-345895348005.us-central1.run.app/analyze-seeds - Method: POST with multipart file upload
- Response: JSON with analysis results
Purpose: GPS and location management
Features:
- Current location retrieval with permissions
- Address resolution from coordinates
- Location permission management
- Fallback to default location (Vijayawada, Andhra Pradesh)
Purpose: Push notification system
Features:
- FCM token management
- Notification sending to farmers
- Local notification scheduling
- Cross-platform notification handling
- Email/password validation
- Authentication error handling
- Loading state management
- Automatic navigation based on verification status
- Multi-step registration process
- Profile data validation
- File upload coordination
- Email verification workflow
- Admin approval waiting mechanism
- Periodic status checking
- Profile completion tracking
- Weather data coordination
- Best deals aggregation
- User welcome personalization
- Real-time data updates
- Location-based weather fetching
- Forecast data management
- Error state handling
- Automatic refresh mechanisms
- Crop listing retrieval and filtering
- Search functionality
- Visit status tracking
- Claimed crops management
Key Features:
- Real-time search with debouncing
- Multi-criteria filtering (type, location)
- Tab-based organization (Listed/Claimed crops)
- Status-based crop categorization
- Appointment scheduling
- Farmer contact management
- Location coordination
- Notification integration
- Price negotiation tracking
- Deal term documentation
- Document upload coordination
- Transaction completion
Purpose: App initialization and branding
- Animated logo presentation
- Background image with gradient overlay
- Automatic navigation to language selection
- Custom font implementation (Satoshi)
Purpose: Internationalization setup
- English/Hindi language selection
- Persistent language preferences
- Cultural adaptation preparation
- LoginScreen: Email/password authentication with validation
- SignupScreen: Multi-field registration with image upload
- ForgotPasswordScreen: Password reset via email
- EmailVerificationScreen: Email confirmation workflow
- ProfileVerificationScreen: Admin approval waiting
Purpose: Main app hub with comprehensive overview Components:
- Dynamic weather widget with real-time data
- Featured crop purchase options
- Mandi Bhav (market price) display
- Best deals carousel
- Bottom navigation integration
Purpose: Marketplace interface with advanced filtering Features:
- Dual-tab layout (Listed/Claimed crops)
- Advanced search with real-time filtering
- Filter chips for type and location
- Pull-to-refresh functionality
- Status-based crop organization
- CaptureProcessScreen: Camera interface with guidelines
- CheckYourCrop: Analysis result display
- PhotoCaptureController: Advanced camera controls
- ClaimListingScreen: Crop details and claiming interface
- VisitScheduleScreen: Appointment scheduling
- VisitSiteScreen: On-site action management
- FinalDealScreen: Deal terms and price finalization
- UploadVerificationDocumentsScreen: Document collection
- DealCompletedSplashScreen: Success confirmation
- CustomBottomNavBar: Persistent bottom navigation
- DashboardAppBar: Context-aware app bar with user info
- EmailInput: Validated email input field
- PasswordInput: Secure password input with visibility toggle
- AppButton: Standardized button with loading states
- AuthHeader: Consistent authentication screen headers
- ErrorDialog: User-friendly error display
- WeatherCard: Real-time weather display with animations
- FeatureCard: Action-oriented feature presentation
- BestDealsCard: Deal highlighting with imagery
- MandiBhavCard: Market price information display
- ListingCard: Comprehensive crop information display
- FilterChip: Interactive filter selection
- SearchBar: Real-time search interface
-
App Launch
- Splash screen with branding
- Language selection (first launch)
- Authentication check
-
Authentication Flow
- Login/Signup decision
- Profile creation with verification
- Email verification process
- Admin profile verification wait
-
Main Application Flow
- Dashboard overview
- Crop browsing and filtering
- Listing claiming process
- Visit scheduling
- On-site crop analysis
- Deal finalization
- Document upload and completion
- Named Routes: Centralized route management in
app_routes.dart - Route Observer: Navigation lifecycle tracking
- Context-Aware Navigation: Conditional routing based on user state
- Deep Linking Support: Direct access to specific screens
- Bottom Navigation: Primary app sections (Home, Buy, Calls, Profile)
- Stack Navigation: Linear workflow progression
- Modal Navigation: Overlay screens for focused tasks
- Tab Navigation: Content organization within screens
- Email/Password Authentication: Firebase Auth integration
- Profile Verification: Two-tier verification system
- Profile Management: Image upload and data editing
- Security Features: Email verification, secure token management
- Crop Listings: Comprehensive product information
- Advanced Search: Multi-criteria filtering and search
- Real-time Updates: Live data synchronization
- Claim Management: Structured purchasing workflow
- Image Capture: Camera integration with guidelines
- Quality Assessment: ML-based seed analysis
- Defect Detection: Automated quality scoring
- Results Interpretation: User-friendly analysis presentation
- Real-time Weather: Current conditions display
- Weather Forecasting: 4-day forecast with detailed metrics
- Location-based Data: GPS-driven weather information
- Agricultural Insights: Weather impact on crop decisions
- Appointment Scheduling: Calendar integration
- Location Coordination: Meeting point management
- Progress Tracking: Multi-stage visit workflow
- Document Management: Verification document collection
- Push Notifications: Firebase Cloud Messaging
- Local Notifications: App-based alerts
- Notification Categories: Visit, deal, and general notifications
- Read/Unread Tracking: Notification status management
- Multi-language Support: English and Hindi
- Cultural Adaptation: Region-specific content
- Dynamic Language Switching: Runtime language changes
- Localized Content: Translated strings and formats
- User Management: Registration, login, password reset
- Email Verification: Automated verification workflow
- Security: Secure token management and validation
- Collections:
buyers: User profiles and authentication datafarmers: Seller information and contact detailsListed crops: Available crop listings with metadataclaimedlist: Visit scheduling and deal trackingpending_notifications: Notification queue management
- Profile Pictures: User image storage and retrieval
- Crop Images: Product photography storage
- Document Storage: Verification document management
- Push Notifications: Cross-platform notification delivery
- Token Management: FCM token lifecycle management
- Background Processing: Cloud function integration
- Current Weather: Real-time weather condition data
- Weather Forecasting: Multi-day forecast information
- Location Integration: GPS-based weather queries
- Data Processing: Temperature, humidity, wind, and precipitation
- Crop Analysis Service:
https://wheat-seed-api-345895348005.us-central1.run.app - Image Processing: Multipart file upload and analysis
- Quality Assessment: Seed count and defect detection
- Error Handling: Structured error response management
- Location Services: GPS and geocoding integration
- Maps Integration: Location display and selection
- Sign-in Services: Google authentication option
- Camera Access: Image capture with permission management
- Storage Access: File system integration
- Network Monitoring: Connectivity status tracking
- Permission Management: Runtime permission handling
- English (en): Primary language
- Hindi (hi): Regional language support
- File Structure: JSON-based translation files
- Dynamic Loading: Runtime language switching
- Fallback Mechanism: Default to English for missing translations
- Extension Methods: Convenient translation access via context
- Authentication: Login, signup, verification messages
- Marketplace: Crop listings, search, and filtering
- Weather: Weather conditions and forecasts
- Notifications: Alert messages and updates
- Error Messages: User-friendly error communication
class AppColors {
// Primary Colors
static const Color orange = Color.fromARGB(255, 242, 128, 53);
static const Color brown = Color(0xFF4A3C31);
// Secondary Colors
static const Color lightOrange = Color(0xFFFFE4CC);
static const Color lightBrown = Color(0xFFE5DFD9);
// Status Colors
static const Color success = Color(0xFF4CAF50);
static const Color error = Color(0xFFE53935);
static const Color warning = Color(0xFFFFA000);
}- Font Family: Satoshi (custom font with multiple weights)
- Font Weights: Light (300), Regular (400), Medium (500), Bold (600), Black (900)
- Responsive Typography: Scalable text sizes based on screen dimensions
- Consistent Spacing: Standardized padding and margin values
- Border Radius: Consistent corner radius application
- Shadow System: Layered shadow definitions for depth
- Component Styling: Reusable style definitions
- Project ID:
- Support Platforms: Android, iOS, Web
- Security: Firebase App Check integration
- Application ID:
- Configuration File:
- Firebase App ID:
- Bundle ID: Configured for iOS deployment
- Firebase App ID:
- Runtime: Node.js 20
- Source Directory:
- Build Command:
npm run build - Deployment: Automated via Firebase CLI
- Authentication: User-based access control
- Data Validation: Schema validation for Firestore
- File Upload: Secure storage rules for user content
- Flutter SDK ^3.6.2
- Dart SDK (included with Flutter)
- Android Studio / Xcode (for mobile development)
- Firebase CLI (for backend deployment)
- Node.js 20+ (for Cloud Functions)
# Get dependencies
flutter pub get
# Run in development
flutter run
# Build for production (Android)
flutter build apk --release
flutter build appbundle --release
# Build for production (iOS)
flutter build ios --release
# Web build
flutter build web- API Keys: Weather API key embedded in service classes
- Firebase Configuration: Auto-generated configuration files
- Build Variants: Debug, profile, and release configurations
- Google Play Store: Android app distribution
- Apple App Store: iOS app distribution
- App Signing: Proper certificate management
- Firebase Hosting: Web app deployment option
- Static Site Generation: Optimized web builds
- Cloud Functions: Automated notification processing
- Firebase Services: Managed backend infrastructure
- Clean Architecture: Separation of concerns
- MVVM Pattern: Model-View-ViewModel implementation
- Provider Pattern: State management and dependency injection
- Flutter Lints: Enforced code quality rules
- Naming Conventions: Consistent variable and method naming
- Documentation: Comprehensive code comments
- Error Handling: Structured exception management
- Image Optimization: Cached network images
- Memory Management: Proper widget disposal
- Network Efficiency: Request optimization and caching
- Background Processing: Efficient data synchronization
- Unit Testing: Business logic validation
- Widget Testing: UI component testing
- Integration Testing: End-to-end workflow validation
- Performance Testing: App performance monitoring
- Data Encryption: Sensitive data protection
- Authentication Security: Secure token management
- API Security: Secure external service integration
- Permission Management: Minimal permission requests
- Version Control: Git-based source code management
- Release Management: Structured release workflow
- Bug Tracking: Issue identification and resolution
- Feature Development: Agile development practices
AgrimSeller represents a comprehensive agricultural marketplace solution built with modern Flutter architecture and comprehensive external service integration. The application demonstrates enterprise-level development practices with robust error handling, security considerations, and user experience optimization.
- Comprehensive Feature Set: Complete crop trading workflow
- Modern Architecture: Clean, maintainable, and scalable code structure
- External Integration: Effective use of Firebase, weather, and ML services
- User Experience: Intuitive interface with cultural considerations
- Technical Excellence: Proper state management and error handling
- Enhanced Analytics: User behavior tracking and insights
- Advanced Filtering: AI-powered crop recommendations
- Social Features: Community building and farmer networks
- Payment Integration: Integrated payment processing
- Logistics Coordination: Delivery and transportation management
This documentation provides a complete technical reference for the AgrimSeller project, enabling effective development, maintenance, and enhancement of the application.



