# plasticgaming99/photon architecture

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

- Interactive diagram: https://gitdiagram.com/plasticgaming99/photon
- Repository: https://github.com/plasticgaming99/photon

## Overview

1. **Project shape**
   - This is a small Go application for a **text editor** called **photon**.
   - The repo is organized as a single executable plus a few internal support packages, rather than a multi-service system.

2. **Entry point**
   - `main.go` is the top-level application entry.
   - It likely boots the editor, initializes graphics/UI state, wires together editor subsystems, and starts the Ebitengine game loop.

3. **Core runtime**
   - The editor is built on **Ebitengine**, so the primary runtime boundary is the game/window loop managed by that engine.
   - That means rendering, input handling, and frame updates are likely centralized in the main app rather than split across background services.

4. **Internal package boundary: `modules/dyntypes`**
   - `modules/dyntypes/dyntypes.go` is a shared utility package for dynamic or loosely typed values.
   - Architecturally, this looks like a **support layer** for editor state/configuration/data conversion where flexible typing is needed.

5. **Internal package boundary: `modules/plastk`**
   - `modules/plastk` contains `etclibs.go` and `menubar.go`, suggesting platform/UI support code.
   - `menubar.go` likely encapsulates menu bar behavior.
   - `etclibs.go` appears to collect miscellaneous platform or system-library integration helpers.
   - This package is a clear boundary between the editor core and OS-/UI-specific features.

6. **Embedded assets subsystem**
   - `assets/phfonts` and `assets/phicons` each have an `embed.go`, indicating use of Go’s embedded-resource mechanism.
   - These packages bundle runtime assets directly into the binary, so the app does not depend on external font/icon files at execution time.

7. **Font resources**
   - `assets/phfonts` contains several CJK font files, including Noto Sans variants.
   - That strongly suggests the editor needs **broad Unicode/CJK text rendering support**, which is important for an editor architecture diagram because text rendering is not just decorative—it is a core capability.

8. **Icon resources**
   - `assets/phicons` likely supplies UI icons used by the editor chrome, toolbar, menus, or commands.
   - These are part of the presentation layer and probably consumed by the UI/menu subsystem rather than the editing engine itself.

9. **Data flow**
   - The simplest likely flow is: **embedded assets and helper packages feed the main editor runtime**, and the main runtime drives rendering/input through Ebitengine.
   - `main.go` sits at the center, consuming internal packages and bundled resources to produce the interactive editor window.

10. **Build/deployment model**
    - The project is built as a standard Go binary with `go build`.
    - No separate backend, database, or network service is indicated in the repository layout.
    - The architecture is therefore a **single-process desktop application** with embedded resources.

11. **Dependency boundaries**
    - External dependency visibility is intentionally small in the repo layout: the notable runtime dependency is **Ebitengine**.
    - Everything else appears to be local packages and embedded files, which keeps the architecture compact and self-contained.

12. **What to show in a diagram**
    - A good diagram would place `main.go` at the center, with arrows to:
      - `modules/plastk` for UI/platform helpers
      - `modules/dyntypes` for shared data/type utilities
      - `assets/phfonts` and `assets/phicons` for embedded runtime resources
      - Ebitengine as the external rendering/input runtime underneath the app

Main entry points: [`main.go`](https://github.com/plasticgaming99/photon/blob/main/main.go) (main.go), [`modules/plastk`](https://github.com/plasticgaming99/photon/tree/main/modules/plastk) (plastk), [`assets/phicons`](https://github.com/plasticgaming99/photon/tree/main/assets/phicons) (icons), [`modules/plastk/menubar.go`](https://github.com/plasticgaming99/photon/blob/main/modules/plastk/menubar.go) (menubar.go)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Editor app"]
  node_main_go["main.go<br/>entrypoint<br/>[main.go]"]
  node_ebitengine(("Ebitengine<br/>runtime"))
end

subgraph group_support["Support code"]
  node_plastk["plastk<br/>platform ui"]
  node_menubar_go["menubar.go<br/>menu ui<br/>[menubar.go]"]
  node_etclibs_go["etclibs.go<br/>platform helpers<br/>[etclibs.go]"]
  node_dyntypes_go["dyntypes<br/>type utils<br/>[dyntypes.go]"]
end

subgraph group_assets["Embedded assets"]
  node_phfonts[("fonts")]
  node_phicons[("icons")]
end

node_main_go -->|"runs on"| node_ebitengine
node_main_go -->|"uses"| node_plastk
node_main_go -->|"uses"| node_dyntypes_go
node_main_go -->|"loads"| node_phfonts
node_main_go -->|"loads"| node_phicons
node_plastk -->|"contains"| node_menubar_go
node_plastk -->|"contains"| node_etclibs_go
node_menubar_go -->|"uses"| node_phicons
node_phfonts -->|"provides"| node_main_go
node_phicons -->|"provides"| node_main_go

click node_main_go "https://github.com/plasticgaming99/photon/blob/main/main.go"
click node_plastk "https://github.com/plasticgaming99/photon/tree/main/modules/plastk"
click node_menubar_go "https://github.com/plasticgaming99/photon/blob/main/modules/plastk/menubar.go"
click node_etclibs_go "https://github.com/plasticgaming99/photon/blob/main/modules/plastk/etclibs.go"
click node_dyntypes_go "https://github.com/plasticgaming99/photon/blob/main/modules/dyntypes/dyntypes.go"
click node_phfonts "https://github.com/plasticgaming99/photon/tree/main/assets/phfonts"
click node_phicons "https://github.com/plasticgaming99/photon/tree/main/assets/phicons"

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_main_go,node_ebitengine toneBlue
class node_plastk,node_menubar_go,node_etclibs_go,node_dyntypes_go toneAmber
class node_phfonts,node_phicons toneMint
```

## Components

### Editor app

Top-level executable and runtime loop.

- [main.go](https://github.com/plasticgaming99/photon/blob/main/main.go): entrypoint · Bootstraps the editor and wires the runtime together. · `main.go`
- **Ebitengine**: runtime · Window, frame, rendering, and input loop used by the editor.

### Support code

Shared helper packages for editor behavior and platform integration.

- [plastk](https://github.com/plasticgaming99/photon/tree/main/modules/plastk): platform ui · Platform and UI integration helpers for editor chrome and system-specific behavior. · `modules/plastk`
- [menubar.go](https://github.com/plasticgaming99/photon/blob/main/modules/plastk/menubar.go): menu ui · Menu bar behavior and related UI plumbing. · `modules/plastk/menubar.go`
- [etclibs.go](https://github.com/plasticgaming99/photon/blob/main/modules/plastk/etclibs.go): platform helpers · Miscellaneous platform or system-library support utilities. · `modules/plastk/etclibs.go`
- [dyntypes](https://github.com/plasticgaming99/photon/blob/main/modules/dyntypes/dyntypes.go): type utils · Helpers for dynamic or loosely typed values used across editor state and data conversion. · `modules/dyntypes/dyntypes.go`

### Embedded assets

Bundled runtime resources compiled into the binary.

- [fonts](https://github.com/plasticgaming99/photon/tree/main/assets/phfonts): embedded fonts · Embedded font resources for broad Unicode and CJK text rendering. · `assets/phfonts`
- [icons](https://github.com/plasticgaming99/photon/tree/main/assets/phicons): embedded icons · Embedded icon resources for editor chrome and UI presentation. · `assets/phicons`

## Connections

- main.go → Ebitengine: runs on · Main editor loop is hosted by Ebitengine.
- main.go → plastk: uses · Main application wires in platform and menu support.
- main.go → dyntypes: uses · Main application relies on shared dynamic value helpers.
- main.go → fonts: loads · Editor consumes embedded fonts for text rendering.
- main.go → icons: loads · Editor consumes embedded icons for UI presentation.
- plastk → menubar.go: contains · Menu bar implementation lives inside the plastk package.
- plastk → etclibs.go: contains · Platform helper code lives inside the plastk package.
- menubar.go → icons: uses · Menu bar UI likely draws from embedded icon resources.
- fonts → main.go: provides · Embedded font assets are packaged for the editor runtime.
- icons → main.go: provides · Embedded icon assets are packaged for the editor runtime.
