# kevinboone/mowf architecture

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

- Interactive diagram: https://gitdiagram.com/kevinboone/mowf
- Repository: https://github.com/kevinboone/mowf

## Overview

##### Project Type & Purpose
- This is a Garmin Connect IQ watch face application designed for smart watches with OLED displays. Its goal is to display the time, date, battery charge, and (in high power mode) heart rate while minimizing power consumption and reducing screen burn-in.
- Unlike a full-stack application, this project is an embedded application running on wearable hardware. The challenges here focus on battery management and display strategy (switching between low-power and high-power modes).

##### Analyzing the File Structure
- Top-Level Files:
- .gitignore: Git configuration.
- README.md: Contains project description, design considerations, and build instructions.
- build.sh: Likely a build script that wraps commands.
- manifest.xml, monkey.jungle: Important for Connect IQ build configurations and defining the app’s structure.
- mowf.prg: The final compiled binary installed onto the device.
- Resources Folder:
- Source Folder:
- Contains multiple .mc files (Monkey-C source code):
- App.mc: Likely the entry point for the application.
- DisplayHelper.mc: Provides utility functions for drawing.
- Displayer.mc: Possibly a base module or interface for display behavior.
- HPDisplayer.mc and LPDisplayer.mc: Specialized modules for high power and low power display modes.
- View.mc: Manages the visual layout.
- This structure hints at a separation of concerns with respect to display logic and different power modes.

a. Main Components:
- Build/Compilation Process:
- Build Script (build.sh) invoking the Monkey-C compiler with configuration files (manifest.xml, monkey.jungle) to produce the final binary (mowf.prg).
- Core Application:
- App Component (App.mc) as the main application loop.
- Modules, split into:
‣ HP (High Power) Displayer (HPDisplayer.mc)
‣ LP (Low Power) Displayer (LPDisplayer.mc)
‣ Common Display interfaces/utilities (Displayer.mc and DisplayHelper.mc).
- View (View.mc): Manages layouting of digital watch face components (time, date, battery, heart rate).
- Resources:
- Assets like bitmaps, images, and strings (resources/ directory) are integrated by the display components.
- Hardware/Runtime Environment:
- Garmin Smart Watch with OLED display that runs mowf.prg.
- Optional simulator environment, as noted in the README.

b. Relationships & Interactions:
- The Build Process component uses configuration files and source code to produce a binary.
- The App Component initializes and manages the display mode switching (invoking either high power or low power display routines).
- DisplayHelper and Displayer modules provide abstraction and utilities to simplify drawing operations.
- View gathers data (time, date, battery, heart rate) and instructs the appropriate displayer to render on screen.
- Resources feed into the view and display helpers to supply layout elements, text, and images.
- The compiled binary (mowf.prg) is then installed on the Garmin device, which interacts directly with the hardware (via Connect IQ APIs).

c. Architectural Patterns & Design Principles:
- Separation of concerns: Dividing presentation (View, Display Modules) from application logic (App.mc) and resource management.
- Mode-based behavior: Different strategies for high-power vs. low-power rendering are encapsulated in dedicated modules to minimize code complexity.
- Modularity: Each source file covers specific functionality (helper functions, different display modes), making the system extendable and maintainable.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Build Process"
        buildScript["Build Script (build.sh)"]:::build
        manifest["Manifest (manifest.xml)"]:::build
        monkeyJungle["Monkey Jungle (monkey.jungle)"]:::build
    end
    buildScript -->|"compiles_to"| mowfBinary["Compiled Binary (mowf.prg)"]:::build
    manifest -->|"compiles_to"| mowfBinary
    monkeyJungle -->|"compiles_to"| mowfBinary

    subgraph "Application Core"
        appCore["App (Core Application) (App.mc)"]:::core
    end

    subgraph "Display Modules"
        viewNode["View (Layout & Rendering) (View.mc)"]:::display
        hpDisplayer["HP Displayer (HPDisplayer.mc)"]:::display
        lpDisplayer["LP Displayer (LPDisplayer.mc)"]:::display
        displayer["Display Interface (Displayer.mc)"]:::display
        displayHelper["Display Helper (DisplayHelper.mc)"]:::display
    end

    resources["Resource Assets (resources)"]:::resource
    hardware["Garmin Smart Watch/Simulator"]:::hardware

    appCore -->|"initializes"| viewNode
    viewNode -->|"if_high_power"| hpDisplayer
    viewNode -->|"if_low_power"| lpDisplayer
    hpDisplayer -->|"utilizes"| displayer
    hpDisplayer -->|"assists"| displayHelper
    lpDisplayer -->|"utilizes"| displayer
    lpDisplayer -->|"assists"| displayHelper
    resources -->|"provides_assets"| viewNode
    resources -->|"provides_assets"| displayHelper
    mowfBinary -->|"deployed_on"| hardware

    click buildScript "https://github.com/kevinboone/mowf/blob/main/build.sh"
    click manifest "https://github.com/kevinboone/mowf/blob/main/manifest.xml"
    click monkeyJungle "https://github.com/kevinboone/mowf/blob/main/monkey.jungle"
    click mowfBinary "https://github.com/kevinboone/mowf/blob/main/mowf.prg"
    click appCore "https://github.com/kevinboone/mowf/blob/main/source/App.mc"
    click displayer "https://github.com/kevinboone/mowf/blob/main/source/Displayer.mc"
    click displayHelper "https://github.com/kevinboone/mowf/blob/main/source/DisplayHelper.mc"
    click hpDisplayer "https://github.com/kevinboone/mowf/blob/main/source/HPDisplayer.mc"
    click lpDisplayer "https://github.com/kevinboone/mowf/blob/main/source/LPDisplayer.mc"
    click viewNode "https://github.com/kevinboone/mowf/blob/main/source/View.mc"
    click resources "https://github.com/kevinboone/mowf/tree/main/resources"

    class build buildScript,manifest,monkeyJungle,mowfBinary
    class core appCore
    class display viewNode,hpDisplayer,lpDisplayer,displayer,displayHelper
    class resource resources
    class hardware hardware

    classDef build fill:#ffcc80,stroke:#e65100,stroke-width:2px;
    classDef core fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef display fill:#d1c4e9,stroke:#4a148c,stroke-width:2px;
    classDef resource fill:#c8e6c9,stroke:#1b5e20,stroke-width:2px;
    classDef hardware fill:#ffe082,stroke:#f57f17,stroke-width:2px;
```
