How plasticgaming99/photon works
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 main.go · plastk plastk · phicons icons · menubar.go menubar.go
Components 8
Editor app
Top-level executable and runtime loop.
- main.go · Bootstraps the editor and wires the runtime together.
main.go - Ebitengine · Window, frame, rendering, and input loop used by the editor.
Support code
Shared helper packages for editor behavior and platform integration.
- plastk · Platform and UI integration helpers for editor chrome and system-specific behavior.
modules/plastk - menubar.go · Menu bar behavior and related UI plumbing.
modules/plastk/menubar.go - etclibs.go · Miscellaneous platform or system-library support utilities.
modules/plastk/etclibs.go - dyntypes · Helpers for dynamic or loosely typed values used across editor state and data conversion.
modules/dyntypes/dyntypes.go
Connections 10
- 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.