# usernameyann/sunflower-land-widget-for-ios architecture

> Architecture diagram of the GitHub repository usernameyann/sunflower-land-widget-for-ios, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/usernameyann/sunflower-land-widget-for-ios
- Repository: https://github.com/usernameyann/sunflower-land-widget-for-ios

## Overview

##### Project type and purpose
- This is a small client-side iOS widget implemented in Scriptable (JavaScript).
- Its purpose is to fetch a user’s Sunflower Land farm data from the game’s public API, render the status of crops, trees, and animals on the iPhone home screen, and optionally schedule local notifications when items become ready.

##### File structure
- Top-level:
- LICENSE
- README.md
- SFL-widget.js (core widget logic)
- SFL-widget+Notif.js (widget + notification scheduling)
- No “backend” code here—this is purely a front-end widget script that runs inside the Scriptable app.
- Configuration is minimal: the user sets a FARM_ID constant on line 8 of the script.
- No build scripts or deployment artifacts—installation is manual via Scriptable.

##### Detailed callouts
- FARM_ID injection point in the script.
- How user settings (in iOS Settings → Notifications → Scriptable) impact the notification flow.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Platform Layer
    subgraph "iOS Platform"
        direction TB
        iOSHome["iOS Home Screen / SpringBoard"]:::platform
        UserTap["User Tap Widget"]:::platform
    end

    %% Scriptable Layer
    subgraph "Scriptable App (Widget Engine)"
        direction TB
        ScriptableApp["Scriptable App"]:::script
        SFLWidget["SFL-widget Script"]:::script
        SFLWidgetNotif["SFL-widget+Notif Script"]:::script
    end

    %% External Service
    subgraph "External Service"
        direction TB
        SunflowerAPI["Sunflower Land Public API"]:::external
    end

    %% Notification Layer
    subgraph "Notification Subsystem"
        direction TB
        NotificationCenter["iOS Notification Center"]:::notification
    end

    %% Documentation
    subgraph "Project Documentation"
        direction TB
        README["README.md"]:::docs
        LICENSE["LICENSE"]:::docs
    end

    %% Data Flow and Interactions
    iOSHome -->|"schedule refresh"| ScriptableApp
    UserTap -->|"force refresh"| ScriptableApp

    ScriptableApp --> SFLWidget
    ScriptableApp --> SFLWidgetNotif

    SFLWidget -->|"read FARM_ID constant"| SFLWidget
    SFLWidgetNotif -->|"read FARM_ID constant"| SFLWidgetNotif

    SFLWidget -->|"HTTP GET /farm/{FARM_ID}"| SunflowerAPI
    SFLWidgetNotif -->|"HTTP GET /farm/{FARM_ID}"| SunflowerAPI

    SunflowerAPI -->|"JSON farm data"| SFLWidget
    SunflowerAPI -->|"JSON farm data"| SFLWidgetNotif

    SFLWidget -->|"parse JSON & render UI"| ScriptableApp
    SFLWidgetNotif -->|"parse JSON & render UI"| ScriptableApp

    SFLWidgetNotif -->|"scheduleNotification()"| NotificationCenter
    NotificationCenter -->|"trigger alert at ready time"| UserTap

    %% Documentation Links
    click SFLWidget "https://github.com/usernameyann/sunflower-land-widget-for-ios/blob/main/SFL-widget.js"
    click SFLWidgetNotif "https://github.com/usernameyann/sunflower-land-widget-for-ios/blob/main/SFL-widget+Notif.js"
    click README "https://github.com/usernameyann/sunflower-land-widget-for-ios/blob/main/README.md"
    click LICENSE "https://github.com/usernameyann/sunflower-land-widget-for-ios/tree/main/LICENSE"

    %% Styles
    classDef platform fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef script fill:#90EE90,stroke:#333,stroke-width:1px
    classDef external fill:#FFD580,stroke:#333,stroke-width:1px
    classDef notification fill:#FFC0CB,stroke:#333,stroke-width:1px
    classDef docs fill:#D3D3D3,stroke:#333,stroke-width:1px
```
