# popaspinka/popkastudio architecture

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

- Interactive diagram: https://gitdiagram.com/popaspinka/popkastudio
- Repository: https://github.com/popaspinka/popkastudio

## Overview

PopkaStudio is a browser-based visual editor for ESP32 watch and display interfaces. Users assemble screens from layers, link screens, preview them using the board’s rendering code, then load or live-update firmware on a board. The repository also includes the watch firmware and a companion iPhone app that exchanges weather, time, battery, and step data over Bluetooth. The source excerpts show editor orchestration and selected model/rendering links; broader firmware capabilities are retained from the README, but their internal wiring is not inferred.

Main entry points: [`studio/web/js/main.js`](https://github.com/popaspinka/popkastudio/blob/main/studio/web/js/main.js) (Editor entry), [`studio/web/js/engine.js`](https://github.com/popaspinka/popkastudio/blob/main/studio/web/js/engine.js) (Web render engine), [`ios/PopkaWatch/Model/AppModel.swift`](https://github.com/popaspinka/popkastudio/blob/main/ios/PopkaWatch/Model/AppModel.swift) (Watch and weather model), [`ios/PopkaWatch/App/PopkaWatchApp.swift`](https://github.com/popaspinka/popkastudio/blob/main/ios/PopkaWatch/App/PopkaWatchApp.swift) (iPhone app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_editor["Browser editor"]
  node_helper["Studio helper<br/>[studio.py]"]
  node_state["Project state<br/>[state.js]"]
  node_screen["Board profile<br/>[screen.js]"]
  node_panels["Editor panels<br/>[panels.js]"]
  node_shade["Quick settings editor<br/>[shade.js]"]
  node_stage["Screen map<br/>[stage.js]"]
  node_engine["Web render engine<br/>[engine.js]"]
  node_previews["Layer previews<br/>[previews.js]"]
  node_board["Board connection<br/>[board.js]"]
  node_live["Live editing<br/>[live.js]"]
  node_start["Project startup<br/>[start.js]"]
  node_entry["Editor entry<br/>[main.js]"]
  node_assets["Asset generation<br/>[halo_assets.py]"]
end

subgraph group_device["Watch firmware"]
  node_firmware["Watch screens and apps"]
  node_flow["Dot flow face<br/>[flow.h]"]
  node_fonts["Pixel fonts<br/>[pixelfonts.h]"]
end

subgraph group_halo["Halo rendering"]
  node_halo["Halo drawing<br/>[halo_draw.cpp]"]
  node_haloapi["Halo API<br/>[Halo.h]"]
end

subgraph group_iphone["iPhone companion"]
  node_iosapp["iPhone app"]
  node_model["Watch and weather model<br/>[AppModel.swift]"]
  node_watchlink["Bluetooth link<br/>[WatchLink.swift]"]
  node_weather["Weather service<br/>[OpenMeteo.swift]"]
  node_home["Home screen<br/>[HomeView.swift]"]
  node_drawing["Watch drawing<br/>[WatchDrawing.swift]"]
end

node_user(("Designer"))
node_watch(("ESP32 watch"))
node_weatherapi(("Open-Meteo"))

node_user -->|"edits project"| node_entry
node_entry -->|"loads state"| node_state
node_entry -->|"starts map"| node_stage
node_entry -->|"renders panels"| node_panels
node_entry -->|"initializes board"| node_board
node_entry -->|"starts live mode"| node_live
node_entry -->|"runs engines"| node_engine
node_engine -->|"reads font scale"| node_state
node_engine -->|"uses board dimensions"| node_screen
node_previews -->|"renders previews"| node_engine
node_panels -->|"reads project"| node_state
node_panels -->|"uses settings editor"| node_shade
node_user -->|"loads firmware"| node_helper
node_helper -->|"generates assets"| node_assets
node_engine -->|"runs board code"| node_firmware
node_engine -->|"renders with"| node_halo
node_assets -.->|"builds font assets"| node_fonts
node_user -->|"uses device"| node_watch
node_watch -->|"runs screens"| node_firmware
node_firmware -.->|"includes dot flow"| node_flow
node_iosapp -->|"creates model"| node_model
node_iosapp -->|"creates link"| node_watchlink
node_model -->|"exchanges reports"| node_watchlink
node_model -->|"fetches forecast"| node_weather
node_weather -.->|"requests forecast"| node_weatherapi
node_iosapp -->|"shows home screen"| node_home
node_home -->|"displays watch data"| node_model
node_home -->|"draws watch"| node_drawing
node_watchlink -->|"sends and receives"| node_watch

click node_helper "https://github.com/popaspinka/popkastudio/blob/main/studio/studio.py"
click node_state "https://github.com/popaspinka/popkastudio/blob/main/studio/web/js/state.js"
click node_screen "https://github.com/popaspinka/popkastudio/blob/main/studio/web/js/screen.js"
click node_panels "https://github.com/popaspinka/popkastudio/blob/main/studio/web/js/panels.js"
click node_shade "https://github.com/popaspinka/popkastudio/blob/main/studio/web/js/shade.js"
click node_stage "https://github.com/popaspinka/popkastudio/blob/main/studio/web/js/stage.js"
click node_engine "https://github.com/popaspinka/popkastudio/blob/main/studio/web/js/engine.js"
click node_previews "https://github.com/popaspinka/popkastudio/blob/main/studio/web/js/previews.js"
click node_board "https://github.com/popaspinka/popkastudio/blob/main/studio/web/js/board.js"
click node_live "https://github.com/popaspinka/popkastudio/blob/main/studio/web/js/live.js"
click node_start "https://github.com/popaspinka/popkastudio/blob/main/studio/web/js/start.js"
click node_entry "https://github.com/popaspinka/popkastudio/blob/main/studio/web/js/main.js"
click node_assets "https://github.com/popaspinka/popkastudio/blob/main/tools/halo_assets.py"
click node_firmware "https://github.com/popaspinka/popkastudio/tree/main/firmware/PopkaWatch"
click node_flow "https://github.com/popaspinka/popkastudio/blob/main/firmware/PopkaWatch/flow.h"
click node_fonts "https://github.com/popaspinka/popkastudio/blob/main/firmware/PopkaWatch/pixelfonts.h"
click node_halo "https://github.com/popaspinka/popkastudio/blob/main/lib/Halo/src/halo_draw.cpp"
click node_haloapi "https://github.com/popaspinka/popkastudio/blob/main/lib/Halo/src/Halo.h"
click node_iosapp "https://github.com/popaspinka/popkastudio/blob/main/ios/PopkaWatch/App/PopkaWatchApp.swift"
click node_model "https://github.com/popaspinka/popkastudio/blob/main/ios/PopkaWatch/Model/AppModel.swift"
click node_watchlink "https://github.com/popaspinka/popkastudio/blob/main/ios/PopkaWatch/Model/WatchLink.swift"
click node_weather "https://github.com/popaspinka/popkastudio/blob/main/ios/PopkaWatch/Model/OpenMeteo.swift"
click node_home "https://github.com/popaspinka/popkastudio/blob/main/ios/PopkaWatch/Views/HomeView.swift"
click node_drawing "https://github.com/popaspinka/popkastudio/blob/main/ios/PopkaWatch/Views/WatchDrawing.swift"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_helper,node_state,node_screen,node_panels,node_shade,node_stage,node_engine,node_previews,node_board,node_live,node_start,node_entry,node_assets toneBlue
class node_firmware,node_flow,node_fonts toneAmber
class node_halo,node_haloapi toneMint
class node_iosapp,node_model,node_watchlink,node_weather,node_home,node_drawing toneRose
class node_user,node_watch,node_weatherapi toneIndigo
```

## Components

### Browser editor

- [Studio helper](https://github.com/popaspinka/popkastudio/blob/main/studio/studio.py): `studio/studio.py`
- [Project state](https://github.com/popaspinka/popkastudio/blob/main/studio/web/js/state.js): `studio/web/js/state.js`
- [Board profile](https://github.com/popaspinka/popkastudio/blob/main/studio/web/js/screen.js): `studio/web/js/screen.js`
- [Editor panels](https://github.com/popaspinka/popkastudio/blob/main/studio/web/js/panels.js): `studio/web/js/panels.js`
- [Quick settings editor](https://github.com/popaspinka/popkastudio/blob/main/studio/web/js/shade.js): `studio/web/js/shade.js`
- [Screen map](https://github.com/popaspinka/popkastudio/blob/main/studio/web/js/stage.js): `studio/web/js/stage.js`
- [Web render engine](https://github.com/popaspinka/popkastudio/blob/main/studio/web/js/engine.js): `studio/web/js/engine.js`
- [Layer previews](https://github.com/popaspinka/popkastudio/blob/main/studio/web/js/previews.js): `studio/web/js/previews.js`
- [Board connection](https://github.com/popaspinka/popkastudio/blob/main/studio/web/js/board.js): `studio/web/js/board.js`
- [Live editing](https://github.com/popaspinka/popkastudio/blob/main/studio/web/js/live.js): `studio/web/js/live.js`
- [Project startup](https://github.com/popaspinka/popkastudio/blob/main/studio/web/js/start.js): `studio/web/js/start.js`
- [Editor entry](https://github.com/popaspinka/popkastudio/blob/main/studio/web/js/main.js): `studio/web/js/main.js`
- [Asset generation](https://github.com/popaspinka/popkastudio/blob/main/tools/halo_assets.py): `tools/halo_assets.py`

### Watch firmware

- [Watch screens and apps](https://github.com/popaspinka/popkastudio/tree/main/firmware/PopkaWatch): `firmware/PopkaWatch`
- [Dot flow face](https://github.com/popaspinka/popkastudio/blob/main/firmware/PopkaWatch/flow.h): `firmware/PopkaWatch/flow.h`
- [Pixel fonts](https://github.com/popaspinka/popkastudio/blob/main/firmware/PopkaWatch/pixelfonts.h): `firmware/PopkaWatch/pixelfonts.h`

### Halo rendering

- [Halo drawing](https://github.com/popaspinka/popkastudio/blob/main/lib/Halo/src/halo_draw.cpp): `lib/Halo/src/halo_draw.cpp`
- [Halo API](https://github.com/popaspinka/popkastudio/blob/main/lib/Halo/src/Halo.h): `lib/Halo/src/Halo.h`

### iPhone companion

- [iPhone app](https://github.com/popaspinka/popkastudio/blob/main/ios/PopkaWatch/App/PopkaWatchApp.swift): `ios/PopkaWatch/App/PopkaWatchApp.swift`
- [Watch and weather model](https://github.com/popaspinka/popkastudio/blob/main/ios/PopkaWatch/Model/AppModel.swift): `ios/PopkaWatch/Model/AppModel.swift`
- [Bluetooth link](https://github.com/popaspinka/popkastudio/blob/main/ios/PopkaWatch/Model/WatchLink.swift): `ios/PopkaWatch/Model/WatchLink.swift`
- [Weather service](https://github.com/popaspinka/popkastudio/blob/main/ios/PopkaWatch/Model/OpenMeteo.swift): `ios/PopkaWatch/Model/OpenMeteo.swift`
- [Home screen](https://github.com/popaspinka/popkastudio/blob/main/ios/PopkaWatch/Views/HomeView.swift): `ios/PopkaWatch/Views/HomeView.swift`
- [Watch drawing](https://github.com/popaspinka/popkastudio/blob/main/ios/PopkaWatch/Views/WatchDrawing.swift): `ios/PopkaWatch/Views/WatchDrawing.swift`

### Other components

- **Designer**
- **ESP32 watch**
- **Open-Meteo**

## Connections

- Designer → Editor entry: edits project (evidence: `README.md`)
- Editor entry → Project state: loads state (evidence: `studio/web/js/main.js`)
- Editor entry → Screen map: starts map (evidence: `studio/web/js/main.js`)
- Editor entry → Editor panels: renders panels (evidence: `studio/web/js/main.js`)
- Editor entry → Board connection: initializes board (evidence: `studio/web/js/main.js`)
- Editor entry → Live editing: starts live mode (evidence: `studio/web/js/main.js`)
- Editor entry → Web render engine: runs engines (evidence: `studio/web/js/main.js`)
- Web render engine → Project state: reads font scale (evidence: `studio/web/js/engine.js`)
- Web render engine → Board profile: uses board dimensions (evidence: `studio/web/js/screen.js`)
- Layer previews → Web render engine: renders previews (evidence: `studio/web/js/previews.js`)
- Editor panels → Project state: reads project (evidence: `studio/web/js/panels.js`)
- Editor panels → Quick settings editor: uses settings editor (evidence: `studio/web/js/panels.js`)
- Designer → Studio helper: loads firmware (evidence: `README.md`)
- Studio helper → Asset generation: generates assets (evidence: `studio/studio.py`)
- Web render engine → Watch screens and apps: runs board code (evidence: `studio/web/js/engine.js`)
- Web render engine → Halo drawing: renders with (evidence: `studio/web/js/engine.js`)
- Asset generation → Pixel fonts: builds font assets
- Designer → ESP32 watch: uses device (evidence: `README.md`)
- ESP32 watch → Watch screens and apps: runs screens (evidence: `README.md`)
- Watch screens and apps → Dot flow face: includes dot flow (evidence: `firmware/PopkaWatch/flow.h`)
- iPhone app → Watch and weather model: creates model (evidence: `ios/PopkaWatch/App/PopkaWatchApp.swift`)
- iPhone app → Bluetooth link: creates link (evidence: `ios/PopkaWatch/App/PopkaWatchApp.swift`)
- Watch and weather model → Bluetooth link: exchanges reports (evidence: `ios/PopkaWatch/Model/AppModel.swift`)
- Watch and weather model → Weather service: fetches forecast (evidence: `ios/PopkaWatch/Model/AppModel.swift`)
- Weather service → Open-Meteo: requests forecast
- iPhone app → Home screen: shows home screen (evidence: `ios/PopkaWatch/App/PopkaWatchApp.swift`)
- Home screen → Watch and weather model: displays watch data (evidence: `ios/PopkaWatch/Views/HomeView.swift`)
- Home screen → Watch drawing: draws watch (evidence: `ios/PopkaWatch/Views/HomeView.swift`)
- Bluetooth link → ESP32 watch: sends and receives (evidence: `README.md`)
