# ghostty-org/ghostty architecture

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

- Interactive diagram: https://gitdiagram.com/ghostty-org/ghostty
- Repository: https://github.com/ghostty-org/ghostty

## Overview

Ghostty is a native terminal emulator and an embeddable terminal library. In the macOS app, users launch or open a terminal; app actions create terminal windows and tabs, while controllers manage surfaces, splits, and rendering. The separate libghostty-vt API exposes terminal parsing and state for embedding. The graph includes documented native features such as Quick Terminal and automation, even where implementation details were not sampled; those links are marked unverified. Relationships reflect shown calls or source-index references, not an assumed end-to-end pipeline.

Main entry points: [`macos/Sources/Features/Terminal/TerminalController.swift`](https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/Terminal/TerminalController.swift) (Window and Tabs), [`macos/Sources/Features/Terminal/BaseTerminalController.swift`](https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/Terminal/BaseTerminalController.swift) (Terminal Controller Base), [`macos/Sources/App/AppDelegate.swift`](https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/App/AppDelegate.swift) (App Lifecycle), [`macos/Sources/Features/QuickTerminal/QuickTerminalController.swift`](https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift) (Quick Terminal)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["macOS App"]
  node_app_start["App Lifecycle<br/>[AppDelegate.swift]"]
end

subgraph group_terminal["Terminal Workspace"]
  node_terminal_controller["Window and Tabs"]
  node_base_controller["Terminal Controller Base"]
  node_split_tree["Split Layout<br/>[SplitTree.swift]"]
  node_terminal_view["Terminal View<br/>[TerminalView.swift]"]
  node_view_container["View Container"]
  node_surface["Terminal Surface<br/>[SurfaceView.swift]"]
  node_terminal_window["Window Styling"]
end

subgraph group_native["Native Features"]
  node_quick_terminal["Quick Terminal"]
  node_quick_position["Quick Positioning"]
  node_quick_cache[("Screen State Cache")]
  node_secure_input["Secure Input<br/>[SecureInput.swift]"]
  node_update["Update UI State"]
  node_automation["AppleScript and Shortcuts"]
end

subgraph group_library["Embeddable Library"]
  node_lib_api["libghostty API<br/>[ghostty.h]"]
  node_vt_api["VT Terminal API<br/>[terminal.h]"]
  node_vt_search["Terminal Search<br/>[search.h]"]
end

node_user(("User"))
node_embedder(("Embedding Application"))

node_user -->|"launches"| node_app_start
node_app_start -->|"creates window"| node_terminal_controller
node_terminal_controller -->|"inherits from"| node_base_controller
node_base_controller -->|"creates surface"| node_surface
node_base_controller -->|"updates layout"| node_split_tree
node_terminal_controller -->|"uses layout"| node_split_tree
node_terminal_controller -->|"uses view"| node_terminal_view
node_terminal_controller -->|"uses container"| node_view_container
node_terminal_controller -->|"uses window"| node_terminal_window
node_terminal_view -->|"displays surface"| node_surface
node_view_container -->|"uses controller"| node_base_controller
node_app_start -->|"manages feature"| node_quick_terminal
node_quick_terminal -->|"uses positioning"| node_quick_position
node_quick_terminal -->|"saves screen state"| node_quick_cache
node_quick_terminal -->|"inherits from"| node_base_controller
node_surface -->|"uses secure input"| node_secure_input
node_app_start -->|"configures updates"| node_update
node_user -.->|"invokes commands"| node_automation
node_embedder -->|"embeds library"| node_lib_api
node_lib_api -.->|"exposes VT API"| node_vt_api
node_embedder -.->|"uses search API"| node_vt_search

