Skip to content

SpaceTrucker2196/MaterialsAndPractices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Materials And Practices

Executive Summary

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.

Key Features

  • 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

NEW: iPad Pro Features (2024)

  • 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

Application Architecture

Technology Stack

  • 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

NEW: Enhanced Architecture (2024)

  • 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

View Hierarchy

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)

Core Data Models

  • 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

Key Components

  • 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

Development Guidelines

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

NEW: Clean Architecture Implementation

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

Device Optimization Strategy

  • 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

Data Sources

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

Organic Certification Support

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

Worker Time Clock System

The application includes a comprehensive time tracking system for farm workers with the following features:

Time Clock Functionality

  • 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

Test Coverage

The time clock system includes comprehensive test coverage with all tests passing:

✅ Basic Time Clock Tests

  • testCreateTimeClockEntry - Validates time clock entry creation and worker relationships
  • testClockInClockOut - Tests clock in/out functionality and hours calculation

✅ Weekly Hours Calculation Tests

  • 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

✅ Edge Cases Tests

  • testMultipleWorkersTimeTracking - Ensures independent tracking for multiple workers
  • testIncompleteTimeEntry - Handles active/incomplete time entries properly

Build and Test Instructions

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 suites

🧪 Test Coverage Status

✅ Time Clock System Tests (TimeClockTests.swift)

All time clock tests pass validation ensuring reliable worker time tracking functionality:

Basic Time Clock Tests

  • testCreateTimeClockEntry - Validates time clock entry creation and worker relationships
  • testClockInClockOut - Tests clock in/out functionality and hours calculation

Weekly Hours Calculation Tests

  • 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

Edge Cases Tests

  • testMultipleWorkersTimeTracking - Ensures independent tracking for multiple workers
  • testIncompleteTimeEntry - Handles active/incomplete time entries properly

✅ Harvest Calendar Tests (HarvestCalendarTests.swift)

Comprehensive harvest calendar functionality with date range validation:

Harvest Quality and Calculation Tests

  • 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)

Harvest Calculator Tests

  • 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

Week Number and Date Range Tests

  • 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

Performance Tests

  • testHarvestCalculationPerformance - Ensures calculations are fast enough for real-time use
  • testHarvestQualityPerformance - Validates performance of quality lookups

✅ Clean Architecture Time Tracking Tests (CleanArchitectureTimeTrackingTests.swift)

Tests for the new clean architecture implementation:

Domain Entity Tests

  • testTimeTrackingEntityBusinessRules - Tests business rules for overtime detection
  • testTimeTrackingEntityValidation - Validates entity consistency and validation rules
  • testFormattedHoursCalculation - Tests time formatting (HH:MM format)

Use Case Tests - Clock In/Out

  • 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

Use Case Tests - Reporting

  • testWeeklyReportGeneration - Tests weekly time report generation
  • testWeeklyReportWithNoOvertime - Tests reports with exactly 40 hours
  • testPayrollDataCalculation - Tests payroll calculations for pay periods

Controller and Presenter Tests

  • 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

Integration Tests

  • testDependencyInjectionContainer - Tests dependency injection setup
  • testCoreDataGatewayMapping - Tests Core Data gateway functionality

✅ Device Detection and Adaptive UI Tests (DeviceDetectionAndAdaptiveUITests.swift)

Tests for iPad Pro features and responsive design:

Device Detection Tests

  • 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

Size Class and Responsive Design Tests

  • 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

Dashboard and Layout Tests

  • 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

Accessibility Tests

  • testAccessibilityScaling - Tests scaling for different content size categories
  • testMinimumTouchTargetSize - Tests minimum 44pt touch target enforcement

Performance and Edge Case Tests

  • 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

📊 Test Summary

  • 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

🚀 Running Specific Test Suites

# 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/DeviceDetectionAndAdaptiveUITests

Documentation

For comprehensive user documentation, please see:

About

Software for managing organic and conventional farming practices for small farms

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages