# ducbao414/live-wallpaper architecture

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

- Interactive diagram: https://gitdiagram.com/ducbao414/live-wallpaper
- Repository: https://github.com/ducbao414/live-wallpaper

## Overview

#### Purpose and Runtime
LiveWallpaper is a sandboxed macOS Ventura+ Swift/SwiftUI utility that renders a user-selected video as the desktop wallpaper and mixes bundled ambient audio. It uses Apple media/window APIs locally; no backend, network service, or external runtime is indicated. The Xcode application target and signing/sandbox boundary are in `LiveWallpaper.xcodeproj/project.pbxproj` and `LiveWallpaper/LiveWallpaper.entitlements`.

#### Application Entry and UI Shell
`LiveWallpaper/LiveWallpaperApp.swift` is the SwiftUI application entry point. `LiveWallpaper/ContentView.swift` is the primary interactive shell, coordinating wallpaper/video selection, recent media, settings, and ambient-sound UI. `LiveWallpaper/WindowManager.swift` manages application-window behavior, including continued control after the primary window closes.

#### Wallpaper Lifecycle
`LiveWallpaper/Singletons/WallpaperManager.swift` is the central controller for installing, playing, pausing, and removing the video wallpaper. It owns the desktop-rendering boundary and likely coordinates playback state with the system window hierarchy. `LiveWallpaper/Components/PlayerLayerView.swift` and `LiveWallpaper/Components/InlineVideoPlayer.swift` bridge video playback/rendering into SwiftUI for wallpaper and preview contexts.

#### Video Ingestion and Library Flow
`LiveWallpaper/Views/VideoDropView.swift` is the import boundary for user-selected or dropped video files; sandbox access is limited to selected videos. `LiveWallpaper/Helpers/VidAnalyzer.swift` analyzes candidate media, while `LiveWallpaper/Views/Recent.swift` and `LiveWallpaper/Components/RecentVideoView.swift` present persisted/recent video choices. The flow is: choose/drop video → validate/analyze → retain recent selection/state → hand selected URL to `WallpaperManager`.

#### Power and Appearance Adaptation
`LiveWallpaper/Helpers/OvercastDetector.swift` supports the power-saving behavior: wallpaper rendering can pause when application windows substantially cover it. `LiveWallpaper/Singletons/WallpaperManager.swift` consumes this visibility/occlusion signal to control playback rather than continuously rendering. Adaptive light/dark presentation is handled at the SwiftUI/application layer, centered on `LiveWallpaper/ContentView.swift` and `LiveWallpaper/Views/SettingView.swift`.

#### Ambient Audio Mixer
`LiveWallpaper/Singletons/AudioMixer.swift` is the audio-state and playback authority for concurrent ambient tracks and per-track volumes. `LiveWallpaper/Views/AmbientSounds.swift` exposes mixer controls. Audio assets are bundled under `LiveWallpaper/Sounds`, such as `LiveWallpaper/Sounds/rain.mp3`, `LiveWallpaper/Sounds/beach.mp3`, and `LiveWallpaper/Sounds/fire.mp3`; they are app resources rather than downloaded content.

#### Persistent Settings and Supporting Presentation
`LiveWallpaper/Singletons/UserSetting.swift` centralizes persisted user preferences and is shared by wallpaper, audio, and settings flows. `LiveWallpaper/Views/SettingView.swift` is the settings surface. Reusable presentation components—blur, progress, and notifications—are isolated in `LiveWallpaper/Components/BlurView.swift`, `LiveWallpaper/Components/ProgressRing.swift`, and `LiveWallpaper/Components/Toast.swift`, keeping UI feedback separate from media/window control.

Main entry points: [`LiveWallpaper/ContentView.swift`](https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/ContentView.swift) (Control shell), [`LiveWallpaper/Singletons/WallpaperManager.swift`](https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/Singletons/WallpaperManager.swift) (Wallpaper manager), [`LiveWallpaper/Singletons/UserSetting.swift`](https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/Singletons/UserSetting.swift) (User settings), [`LiveWallpaper/Views/VideoDropView.swift`](https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/Views/VideoDropView.swift) (Video import)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["SwiftUI surfaces"]
  node_app["App entry<br/>SwiftUI app"]
  node_shell["Control shell<br/>SwiftUI view<br/>[ContentView.swift]"]
  node_windows["Window manager<br/>window control"]
  node_settings_view["Settings<br/>SwiftUI view<br/>[SettingView.swift]"]
  node_preferences[("User settings<br/>persistent state<br/>[UserSetting.swift]")]
  node_feedback["UI feedback components<br/>presentation components<br/>[Toast.swift]"]
end

subgraph group_video["Video wallpaper"]
  node_import["Video import<br/>sandbox file input"]
  node_analyzer["Media analyzer<br/>video validation<br/>[VidAnalyzer.swift]"]
  node_recents["Recent videos<br/>media library UI<br/>[Recent.swift]"]
  node_wallpaper{{"Wallpaper manager<br/>wallpaper controller"}}
  node_player_bridge["Video player bridge<br/>SwiftUI playback view"]
  node_occlusion["Occlusion detector<br/>visibility signal"]
end

subgraph group_audio["Ambient audio"]
  node_ambient_ui["Ambient sound controls<br/>SwiftUI view"]
  node_mixer{{"Audio mixer<br/>audio controller<br/>[AudioMixer.swift]"}}
  node_sounds["Bundled sound assets<br/>app resources"]
end

node_sandbox{{"App sandbox and signing<br/>macOS security boundary"}}

