# lwouis/alt-tab-macos architecture

> Architecture diagram of the GitHub repository lwouis/alt-tab-macos, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lwouis/alt-tab-macos
- Repository: https://github.com/lwouis/alt-tab-macos

## Overview

##### Main Components

- Application Logic Layer
- Windows Management (Windows.swift, Window.swift)
- Applications Management (Applications.swift, Application.swift)
- Spaces Management (Spaces.swift)
- UI Layer
- Main Window (ThumbnailsPanel.swift, PreviewPanel.swift)
- Preferences Window
- Permission Window

b. Event System (Left side):
- Event Handlers (Group these together)
- AccessibilityEvents
- KeyboardEvents
- MouseEvents
- SpacesEvents
- SystemEvents
- DockEvents

c. System Integration (Right side):
- API Wrappers
- AXUIElement (Accessibility)
- CGWindow
- MissionControl
- Private APIs

- Event flow from Event System to Core Components
- UI updates from Core Components to UI Layer
- System interaction between API Wrappers and macOS

##### External Dependencies (Bottom)
- AppCenter (Crash Reporting)
- Sparkle (Updates)
- SwiftyBeaver (Logging)
- ShortcutRecorder (Keyboard Shortcuts)

##### Component Relationships

- Use double lines for data binding

##### Specific Implementation Details

- A "Permissions" subsystem showing integration with macOS security
- Preferences system showing configuration flow
- Window thumbnail management pipeline

##### Notes for Implementation

- Event-driven nature of the application
- How accessibility APIs are leveraged
- Cross-space window management

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef core fill:#a8d1f0,stroke:#333
    classDef event fill:#90EE90,stroke:#333
    classDef system fill:#FFA07A,stroke:#333
    classDef ui fill:#DDA0DD,stroke:#333
    classDef external fill:#D3D3D3,stroke:#333

    %% UI Layer
    subgraph UI
        MainWin["Main Window"]:::ui
        PrefWin["Preferences Window"]:::ui
        PermWin["Permission Window"]:::ui
    end

    %% Core Components
    subgraph Core
        WinMgmt["Windows Management"]:::core
        AppMgmt["Applications Management"]:::core
        SpaceMgmt["Spaces Management"]:::core
    end

    %% Event System
    subgraph Events
        AccessEvents["Accessibility Events"]:::event
        KeyEvents["Keyboard Events"]:::event
        MouseEvents["Mouse Events"]:::event
        SpaceEvents["Spaces Events"]:::event
        SysEvents["System Events"]:::event
        DockEvents["Dock Events"]:::event
    end

    %% System Integration
    subgraph SystemAPI
        AXWrapper["AXUIElement Wrapper"]:::system
        CGWrapper["CGWindow Wrapper"]:::system
        MCWrapper["MissionControl Wrapper"]:::system
        PrivateAPI["Private APIs"]:::system
    end

    %% External Dependencies
    subgraph External
        AppCenter["AppCenter"]:::external
        Sparkle["Sparkle"]:::external
        SwiftyBeaver["SwiftyBeaver"]:::external
        ShortcutRec["ShortcutRecorder"]:::external
    end

    %% Relationships
    Events --> Core
    Core --> UI
    Core --> SystemAPI
    SystemAPI --> Core
    External --> Core

    %% Click Events
    click WinMgmt "https://github.com/lwouis/alt-tab-macos/blob/master/src/logic/Window.swift"
    click AppMgmt "https://github.com/lwouis/alt-tab-macos/blob/master/src/logic/Application.swift"
    click SpaceMgmt "https://github.com/lwouis/alt-tab-macos/blob/master/src/logic/Spaces.swift"
    click MainWin "https://github.com/lwouis/alt-tab-macos/blob/master/src/ui/main-window/ThumbnailsPanel.swift"
    click PrefWin "https://github.com/lwouis/alt-tab-macos/blob/master/src/ui/preferences-window/PreferencesWindow.swift"
    click PermWin "https://github.com/lwouis/alt-tab-macos/blob/master/src/ui/permission-window/PermissionsWindow.swift"
    click AccessEvents "https://github.com/lwouis/alt-tab-macos/blob/master/src/logic/events/AccessibilityEvents.swift"
    click KeyEvents "https://github.com/lwouis/alt-tab-macos/blob/master/src/logic/events/KeyboardEvents.swift"
    click MouseEvents "https://github.com/lwouis/alt-tab-macos/blob/master/src/logic/events/MouseEvents.swift"
    click SpaceEvents "https://github.com/lwouis/alt-tab-macos/blob/master/src/logic/events/SpacesEvents.swift"
    click DockEvents "https://github.com/lwouis/alt-tab-macos/blob/master/src/logic/events/DockEvents.swift"
    click SysEvents "https://github.com/lwouis/alt-tab-macos/blob/master/src/logic/events/SystemAppearanceEvents.swift"
    click AXWrapper "https://github.com/lwouis/alt-tab-macos/blob/master/src/api-wrappers/AXUIElement.swift"
    click CGWrapper "https://github.com/lwouis/alt-tab-macos/blob/master/src/api-wrappers/CGWindow.swift"
    click MCWrapper "https://github.com/lwouis/alt-tab-macos/blob/master/src/api-wrappers/MissionControl.swift"
    click PrivateAPI "https://github.com/lwouis/alt-tab-macos/blob/master/src/api-wrappers/PrivateApis.swift"
    click AppCenter "https://github.com/lwouis/alt-tab-macos/tree/master/Pods/AppCenter"
    click Sparkle "https://github.com/lwouis/alt-tab-macos/tree/master/Pods/Sparkle"
    click SwiftyBeaver "https://github.com/lwouis/alt-tab-macos/tree/master/Pods/SwiftyBeaver"
    click ShortcutRec "https://github.com/lwouis/alt-tab-macos/tree/master/Pods/ShortcutRecorder"
```
