# lieonshelly/rectangler architecture

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

- Interactive diagram: https://gitdiagram.com/lieonshelly/rectangler
- Repository: https://github.com/lieonshelly/rectangler

## Overview

Rectangler is a macOS menu-bar window manager. Users choose a layout from the menu or invoke a global shortcut; both paths apply a layout to the frontmost eligible window, with one-level restore. Settings cover Accessibility guidance, shortcut enablement, custom split ratios, and launch at login. The source excerpts show the central dispatch and state-management calls; menu-bar lifecycle wiring is visible in the app entry point. Major documented stages whose implementations were not sampled are represented by their indexed source paths.

Main entry points: [`Rectangler/SettingsView.swift`](https://github.com/lieonshelly/rectangler/blob/main/Rectangler/SettingsView.swift) (Settings panel), [`Rectangler/WindowManager.swift`](https://github.com/lieonshelly/rectangler/blob/main/Rectangler/WindowManager.swift) (Window manager), [`Rectangler/RectanglerMenu.swift`](https://github.com/lieonshelly/rectangler/blob/main/Rectangler/RectanglerMenu.swift) (Menu controls), [`Rectangler/AccessibilityPermissionStore.swift`](https://github.com/lieonshelly/rectangler/blob/main/Rectangler/AccessibilityPermissionStore.swift) (Accessibility permission)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["App and controls"]
  node_app["App lifecycle"]
  node_menu["Menu controls"]
  node_settingsview["Settings panel<br/>[SettingsView.swift]"]
  node_hotkeys["Global shortcuts"]
end

subgraph group_window["Window operations"]
  node_layouts["Layout geometry<br/>[WindowLayout.swift]"]
  node_manager["Window manager"]
end

subgraph group_settings["Preferences and access"]
  node_access["Accessibility permission"]
  node_layoutsettings["Layout preferences"]
  node_launch["Launch at login"]
end

node_user(("Mac user"))
node_target["Frontmost app window"]
node_macos["macOS services"]

node_user -->|"chooses layout"| node_menu
node_user -->|"presses shortcut"| node_hotkeys
node_user -->|"configures"| node_settingsview
node_app -->|"presents"| node_menu
node_app -->|"presents"| node_settingsview
node_app -->|"registers"| node_hotkeys
node_menu -->|"applies or restores"| node_manager
node_hotkeys -->|"dispatches actions"| node_manager
node_manager -->|"calculates frame"| node_layouts
node_manager -->|"reads and resizes"| node_target
node_manager -->|"queries displays"| node_macos
node_menu -->|"checks and guides"| node_access
node_menu -->|"reads split ratio"| node_layoutsettings
node_settingsview -->|"refreshes and opens"| node_access
node_settingsview -->|"toggles shortcuts"| node_hotkeys
node_settingsview -->|"updates ratios"| node_layoutsettings
node_settingsview -->|"updates split"| node_manager
node_settingsview -->|"toggles startup"| node_launch
node_access -->|"checks permission"| node_macos
node_access -->|"opens settings"| node_macos
node_launch -->|"registers service"| node_macos
node_layoutsettings -->|"persists ratios"| node_macos

click node_app "https://github.com/lieonshelly/rectangler/blob/main/Rectangler/RectanglerApp.swift"
click node_menu "https://github.com/lieonshelly/rectangler/blob/main/Rectangler/RectanglerMenu.swift"
click node_settingsview "https://github.com/lieonshelly/rectangler/blob/main/Rectangler/SettingsView.swift"
click node_hotkeys "https://github.com/lieonshelly/rectangler/blob/main/Rectangler/HotKeyManager.swift"
click node_layouts "https://github.com/lieonshelly/rectangler/blob/main/Rectangler/WindowLayout.swift"
click node_manager "https://github.com/lieonshelly/rectangler/blob/main/Rectangler/WindowManager.swift"
click node_access "https://github.com/lieonshelly/rectangler/blob/main/Rectangler/AccessibilityPermissionStore.swift"
click node_layoutsettings "https://github.com/lieonshelly/rectangler/blob/main/Rectangler/LayoutSettingsStore.swift"
click node_launch "https://github.com/lieonshelly/rectangler/blob/main/Rectangler/LaunchAtLoginStore.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_app,node_menu,node_settingsview,node_hotkeys,node_user toneBlue
class node_layouts,node_manager toneAmber
class node_access,node_layoutsettings,node_launch toneMint
class node_target,node_macos toneIndigo
```

## Components

### App and controls

- [App lifecycle](https://github.com/lieonshelly/rectangler/blob/main/Rectangler/RectanglerApp.swift): `Rectangler/RectanglerApp.swift`
- [Menu controls](https://github.com/lieonshelly/rectangler/blob/main/Rectangler/RectanglerMenu.swift): `Rectangler/RectanglerMenu.swift`
- [Settings panel](https://github.com/lieonshelly/rectangler/blob/main/Rectangler/SettingsView.swift): `Rectangler/SettingsView.swift`
- [Global shortcuts](https://github.com/lieonshelly/rectangler/blob/main/Rectangler/HotKeyManager.swift): `Rectangler/HotKeyManager.swift`

### Window operations

- [Layout geometry](https://github.com/lieonshelly/rectangler/blob/main/Rectangler/WindowLayout.swift): `Rectangler/WindowLayout.swift`
- [Window manager](https://github.com/lieonshelly/rectangler/blob/main/Rectangler/WindowManager.swift): `Rectangler/WindowManager.swift`

### Preferences and access

- [Accessibility permission](https://github.com/lieonshelly/rectangler/blob/main/Rectangler/AccessibilityPermissionStore.swift): `Rectangler/AccessibilityPermissionStore.swift`
- [Layout preferences](https://github.com/lieonshelly/rectangler/blob/main/Rectangler/LayoutSettingsStore.swift): `Rectangler/LayoutSettingsStore.swift`
- [Launch at login](https://github.com/lieonshelly/rectangler/blob/main/Rectangler/LaunchAtLoginStore.swift): `Rectangler/LaunchAtLoginStore.swift`

### Other components

- **Mac user**
- **Frontmost app window**
- **macOS services**

## Connections

- Mac user → Menu controls: chooses layout (evidence: `Rectangler/RectanglerMenu.swift`)
- Mac user → Global shortcuts: presses shortcut (evidence: `Rectangler/HotKeyManager.swift`)
- Mac user → Settings panel: configures (evidence: `Rectangler/SettingsView.swift`)
- App lifecycle → Menu controls: presents (evidence: `Rectangler/RectanglerApp.swift`)
- App lifecycle → Settings panel: presents (evidence: `Rectangler/RectanglerApp.swift`)
- App lifecycle → Global shortcuts: registers (evidence: `Rectangler/RectanglerApp.swift`)
- Menu controls → Window manager: applies or restores (evidence: `Rectangler/RectanglerMenu.swift`)
- Global shortcuts → Window manager: dispatches actions (evidence: `Rectangler/HotKeyManager.swift`)
- Window manager → Layout geometry: calculates frame (evidence: `Rectangler/WindowManager.swift`)
- Window manager → Frontmost app window: reads and resizes (evidence: `Rectangler/WindowManager.swift`)
- Window manager → macOS services: queries displays (evidence: `Rectangler/WindowManager.swift`)
- Menu controls → Accessibility permission: checks and guides (evidence: `Rectangler/RectanglerMenu.swift`)
- Menu controls → Layout preferences: reads split ratio (evidence: `Rectangler/RectanglerMenu.swift`)
- Settings panel → Accessibility permission: refreshes and opens (evidence: `Rectangler/SettingsView.swift`)
- Settings panel → Global shortcuts: toggles shortcuts (evidence: `Rectangler/SettingsView.swift`)
- Settings panel → Layout preferences: updates ratios (evidence: `Rectangler/SettingsView.swift`)
- Settings panel → Window manager: updates split (evidence: `Rectangler/SettingsView.swift`)
- Settings panel → Launch at login: toggles startup (evidence: `Rectangler/SettingsView.swift`)
- Accessibility permission → macOS services: checks permission (evidence: `Rectangler/AccessibilityPermissionStore.swift`)
- Accessibility permission → macOS services: opens settings (evidence: `Rectangler/AccessibilityPermissionStore.swift`)
- Launch at login → macOS services: registers service (evidence: `Rectangler/LaunchAtLoginStore.swift`)
- Layout preferences → macOS services: persists ratios (evidence: `Rectangler/LayoutSettingsStore.swift`)
