# brokoline/ocutuneapplication architecture

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

- Interactive diagram: https://gitdiagram.com/brokoline/ocutuneapplication
- Repository: https://github.com/brokoline/ocutuneapplication

## Overview

##### Project type and purpose
- This is a cross-platform Flutter application (“ocutune_light_logger”) for logging and analyzing users’ light exposure, managing patient/clinician messaging, and interacting with a BLE sensor. It bundles platform integrations for Android, iOS, Linux, macOS, Windows, and Web, uses a TensorFlow Lite model for light classification, and persists data locally with offline sync to a remote API.

##### File structure
- Top-level platform folders (android, ios, linux, macos, windows, web) contain native build and configuration.
- lib/ holds the Dart application:
- models/ – data representations
- controller/ – business-logic controllers managing state and coordinating services
- viewmodel/ – view models for MVVM binding (clinician, patient)
- services/ – abstractions over BLE, REST API, offline storage, classifier, error logging, sync scheduler
- screens/ & widgets/ – UI layer, organized by user role (customer, patient, clinician), registration flows, messaging, dashboards
- pubspec.yaml defines dependencies (flutter_tflite, HTTP, BLE libs, state-management if any)

##### README
- Confirms it’s a Flutter starter for a diploma project. No explicit architecture section—architecture is implied by the directory layout.

##### Key pointers
- Be exhaustive: include every major controller, service, and external dependency.
- Asynchronous flows: sensor polling, offline sync, message fetch.
- Assets (classifier model & matrices) feeding into LightClassifierService.
- With brief notes (e.g., “platform channel for BLE”, “periodic sync job”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        CR["Customer Registration Screens"]:::ui
        PDS["Patient Dashboard Screen"]:::ui
        CIS["Clinician Inbox Screen"]:::ui
    end

    %% Logic Layer
    subgraph "State-Logic Layer"
        direction TB
        BLEC["BleController"]:::logic
        CHRC["ChronotypeController"]:::logic
        INBC["InboxController"]:::logic
        LDLC["LightDataController"]:::logic
        BSV["BleSensorViewModel"]:::logic
        PDV["PatientDetailViewModel"]:::logic
    end

    %% Service Layer
    subgraph "Service Layer"
        direction TB
        BPS["BlePollingService"]:::service
        BLH["BleLifecycleHandler"]:::service
        API["ApiService"]:::service
        CDS["CustomerDataService"]:::service
        MS["MessageService"]:::service
        OSS["OfflineStorageService"]:::service
        LCS["LightClassifierService"]:::service
        SS["SyncScheduler"]:::service
        REL["RemoteErrorLogger"]:::service
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        LDM["LightDataModel"]:::data
        AM["ActivityModel"]:::data
        PM["PatientModel"]:::data
        MAM["MessagesModel"]:::data
        LocalDB["Local Database/Cache"]:::data
    end

    %% Assets
    subgraph "Assets"
        direction TB
        TFL["classifier.tflite"]:::asset
        MAT["Spectral Matrices"]:::asset
    end

    %% External Systems
    subgraph "External Systems"
        direction TB
        BLE["BLE Sensor Device"]:::external
        REST["Remote REST API"]:::external
        TFLE["TFLite Engine"]:::external
    end

    %% Relationships
    CR -->|uses| CHRC
    PDS -->|binds to| BSV
    CIS -->|binds to| PDV

    BLEC -->|calls| BPS
    CHRC -->|calls| LCS
    INBC -->|calls| MS
    LDLC -->|calls| API

    BSV -->|invokes| BLEC
    PDV -->|invokes| INBC

    BPS -->|polls| BLE
    BLH -->|manages| BLE
    API -->|requests| REST
    CDS -->|fetches| REST
    MS -->|posts/fetches| REST
    OSS -->|reads/writes| LocalDB
    SS -->|syncs| LocalDB
    SS -->|syncs| REST
    REL -->|reports| REST
    LCS -->|loads model| TFL
    LCS -->|executes on| TFLE

    CHRC -->|stores| OSS
    BLEC -->|stores| OSS
    INBC -->|stores| OSS
    LDLC -->|stores| OSS

    OSS -->|provides| LDM
    OSS -->|provides| AM
    OSS -->|provides| PM
    OSS -->|provides| MAM

    %% Click Events
    click CR "https://github.com/brokoline/ocutuneapplication/tree/main/lib/screens/customer/register"
    click PDS "https://github.com/brokoline/ocutuneapplication/blob/main/lib/screens/patient/patient_dashboard_screen.dart"
    click CIS "https://github.com/brokoline/ocutuneapplication/blob/main/lib/screens/clinician/messages/clinician_inbox_screen.dart"
    click BLEC "https://github.com/brokoline/ocutuneapplication/blob/main/lib/controller/ble_controller.dart"
    click CHRC "https://github.com/brokoline/ocutuneapplication/blob/main/lib/controller/chronotype_controller.dart"
    click INBC "https://github.com/brokoline/ocutuneapplication/blob/main/lib/controller/inbox_controller.dart"
    click LDLC "https://github.com/brokoline/ocutuneapplication/blob/main/lib/controller/light_data_controller.dart"
    click BSV "https://github.com/brokoline/ocutuneapplication/blob/main/lib/viewmodel/patient/ble_sensor_viewmodel.dart"
    click PDV "https://github.com/brokoline/ocutuneapplication/blob/main/lib/viewmodel/clinician/patient_detail_viewmodel.dart"
    click BPS "https://github.com/brokoline/ocutuneapplication/blob/main/lib/services/services/ble_polling_service.dart"
    click BLH "https://github.com/brokoline/ocutuneapplication/blob/main/lib/services/ble_lifecycle_handler.dart"
    click API "https://github.com/brokoline/ocutuneapplication/blob/main/lib/services/services/api_services.dart"
    click CDS "https://github.com/brokoline/ocutuneapplication/blob/main/lib/services/services/customer_data_service.dart"
    click MS "https://github.com/brokoline/ocutuneapplication/blob/main/lib/services/services/message_service.dart"
    click OSS "https://github.com/brokoline/ocutuneapplication/blob/main/lib/services/services/offline_storage_service.dart"
    click LCS "https://github.com/brokoline/ocutuneapplication/blob/main/lib/services/services/light_classifier_service.dart"
    click SS "https://github.com/brokoline/ocutuneapplication/blob/main/lib/services/sync_scheduler.dart"
    click REL "https://github.com/brokoline/ocutuneapplication/blob/main/lib/services/remote_error_logger.dart"
    click LDM "https://github.com/brokoline/ocutuneapplication/blob/main/lib/models/light_data_model.dart"
    click AM "https://github.com/brokoline/ocutuneapplication/blob/main/lib/models/activity_model.dart"
    click PM "https://github.com/brokoline/ocutuneapplication/blob/main/lib/models/patient_model.dart"
    click MAM "https://github.com/brokoline/ocutuneapplication/blob/main/lib/models/messages_model.dart"
    click TFL "https://github.com/brokoline/ocutuneapplication/blob/main/assets/classifier.tflite"
    click MAT "https://github.com/brokoline/ocutuneapplication/tree/main/assets/matrices"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
    classDef logic fill:#E6F4EA,stroke:#22863A,color:#22863A;
    classDef service fill:#FFF5B1,stroke:#DBAB09,color:#735C0F;
    classDef data fill:#FFF0F3,stroke:#D73A49,color:#D73A49;
    classDef external fill:#F6F8FA,stroke:#6A737D,color:#6A737D;
    classDef asset fill:#F3E8FF,stroke:#6F42C1,color:#6F42C1;
```
