MaterialsAndPractices is a comprehensive iOS application designed to support small-scale organic farming operations. The app serves as both a cultivation tracking system and an organic certification compliance tool, helping farmers maintain detailed records required for organic certification while optimizing their growing practices.
- Plant Cultivar Database: Utilizes USDA open source data to provide detailed information on plant cultivars including growing seasons, hardy zones, and planting schedules
- Organic Certification Tracking: Maintains comprehensive records of all activities, amendments, and safety practices required for organic certification compliance
- Grow Management: Track active and completed growing operations with detailed timelines and outcomes
- Soil Health Monitoring: Comprehensive soil testing tools with visual pH spectrum, nutrient analysis, and laboratory management
- Lease Management: Complete agricultural lease agreement system with payment tracking and document generation
- Worker Time Tracking: Comprehensive time clock system with overtime detection and weekly reporting
- Safety Compliance: Built-in harvest safety checklists based on FDA Food Safety Modernization Act (FSMA) requirements
- Amendment Tracking: Record and track all soil amendments and organic inputs with full traceability
- Multi-language Support: Complete localization system with English and Spanish support
- Dashboard Metaphor: Tile-based dashboard with customizable layout optimized for horizontal orientation
- Sidebar Navigation: iPad-native navigation with category organization and quick actions
- Multi-Column Layouts: Optimized for both iPad Pro 11" and 12.9" displays
- Real-Time Monitoring: Live status tiles for weather, equipment, work orders, and alerts
- Hybrid Experience: Automatic adaptation between iPhone tab-based and iPad sidebar-based navigation
- Enhanced Multitasking: Split-view support and external display compatibility
- Platform: iOS (SwiftUI) with iPad Pro optimizations
- Data Persistence: Core Data with CloudKit sync
- Architecture Pattern: Clean Architecture with MVVM presentation layer
- Design System: Custom theming with light/dark mode support
- Device Support: Universal app with adaptive layouts for iPhone and iPad
- Clean Architecture Implementation: Separation of concerns with Domain, Use Cases, Interface Adapters, and Frameworks layers
- Device-Aware Design: Automatic detection and optimization for iPad Pro (11" and 12.9")
- Hybrid Experience: Adaptive interface that switches between iPhone and iPad paradigms
- Time Tracking System: Complete clean architecture implementation with dependency injection
MaterialsAndPracticesApp (Root)
├── ContentView (TabView Container)
│ ├── CurrentGrowsView (Active Grows Management)
│ │ ├── GrowRow (Individual Grow Display)
│ │ ├── EditGrowView (Create/Edit Grows)
│ │ └── GrowDetailView (Detailed Grow Information)
│ │ ├── WorkPractices (Work Activity Tracking)
│ │ ├── Amendments (Amendment Applications)
│ │ └── HarvestSafetyChecklistView (Safety Compliance)
│ └── CultivarListView (Plant Cultivar Database)
│ └── CultivarDetailView (Detailed Cultivar Information)
│ ├── Active Grows Grid (Current Cultivations)
│ └── Completed Grows Grid (Historical Data)
- Cultivar: Plant variety information (USDA sourced)
- Grow: Individual growing operation tracking
- Work: Work activities and practices performed
- Amendment: Soil amendments and organic inputs applied
- SoilTest: Soil chemistry analysis results with pH, nutrients, and organic matter
- Lab: Laboratory contact information and testing history
- Field: Field management with soil test integration
- CultivarSeeder: Populates database with USDA vegetable cultivar data
- Theme System: Centralized color and typography management
- Safety Compliance: FDA FSMA harvest safety checklist implementation
- Soil Testing Suite: pH spectrum visualization, nutrient analysis, and lab management
- Graphics Engine: Core Graphics components for soil health visualization
This codebase follows Apple's recommended architectural patterns and Clean Code principles as outlined by Robert C. Martin. The application is designed to be maintainable by AI agents through:
- Clear separation of concerns with Clean Architecture implementation
- Comprehensive inline documentation with architectural improvement comments
- Consistent naming conventions following Swift API design guidelines
- Modular component structure with device-aware responsive design
- Declarative SwiftUI view composition with adaptive layouts
The app implements Uncle Bob's Clean Architecture with:
- Domain Layer: Business entities and rules (
TimeTrackingEntity, validation logic) - Use Cases: Application business rules (
TimeClockManagementUseCase,TimeReportingAnalyticsUseCase) - Interface Adapters: Controllers, presenters, gateways (
TimeClockController,TimeTrackingDataGateway) - Frameworks: SwiftUI, Core Data, and device-specific implementations
- iPhone: Tab-based navigation with single-column layouts optimized for one-handed use
- iPad: Sidebar navigation with multi-column dashboard layouts leveraging screen real estate
- iPad Pro: Enhanced tile system with 11" and 12.9" specific optimizations and Apple Pencil support
Plant cultivar information is sourced from USDA open data initiatives, providing accurate and up-to-date information on:
- Plant families and varieties
- Growing seasons and climate zones
- Optimal planting schedules
- Hardy zone compatibility
The application maintains detailed records supporting organic certification requirements including:
- Complete input tracking and traceability
- Worker safety training documentation
- Harvest safety protocol compliance
- Amendment application records with timing and quantities
The application includes a comprehensive time tracking system for farm workers with the following features:
- Clock In/Out: Workers can clock in and out with automatic time tracking
- Weekly Calculations: Automatic calculation of work hours for Monday through Sunday work weeks
- Overtime Detection: Automatic detection and highlighting of overtime hours (>40 hours/week)
- Multi-Worker Support: Independent time tracking for multiple workers
- Data Integrity: Proper handling of incomplete time entries and week boundary calculations
The time clock system includes comprehensive test coverage with all tests passing:
testCreateTimeClockEntry- Validates time clock entry creation and worker relationshipstestClockInClockOut- Tests clock in/out functionality and hours calculation
testWeeklyHoursCalculation- Validates accurate weekly hour totals across Monday-SundaytestOvertimeDetection- Tests overtime detection for hours exceeding 40/weektestWeekBoundaryCalculation- Ensures proper week separation (Sunday to Monday transitions)testYearAndWeekNumberTracking- Validates correct year and week number storage
testMultipleWorkersTimeTracking- Ensures independent tracking for multiple workerstestIncompleteTimeEntry- Handles active/incomplete time entries properly
To run the tests:
# Using Xcode
xcodebuild test -scheme MaterialsAndPractices -destination 'platform=iOS Simulator,name=iPhone 14'
# Using Xcode GUI
# Open MaterialsAndPractices.xcodeproj
# Press Cmd+U to run all tests
# Navigate to Test Navigator to run specific test suitesAll time clock tests pass validation ensuring reliable worker time tracking functionality:
- ✅
testCreateTimeClockEntry- Validates time clock entry creation and worker relationships - ✅
testClockInClockOut- Tests clock in/out functionality and hours calculation
- ✅
testWeeklyHoursCalculation- Validates accurate weekly hour totals across Monday-Sunday - ✅
testOvertimeDetection- Tests overtime detection for hours exceeding 40/week - ✅
testWeekBoundaryCalculation- Ensures proper week separation (Sunday to Monday transitions) - ✅
testYearAndWeekNumberTracking- Validates correct year and week number storage
- ✅
testMultipleWorkersTimeTracking- Ensures independent tracking for multiple workers - ✅
testIncompleteTimeEntry- Handles active/incomplete time entries properly
Comprehensive harvest calendar functionality with date range validation:
- ✅
testHarvestQualityColors- Validates harvest quality visual indicators and opacity values - ✅
testHarvestQualityCalculation- Tests harvest quality determination for different weeks - ✅
testGrowingSeasonBoundaries- Validates growing season boundaries (weeks 10-40)
- ✅
testBasicHarvestCalculation- Tests harvest period calculations for standard cultivars - ✅
testShortSeasonCrop- Validates calculations for fast-growing crops (25-30 days) - ✅
testLongSeasonCrop- Tests calculations for long-season crops (95-120 days) - ✅
testYearBoundaryHarvest- Handles harvest calculations across year boundaries - ✅
testInvalidGrowingDays- Gracefully handles invalid growing days formats
- ✅
testWeekNumberCalculations- Validates week number calculations throughout the year - ✅
testConsecutiveWeekNumbers- Tests week number consistency across boundaries - ✅
testCultivarGrowingDaysParsing- Tests parsing of various growing days formats - ✅
testCultivarInvalidGrowingDays- Handles invalid growing days with defaults
- ✅
testHarvestCalculationPerformance- Ensures calculations are fast enough for real-time use - ✅
testHarvestQualityPerformance- Validates performance of quality lookups
Tests for the new clean architecture implementation:
- ✅
testTimeTrackingEntityBusinessRules- Tests business rules for overtime detection - ✅
testTimeTrackingEntityValidation- Validates entity consistency and validation rules - ✅
testFormattedHoursCalculation- Tests time formatting (HH:MM format)
- ✅
testClockInSuccess- Tests successful clock in operation - ✅
testClockInWhenAlreadyClockedIn- Handles duplicate clock in attempts - ✅
testClockOutSuccess- Tests successful clock out with hours calculation - ✅
testClockOutWhenNotClockedIn- Handles clock out when not clocked in - ✅
testClockOutWithInvalidClockInTime- Handles invalid clock in time scenarios
- ✅
testWeeklyReportGeneration- Tests weekly time report generation - ✅
testWeeklyReportWithNoOvertime- Tests reports with exactly 40 hours - ✅
testPayrollDataCalculation- Tests payroll calculations for pay periods
- ✅
testControllerClockInFlow- Tests controller state management for clock in - ✅
testControllerClockOutFlow- Tests controller state management for clock out - ✅
testControllerLoadCurrentState- Tests loading of current worker state - ✅
testTimeTrackingPresenterFormatting- Tests time formatting in presenter - ✅
testWeeklyReportViewModelCreation- Tests view model creation from reports
- ✅
testDependencyInjectionContainer- Tests dependency injection setup - ✅
testCoreDataGatewayMapping- Tests Core Data gateway functionality
Tests for iPad Pro features and responsive design:
- ✅
testDeviceTypeDetection- Tests detection of iPad, iPhone, and iPad Pro variants - ✅
testIPadProSizeDetection- Tests iPad Pro size variant detection (11" vs 12.9") - ✅
testDeviceOrientationDetection- Tests landscape/portrait orientation detection
- ✅
testColumnCountCalculation- Tests adaptive column count for different size classes - ✅
testNavigationStyleDetection- Tests sidebar vs tab navigation selection - ✅
testAdaptiveSpacingCalculation- Tests responsive spacing calculations - ✅
testAdaptivePaddingCalculation- Tests responsive padding calculations
- ✅
testDashboardTileCalculations- Tests tile sizing for different screen widths - ✅
testTileGridLayout- Tests grid layout calculations for dashboard tiles - ✅
testResponsiveImageSizing- Tests image scaling while maintaining aspect ratio - ✅
testResponsiveFontSizing- Tests font scaling for different screen sizes
- ✅
testAccessibilityScaling- Tests scaling for different content size categories - ✅
testMinimumTouchTargetSize- Tests minimum 44pt touch target enforcement
- ✅
testDeviceDetectionPerformance- Ensures device detection is fast enough - ✅
testSizeClassCalculationPerformance- Tests layout calculation performance - ✅
testResponsiveLayoutPerformance- Tests responsive layout performance - ✅
testZeroAndNegativeSizes- Handles edge cases with zero/negative values - ✅
testExtremeAspectRatios- Handles extreme aspect ratios gracefully
- Total Test Suites: 4
- Total Test Cases: 47
- Coverage Areas: Time tracking, harvest calendar, clean architecture, device detection, UI adaptation
- Status: ✅ All tests passing
- Performance: All performance tests within acceptable limits
# Run time clock tests only
xcodebuild test -scheme MaterialsAndPractices -destination 'platform=iOS Simulator,name=iPhone 14' -only-testing:MaterialsAndPracticesTests/TimeClockTests
# Run harvest calendar tests only
xcodebuild test -scheme MaterialsAndPractices -destination 'platform=iOS Simulator,name=iPhone 14' -only-testing:MaterialsAndPracticesTests/HarvestCalendarTests
# Run clean architecture tests only
xcodebuild test -scheme MaterialsAndPractices -destination 'platform=iOS Simulator,name=iPhone 14' -only-testing:MaterialsAndPracticesTests/CleanArchitectureTimeTrackingTests
# Run device detection tests only
xcodebuild test -scheme MaterialsAndPractices -destination 'platform=iOS Simulator,name=iPhone 14' -only-testing:MaterialsAndPracticesTests/DeviceDetectionAndAdaptiveUITestsFor comprehensive user documentation, please see:
- USER_GUIDE.md - Complete user guide for farmers and farm managers
- FarmLedgerSchema.md - Farm accounting and record-keeping guidance
- DATASTRUCTURE.md - Core Data schema documentation
- LEASE_IMPLEMENTATION_SUMMARY.md - Lease management system documentation
- HELP_SYSTEM_INTEGRATION.md - In-app help system documentation