node_app -->|"launches"| node_shell
node_app -->|"manages"| node_windows
node_shell -->|"selects video"| node_import
node_shell -->|"shows"| node_recents
node_shell -->|"opens"| node_settings_view
node_shell -->|"hosts"| node_ambient_ui
node_import -->|"analyzes"| node_analyzer
node_analyzer -->|"retains selection"| node_recents
node_recents -->|"selected URL"| node_wallpaper
node_wallpaper -->|"renders through"| node_player_bridge
node_occlusion -->|"pause/resume signal"| node_wallpaper
node_settings_view -->|"updates"| node_preferences
node_preferences -->|"playback preferences"| node_wallpaper
node_preferences -->|"audio preferences"| node_mixer
node_ambient_ui -->|"controls"| node_mixer
node_sounds -->|"local tracks"| node_mixer
node_sandbox -.->|"limits file access"| node_import

click node_app "https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/LiveWallpaperApp.swift"
click node_shell "https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/ContentView.swift"
click node_windows "https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/WindowManager.swift"
click node_settings_view "https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/Views/SettingView.swift"
click node_preferences "https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/Singletons/UserSetting.swift"
click node_feedback "https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/Components/Toast.swift"
click node_import "https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/Views/VideoDropView.swift"
click node_analyzer "https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/Helpers/VidAnalyzer.swift"
click node_recents "https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/Views/Recent.swift"
click node_wallpaper "https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/Singletons/WallpaperManager.swift"
click node_player_bridge "https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/Components/PlayerLayerView.swift"
click node_occlusion "https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/Helpers/OvercastDetector.swift"
click node_ambient_ui "https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/Views/AmbientSounds.swift"
click node_mixer "https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/Singletons/AudioMixer.swift"
click node_sounds "https://github.com/ducbao414/live-wallpaper/tree/main/LiveWallpaper/Sounds"
click node_sandbox "https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/LiveWallpaper.entitlements"

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_shell,node_windows,node_settings_view,node_preferences,node_feedback toneBlue
class node_import,node_analyzer,node_recents,node_wallpaper,node_player_bridge,node_occlusion toneAmber
class node_ambient_ui,node_mixer,node_sounds toneMint
class node_sandbox toneNeutral
```

## Components

### SwiftUI surfaces

- [App entry](https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/LiveWallpaperApp.swift): SwiftUI app · `LiveWallpaper/LiveWallpaperApp.swift`
- [Control shell](https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/ContentView.swift): SwiftUI view · Coordinates media selection, recents, settings, and audio controls. · `LiveWallpaper/ContentView.swift`
- [Window manager](https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/WindowManager.swift): window control · Keeps controls available after the primary window closes. · `LiveWallpaper/WindowManager.swift`
- [Settings](https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/Views/SettingView.swift): SwiftUI view · `LiveWallpaper/Views/SettingView.swift`
- [User settings](https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/Singletons/UserSetting.swift): persistent state · Shared preferences for wallpaper and audio behavior. · `LiveWallpaper/Singletons/UserSetting.swift`
- [UI feedback components](https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/Components/Toast.swift): presentation components · Blur, progress, and toast presentation. · `LiveWallpaper/Components/Toast.swift`

### Video wallpaper

- [Video import](https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/Views/VideoDropView.swift): sandbox file input · Accepts user-selected or dropped videos. · `LiveWallpaper/Views/VideoDropView.swift`
- [Media analyzer](https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/Helpers/VidAnalyzer.swift): video validation · `LiveWallpaper/Helpers/VidAnalyzer.swift`
- [Recent videos](https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/Views/Recent.swift): media library UI · Presents persisted recent video choices. · `LiveWallpaper/Views/Recent.swift`
- [Wallpaper manager](https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/Singletons/WallpaperManager.swift): wallpaper controller · Installs, renders, and controls video wallpaper playback. · `LiveWallpaper/Singletons/WallpaperManager.swift`
- [Video player bridge](https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/Components/PlayerLayerView.swift): SwiftUI playback view · Bridges video rendering for wallpaper and preview contexts. · `LiveWallpaper/Components/PlayerLayerView.swift`
- [Occlusion detector](https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/Helpers/OvercastDetector.swift): visibility signal · Detects when application windows substantially cover the wallpaper. · `LiveWallpaper/Helpers/OvercastDetector.swift`

### Ambient audio

- [Ambient sound controls](https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/Views/AmbientSounds.swift): SwiftUI view · `LiveWallpaper/Views/AmbientSounds.swift`
- [Audio mixer](https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/Singletons/AudioMixer.swift): audio controller · Mixes concurrent ambient tracks with per-track volumes. · `LiveWallpaper/Singletons/AudioMixer.swift`
- [Bundled sound assets](https://github.com/ducbao414/live-wallpaper/tree/main/LiveWallpaper/Sounds): app resources · Local rain, beach, fire, and other ambient tracks. · `LiveWallpaper/Sounds`

### Other components

- [App sandbox and signing](https://github.com/ducbao414/live-wallpaper/blob/main/LiveWallpaper/LiveWallpaper.entitlements): macOS security boundary · Xcode target defines the sandboxed local application boundary. · `LiveWallpaper/LiveWallpaper.entitlements`

## Connections

- App entry → Control shell: launches
- App entry → Window manager: manages
- Control shell → Video import: selects video
- Control shell → Recent videos: shows
- Control shell → Settings: opens
- Control shell → Ambient sound controls: hosts
- Video import → Media analyzer: analyzes
- Media analyzer → Recent videos: retains selection
- Recent videos → Wallpaper manager: selected URL
- Wallpaper manager → Video player bridge: renders through
- Occlusion detector → Wallpaper manager: pause/resume signal
- Settings → User settings: updates
- User settings → Wallpaper manager: playback preferences
- User settings → Audio mixer: audio preferences
- Ambient sound controls → Audio mixer: controls
- Bundled sound assets → Audio mixer: local tracks
- App sandbox and signing → Video import: limits file access
