# ademnea/farmer_app architecture

> Architecture diagram of the GitHub repository ademnea/farmer_app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ademnea/farmer_app
- Repository: https://github.com/ademnea/farmer_app

## Overview

##### Project type and purpose
- This is a cross-platform Flutter mobile/web/desktop application called “Farmer App.”
- Its primary purpose is to help beekeepers monitor hives: count bees via video/ML, track hive conditions (humidity, temperature, weight), fetch weather data, send notifications, and offer advisory/analytics screens.

##### File structure
- Top-level platform folders: android/, ios/, macos/, linux/, windows/, web/
- Core application code under lib/:
- UI screens (login.dart, home.dart, bee_monitoring_screen.dart, etc.)
- Services layer (lib/Services): auth, weather, local storage (Hive), notification, bee_analysis
- ML and video processing (lib/bee_counter, assets/models/*.tflite)
- Analytics engines (lib/analytics/foraging_analysis, bee_advisory)
- Data/API adapters (lib/api/*.dart, server_video_service.dart)
- Shared components & utils (lib/components, lib/utils)
- Assets (images, Lottie animations, fonts), docs, CI/CD pipelines (.github/workflows), tests

##### README
- Boilerplate Flutter README; confirms Flutter stack and points to CI/CD workflows.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"  
        direction TB
        Main["main.dart"]:::presentation
        Login["login.dart"]:::presentation
        Home["home.dart"]:::presentation
        BeeMonitorScreen["bee_monitoring_screen.dart"]:::presentation
        BeeVideoAnalysisScreen["bee_video_analysis_screen.dart"]:::presentation
        AdvisoryScreen["bee_advisory_screen.dart"]:::presentation
        ForagingAnalysisScreen["foraging_analysis_screen.dart"]:::presentation
        Components["components/"]:::presentation
    end

    %% Service Layer
    subgraph "Service Layer"  
        direction TB
        AuthService["auth_services.dart"]:::service
        WeatherService["weather_service.dart"]:::service
        HiveService["hive_service.dart"]:::service
        BeeAnalysisService["bee_analysis_service.dart"]:::service
        NotificationService["notifi_service.dart"]:::service
        LocalStorageService["local_storage_service.dart"]:::service
    end

    %% Data Layer - Local DB & Storage
    subgraph "Data Layer - Local"  
        direction TB
        BeeCountDB["bee_count_database.dart"]:::data
        ForagingDB["time_based_return_rate_database.dart"]:::data
        AdvisoryDB["bee_advisory_database.dart"]:::data
        HiveModels["assets/models/"]:::data
    end

    %% Data Layer - ML & Video
    subgraph "Data Layer - ML & Video"  
        direction TB
        AutoVideoProcessing["auto_video_processing_service.dart"]:::data
        BackgroundVideoProcessing["background_video_processing_service.dart"]:::data
        VideoAnalyzer["bee_video_analyzer.dart"]:::data
        ServerVideoService["server_video_service.dart"]:::data
        VideoResult["bee_video_analysis_result.dart"]:::data
    end

    %% Data Layer - Remote API
    subgraph "Data Layer - Remote API"  
        direction TB
        HiveMonitoringAPI["hive_monitoring_api.dart"]:::data
        ServerVideoAPI["server_video_service.dart"]:::data
    end

    %% Analytics Engines
    subgraph "Analytics Engines"
        direction TB
        ForagingEngine["foraging_analysis_engine.dart"]:::service
        AdvisoryEngine["bee_advisory_engine.dart"]:::service
    end

    %% Notification Subsystem
    subgraph "Notification Subsystem"
        direction TB
        NotificationCore["notification_service.dart"]:::service
        HiveDataNotif["hive_data_service.dart"]:::service
        WeatherDataNotif["weather_data_service.dart"]:::service
        NotificationScreen["notification_screen.dart"]:::presentation
    end

    %% Shared Utilities
    SharedUtils["app_utils.dart"]:::service

    %% Platform Integration
    subgraph "Platform Integration"
        direction TB
        Android["android/"]:::platform
        iOS["ios/"]:::platform
        Web["web/"]:::platform
        Linux["linux/"]:::platform
        MacOS["macos/"]:::platform
        Windows["windows/"]:::platform
    end

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"  
        direction TB
        CIWorkflow1["flutter_ci_cd.yml"]:::ci
        CIWorkflow2["release.yml"]:::ci
        CI_Docs["ci_cd_pipeline.md"]:::ci
    end

    %% Relationships
    Main -->|uses| AuthService
    Main -->|uses| HiveService
    Main -->|uses| BeeAnalysisService
    Main -->|uses| WeatherService
    Main -->|navigates to| BeeMonitorScreen
    BeeMonitorScreen -->|invokes| AutoVideoProcessing
    BeeMonitorScreen -->|invokes| BackgroundVideoProcessing
    BeeVideoAnalysisScreen -->|requests| VideoAnalyzer
    BeeVideoAnalysisScreen -->|requests| ServerVideoService
    AdvisoryScreen -->|requests| AdvisoryEngine
    ForagingAnalysisScreen -->|requests| ForagingEngine
    AuthService -->|reads/writes| LocalStorageService
    HiveService -->|reads/writes| BeeCountDB
    HiveService -->|reads/writes| ForagingDB
    HiveService -->|reads/writes| AdvisoryDB
    BeeAnalysisService -->|uses model| HiveModels
    WeatherService -->|HTTP| HiveMonitoringAPI
    ServerVideoService -->|socket| ServerVideoAPI
    NotificationService -->|triggers| NotificationCore
    NotificationCore -->|reads| HiveDataNotif
    NotificationCore -->|reads| WeatherDataNotif
    NotificationService -->|shows| NotificationScreen
    SharedUtils -->|used by| AuthService
    SharedUtils -->|used by| WeatherService
    SharedUtils -->|used by| BeeAnalysisService
    SharedUtils -->|used by| NotificationService
    Android -->|runs| Main
    iOS -->|runs| Main
    Web -->|runs| Main
    Linux -->|runs| Main
    MacOS -->|runs| Main
    Windows -->|runs| Main
    CIWorkflow1 -->|triggers build| Android
    CIWorkflow1 -->|triggers build| iOS
    CIWorkflow1 -->|triggers build| Web
    CIWorkflow2 -->|publishes| Android
    CIWorkflow2 -->|publishes| iOS
    CI_Docs -->|documents| CIWorkflow1

    %% Click Events
    click Main "https://github.com/ademnea/farmer_app/blob/main/lib/main.dart"
    click Login "https://github.com/ademnea/farmer_app/blob/main/lib/login.dart"
    click Home "https://github.com/ademnea/farmer_app/blob/main/lib/home.dart"
    click BeeMonitorScreen "https://github.com/ademnea/farmer_app/blob/main/lib/bee_counter/bee_monitoring_screen.dart"
    click BeeVideoAnalysisScreen "https://github.com/ademnea/farmer_app/blob/main/lib/bee_counter/bee_video_analysis_screen.dart"
    click AdvisoryScreen "https://github.com/ademnea/farmer_app/blob/main/lib/bee_advisory/bee_advisory_screen.dart"
    click ForagingAnalysisScreen "https://github.com/ademnea/farmer_app/blob/main/lib/analytics/foraging_analysis/foraging_analysis_screen.dart"
    click Components "https://github.com/ademnea/farmer_app/tree/main/lib/components/"
    click AuthService "https://github.com/ademnea/farmer_app/blob/main/lib/Services/auth_services.dart"
    click WeatherService "https://github.com/ademnea/farmer_app/blob/main/lib/Services/weather_service.dart"
    click HiveService "https://github.com/ademnea/farmer_app/blob/main/lib/Services/hive_service.dart"
    click BeeAnalysisService "https://github.com/ademnea/farmer_app/blob/main/lib/Services/bee_analysis_service.dart"
    click NotificationService "https://github.com/ademnea/farmer_app/blob/main/lib/Services/notifi_service.dart"
    click LocalStorageService "https://github.com/ademnea/farmer_app/blob/main/lib/Services/local_storage_service.dart"
    click BeeCountDB "https://github.com/ademnea/farmer_app/blob/main/lib/bee_counter/bee_count_database.dart"
    click ForagingDB "https://github.com/ademnea/farmer_app/blob/main/lib/analytics/foraging_analysis/time_based_return_rate_database.dart"
    click AdvisoryDB "https://github.com/ademnea/farmer_app/blob/main/lib/bee_advisory/bee_advisory_database.dart"
    click HiveModels "https://github.com/ademnea/farmer_app/tree/main/assets/models/"
    classDef presentation fill:#D0E8FF,stroke:#003366,color:#003366
    classDef service fill:#DFF2BF,stroke:#4F8A10,color:#4F8A10
    classDef data fill:#FFD2D2,stroke:#D8000C,color:#D8000C
    classDef platform fill:#F2F2F2,stroke:#999999,color:#666666
    classDef ci fill:#E8E8E8,stroke-dasharray: 5 5,stroke:#666666,color:#333333
```