click node_app_start "https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/App/AppDelegate.swift"
click node_terminal_controller "https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/Terminal/TerminalController.swift"
click node_base_controller "https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/Terminal/BaseTerminalController.swift"
click node_split_tree "https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/Splits/SplitTree.swift"
click node_terminal_view "https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/Terminal/TerminalView.swift"
click node_view_container "https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/Terminal/TerminalViewContainer.swift"
click node_surface "https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Ghostty/Surface%20View/SurfaceView.swift"
click node_terminal_window "https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/Terminal/Window%20Styles/TerminalWindow.swift"
click node_quick_terminal "https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift"
click node_quick_position "https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/QuickTerminal/QuickTerminalPosition.swift"
click node_quick_cache "https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/QuickTerminal/QuickTerminalScreenStateCache.swift"
click node_secure_input "https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/Secure%20Input/SecureInput.swift"
click node_update "https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/Update/UpdateViewModel.swift"
click node_automation "https://github.com/ghostty-org/ghostty/tree/main/macos/Sources/Features/AppleScript"
click node_lib_api "https://github.com/ghostty-org/ghostty/blob/main/include/ghostty.h"
click node_vt_api "https://github.com/ghostty-org/ghostty/blob/main/include/ghostty/vt/terminal.h"
click node_vt_search "https://github.com/ghostty-org/ghostty/blob/main/include/ghostty/vt/search.h"

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_start,node_user toneBlue
class node_terminal_controller,node_base_controller,node_split_tree,node_terminal_view,node_view_container,node_surface,node_terminal_window toneAmber
class node_quick_terminal,node_quick_position,node_quick_cache,node_secure_input,node_update,node_automation toneMint
class node_lib_api,node_vt_api,node_vt_search toneRose
class node_embedder toneIndigo
```

## Components

### macOS App

- [App Lifecycle](https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/App/AppDelegate.swift): `macos/Sources/App/AppDelegate.swift`

### Terminal Workspace

- [Window and Tabs](https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/Terminal/TerminalController.swift): `macos/Sources/Features/Terminal/TerminalController.swift`
- [Terminal Controller Base](https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/Terminal/BaseTerminalController.swift): `macos/Sources/Features/Terminal/BaseTerminalController.swift`
- [Split Layout](https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/Splits/SplitTree.swift): `macos/Sources/Features/Splits/SplitTree.swift`
- [Terminal View](https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/Terminal/TerminalView.swift): `macos/Sources/Features/Terminal/TerminalView.swift`
- [View Container](https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/Terminal/TerminalViewContainer.swift): `macos/Sources/Features/Terminal/TerminalViewContainer.swift`
- [Terminal Surface](https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Ghostty/Surface%20View/SurfaceView.swift): `macos/Sources/Ghostty/Surface View/SurfaceView.swift`
- [Window Styling](https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/Terminal/Window%20Styles/TerminalWindow.swift): `macos/Sources/Features/Terminal/Window Styles/TerminalWindow.swift`

### Native Features

- [Quick Terminal](https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/QuickTerminal/QuickTerminalController.swift): `macos/Sources/Features/QuickTerminal/QuickTerminalController.swift`
- [Quick Positioning](https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/QuickTerminal/QuickTerminalPosition.swift): `macos/Sources/Features/QuickTerminal/QuickTerminalPosition.swift`
- [Screen State Cache](https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/QuickTerminal/QuickTerminalScreenStateCache.swift): `macos/Sources/Features/QuickTerminal/QuickTerminalScreenStateCache.swift`
- [Secure Input](https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/Secure%20Input/SecureInput.swift): `macos/Sources/Features/Secure Input/SecureInput.swift`
- [Update UI State](https://github.com/ghostty-org/ghostty/blob/main/macos/Sources/Features/Update/UpdateViewModel.swift): `macos/Sources/Features/Update/UpdateViewModel.swift`
- [AppleScript and Shortcuts](https://github.com/ghostty-org/ghostty/tree/main/macos/Sources/Features/AppleScript): `macos/Sources/Features/AppleScript`

### Embeddable Library

- [libghostty API](https://github.com/ghostty-org/ghostty/blob/main/include/ghostty.h): `include/ghostty.h`
- [VT Terminal API](https://github.com/ghostty-org/ghostty/blob/main/include/ghostty/vt/terminal.h): `include/ghostty/vt/terminal.h`
- [Terminal Search](https://github.com/ghostty-org/ghostty/blob/main/include/ghostty/vt/search.h): `include/ghostty/vt/search.h`

### Other components

- **User**
- **Embedding Application**

## Connections

- User → App Lifecycle: launches
- App Lifecycle → Window and Tabs: creates window (evidence: `macos/Sources/App/AppDelegate.swift`)
- Window and Tabs → Terminal Controller Base: inherits from (evidence: `macos/Sources/Features/Terminal/TerminalController.swift`)
- Terminal Controller Base → Terminal Surface: creates surface (evidence: `macos/Sources/Features/Terminal/BaseTerminalController.swift`)
- Terminal Controller Base → Split Layout: updates layout (evidence: `macos/Sources/Features/Terminal/BaseTerminalController.swift`)
- Window and Tabs → Split Layout: uses layout (evidence: `macos/Sources/Features/Terminal/TerminalController.swift`)
- Window and Tabs → Terminal View: uses view (evidence: `macos/Sources/Features/Terminal/TerminalController.swift`)
- Window and Tabs → View Container: uses container (evidence: `macos/Sources/Features/Terminal/TerminalController.swift`)
- Window and Tabs → Window Styling: uses window (evidence: `macos/Sources/Features/Terminal/TerminalController.swift`)
- Terminal View → Terminal Surface: displays surface (evidence: `macos/Sources/Features/Terminal/TerminalView.swift`)
- View Container → Terminal Controller Base: uses controller (evidence: `macos/Sources/Features/Terminal/TerminalViewContainer.swift`)
- App Lifecycle → Quick Terminal: manages feature (evidence: `macos/Sources/App/AppDelegate.swift`)
- Quick Terminal → Quick Positioning: uses positioning (evidence: `macos/Sources/Features/QuickTerminal/QuickTerminalController.swift`)
- Quick Terminal → Screen State Cache: saves screen state (evidence: `macos/Sources/Features/QuickTerminal/QuickTerminalController.swift`)
- Quick Terminal → Terminal Controller Base: inherits from (evidence: `macos/Sources/Features/QuickTerminal/QuickTerminalController.swift`)
- Terminal Surface → Secure Input: uses secure input (evidence: `macos/Sources/Ghostty/Surface View/SurfaceView.swift`)
- App Lifecycle → Update UI State: configures updates (evidence: `macos/Sources/App/AppDelegate.swift`)
- User → AppleScript and Shortcuts: invokes commands
- Embedding Application → libghostty API: embeds library
- libghostty API → VT Terminal API: exposes VT API
- Embedding Application → Terminal Search: uses search API (evidence: `include/ghostty/vt/search.h`)
