# leujasyoh/type architecture

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

- Interactive diagram: https://gitdiagram.com/leujasyoh/type
- Repository: https://github.com/leujasyoh/type

## Overview

Type is a Windows desktop keyboard-input simulator. The user enters text and options in the Vue UI, starts a delayed task, then focuses a target window; the Go service locks that window and injects text through keyboard, text-message, or clipboard-paste paths, reporting progress and errors back to the UI. Win32 supplies injection, clipboard, and foreground-window capabilities. The README documents additional clipboard safeguards, focus-drift protection, WebView2, and window controls. Backend details are only partially sampled; unsampled documented capabilities are shown without speculative internal wiring.

Main entry points: [`cmd/type/main.go`](https://github.com/leujasyoh/type/blob/main/cmd/type/main.go) (WebView host), [`internal/typing/typing.go`](https://github.com/leujasyoh/type/blob/main/internal/typing/typing.go) (Typing service), [`internal/win32/win32_keyboard.go`](https://github.com/leujasyoh/type/blob/main/internal/win32/win32_keyboard.go) (Input injector), [`frontend/src/App.vue`](https://github.com/leujasyoh/type/blob/main/frontend/src/App.vue) (Typing UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_appview["Typing UI<br/>[App.vue]"]
  node_taskui["Task controls<br/>[useTypingTask.ts]"]
  node_theme["Theme<br/>[useTheme.ts]"]
  node_statusbar["Progress status<br/>[StatusBar.vue]"]
  node_ipc["Typed IPC<br/>[ipc.ts]"]
end

subgraph group_app["Desktop application"]
  node_host["WebView host<br/>[main.go]"]
  node_embedded["Embedded page<br/>[web.go]"]
end

subgraph group_task["Typing workflow"]
  node_service["Typing service<br/>[typing.go]"]
end

subgraph group_platform["Windows integration"]
  node_foreground["Foreground probe<br/>[win32_window.go]"]
  node_injector["Input injector<br/>[win32_keyboard.go]"]
  node_clipboard["Clipboard handling<br/>[win32_clipboard.go]"]
  node_instance["Single-instance guard<br/>[win32_instance.go]"]
  node_webcheck["WebView2 preflight<br/>[win32_webview2.go]"]
  node_msgbox["Native prompts<br/>[win32_msgbox.go]"]
  node_windowcontrols["Window controls<br/>[win32_window.go]"]
end

node_user(("User"))
node_webview["WebView2"]
node_target["Target window"]
node_clipboardos[("Windows clipboard")]

node_user -->|"enters text"| node_appview
node_appview -->|"starts or cancels"| node_taskui
node_appview -->|"toggles theme"| node_theme
node_taskui -->|"sends commands"| node_ipc
node_ipc -->|"calls bindings"| node_host
node_host -->|"dispatches tasks"| node_service
node_service -->|"publishes status"| node_host
node_ipc -->|"polls status"| node_host
node_taskui -->|"renders progress"| node_statusbar
node_host -->|"loads page"| node_embedded
node_host -->|"creates window"| node_webview
node_host -->|"guards startup"| node_instance
node_host -->|"checks runtime"| node_webcheck
node_webcheck -->|"prompts on failure"| node_msgbox
node_host -->|"sets window properties"| node_windowcontrols
node_service -->|"samples target"| node_foreground
node_foreground -->|"checks foreground"| node_target
node_service -->|"injects text"| node_injector
node_injector -->|"sends input"| node_target
node_service -->|"snapshots and restores"| node_clipboard
node_clipboard -->|"reads and writes formats"| node_clipboardos
node_injector -->|"sets paste shortcut"| node_clipboardos
node_injector -->|"sends paste"| node_target

click node_appview "https://github.com/leujasyoh/type/blob/main/frontend/src/App.vue"
click node_taskui "https://github.com/leujasyoh/type/blob/main/frontend/src/composables/useTypingTask.ts"
click node_theme "https://github.com/leujasyoh/type/blob/main/frontend/src/composables/useTheme.ts"
click node_statusbar "https://github.com/leujasyoh/type/blob/main/frontend/src/components/StatusBar.vue"
click node_ipc "https://github.com/leujasyoh/type/blob/main/frontend/src/ipc.ts"
click node_host "https://github.com/leujasyoh/type/blob/main/cmd/type/main.go"
click node_embedded "https://github.com/leujasyoh/type/blob/main/internal/web/web.go"
click node_service "https://github.com/leujasyoh/type/blob/main/internal/typing/typing.go"
click node_foreground "https://github.com/leujasyoh/type/blob/main/internal/win32/win32_window.go"
click node_injector "https://github.com/leujasyoh/type/blob/main/internal/win32/win32_keyboard.go"
click node_clipboard "https://github.com/leujasyoh/type/blob/main/internal/win32/win32_clipboard.go"
click node_instance "https://github.com/leujasyoh/type/blob/main/internal/win32/win32_instance.go"
click node_webcheck "https://github.com/leujasyoh/type/blob/main/internal/win32/win32_webview2.go"
click node_msgbox "https://github.com/leujasyoh/type/blob/main/internal/win32/win32_msgbox.go"
click node_windowcontrols "https://github.com/leujasyoh/type/blob/main/internal/win32/win32_window.go"

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_appview,node_taskui,node_theme,node_statusbar,node_ipc,node_user,node_webview toneBlue
class node_host,node_embedded,node_clipboardos toneAmber
class node_service toneMint
class node_foreground,node_injector,node_clipboard,node_instance,node_webcheck,node_msgbox,node_windowcontrols toneRose
class node_target toneIndigo
```

## Components

### User interface

- [Typing UI](https://github.com/leujasyoh/type/blob/main/frontend/src/App.vue): `frontend/src/App.vue`
- [Task controls](https://github.com/leujasyoh/type/blob/main/frontend/src/composables/useTypingTask.ts): `frontend/src/composables/useTypingTask.ts`
- [Theme](https://github.com/leujasyoh/type/blob/main/frontend/src/composables/useTheme.ts): `frontend/src/composables/useTheme.ts`
- [Progress status](https://github.com/leujasyoh/type/blob/main/frontend/src/components/StatusBar.vue): `frontend/src/components/StatusBar.vue`
- [Typed IPC](https://github.com/leujasyoh/type/blob/main/frontend/src/ipc.ts): `frontend/src/ipc.ts`

### Desktop application

- [WebView host](https://github.com/leujasyoh/type/blob/main/cmd/type/main.go): `cmd/type/main.go`
- [Embedded page](https://github.com/leujasyoh/type/blob/main/internal/web/web.go): `internal/web/web.go`

### Typing workflow

- [Typing service](https://github.com/leujasyoh/type/blob/main/internal/typing/typing.go): `internal/typing/typing.go`

### Windows integration

- [Foreground probe](https://github.com/leujasyoh/type/blob/main/internal/win32/win32_window.go): `internal/win32/win32_window.go`
- [Input injector](https://github.com/leujasyoh/type/blob/main/internal/win32/win32_keyboard.go): `internal/win32/win32_keyboard.go`
- [Clipboard handling](https://github.com/leujasyoh/type/blob/main/internal/win32/win32_clipboard.go): `internal/win32/win32_clipboard.go`
- [Single-instance guard](https://github.com/leujasyoh/type/blob/main/internal/win32/win32_instance.go): `internal/win32/win32_instance.go`
- [WebView2 preflight](https://github.com/leujasyoh/type/blob/main/internal/win32/win32_webview2.go): `internal/win32/win32_webview2.go`
- [Native prompts](https://github.com/leujasyoh/type/blob/main/internal/win32/win32_msgbox.go): `internal/win32/win32_msgbox.go`
- [Window controls](https://github.com/leujasyoh/type/blob/main/internal/win32/win32_window.go): `internal/win32/win32_window.go`

### Other components

- **User**
- **WebView2**
- **Target window**
- **Windows clipboard**

## Connections

- User → Typing UI: enters text
- Typing UI → Task controls: starts or cancels
- Typing UI → Theme: toggles theme
- Task controls → Typed IPC: sends commands
- Typed IPC → WebView host: calls bindings
- WebView host → Typing service: dispatches tasks
- Typing service → WebView host: publishes status
- Typed IPC → WebView host: polls status
- Task controls → Progress status: renders progress
- WebView host → Embedded page: loads page
- WebView host → WebView2: creates window
- WebView host → Single-instance guard: guards startup
- WebView host → WebView2 preflight: checks runtime
- WebView2 preflight → Native prompts: prompts on failure
- WebView host → Window controls: sets window properties
- Typing service → Foreground probe: samples target
- Foreground probe → Target window: checks foreground
- Typing service → Input injector: injects text
- Input injector → Target window: sends input
- Typing service → Clipboard handling: snapshots and restores
- Clipboard handling → Windows clipboard: reads and writes formats
- Input injector → Windows clipboard: sets paste shortcut
- Input injector → Target window: sends paste
