# lihaoyun6/quickrecorder architecture

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

- Interactive diagram: https://gitdiagram.com/lihaoyun6/quickrecorder
- Repository: https://github.com/lihaoyun6/quickrecorder

## Overview

##### Main Components
- User Interface (UI) Module: Represented by files like QuickRecorderApp.swift and many SwiftUI view files in the ViewModel folder (ContentView, SettingsView, etc.). This module handles the primary user interactions, application settings, and display features (status bar, main panel, preview view).
- Recording Engine: Core functional files such as RecordEngine.swift and AVContext.swift that manage screen capture, audio mix, and video capture.
- Utility and Support Modules: Located inside the Supports folder (AppleScript.swift, Sparkle.swift, SleepPreventer.swift, etc.). These provide additional functionalities like automation/scripting, external integrations (Sparkle for updates), and OS-level support.
- Assets and Resources: The Assets.xcassets directory, localization folders (Base.lproj, it.lproj, zh-Hans.lproj, zh-Hant.lproj), and configuration files (Info.plist, QuickRecorder.entitlements) hold all UI images, localized strings, and basic settings.
- External Libraries/Dependencies: Noted in the README (KeyboardShortcuts, SwiftLAME) which are used for handling shortcut keys and MP3 output respectively.
- Xcode Project and Build Infrastructure: The QuickRecorder.xcodeproj folder and related configuration files represent the project’s setup for building and testing.

##### Relationships and Interactions
- The UI Module sends user commands (e.g., “start recording,” “open settings”) to the Recording Engine.
- The Recording Engine interfaces with macOS AV frameworks (as suggested by files like AVContext.swift) to initiate video and audio capture and manage post-recording operations such as the optional audio track splitting.
- Utility modules interact with both the UI and core engine to manage support features such as AppleScript integration, window inspecting/highlighting (WindowAccessor.swift and WindowHighlighter.swift), and preventing the screen from sleeping during recording.
- External libraries are integrated within the respective modules (e.g., KeyboardShortcuts for handling hotkeys in the UI, SwiftLAME for encoding audio).

##### Architectural Patterns and Design Principles
- Separation of Concerns: The project clearly separates UI (ViewModel folder and main app file), core processing (RecordEngine.swift, AVContext.swift), and support utilities (Supports folder) to improve maintainability.
- Modular Design: Dividing functionalities into discreet modules (e.g., handling visuals, audio recording, scripting, and settings) suggests a modular, extensible architecture.
- Integration with External Services: The pull in of open-source libraries and usage of system-level libraries (AVFoundation) are significant aspects of the design.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Module
    subgraph "User Interface (UI) Module"
        UI_App["QuickRecorderApp.swift"]:::ui
        ContentView["ContentView.swift"]:::ui
        SettingsView["SettingsView.swift"]:::ui
    end

    %% Recording Engine
    subgraph "Recording Engine"
        RecordEngine["RecordEngine.swift"]:::engine
        AVContext["AVContext.swift"]:::engine
        SCContext["SCContext.swift"]:::engine
    end

    %% Utility and Support Modules
    subgraph "Utility & Support Modules"
        AppleScript["AppleScript.swift"]:::support
        Sparkle["Sparkle.swift"]:::support
        SleepPreventer["SleepPreventer.swift"]:::support
        WindowAccessor["WindowAccessor.swift"]:::support
        WindowHighlighter["WindowHighlighter.swift"]:::support
    end

    %% Assets and Resources
    subgraph "Assets & Resources"
        Assets["Assets.xcassets"]:::assets
        BaseLproj["Base.lproj"]:::assets
        ItLproj["it.lproj"]:::assets
        ZHHans["zh-Hans.lproj"]:::assets
        ZHHant["zh-Hant.lproj"]:::assets
        InfoPlist["Info.plist"]:::assets
        Entitlements["QuickRecorder.entitlements"]:::assets
    end

    %% External Libraries/Dependencies
    subgraph "External Libraries"
        KeyboardShortcuts["KeyboardShortcuts"]:::external
        SwiftLAME["SwiftLAME"]:::external
    end

    %% Xcode Project and Build Infrastructure
    subgraph "Build Infrastructure"
        XcodeProj["QuickRecorder.xcodeproj"]:::build
    end

    %% Relationships
    UI_App -->|"start/stop"| RecordEngine
    ContentView -->|"display"| RecordEngine
    RecordEngine -->|"utilizes"| AVContext
    RecordEngine -->|"utilizes"| SCContext
    UI_App -->|"integrates"| AppleScript
    UI_App -->|"integrates"| Sparkle
    UI_App -->|"integrates"| SleepPreventer
    UI_App -->|"integrates"| WindowAccessor
    UI_App -->|"integrates"| WindowHighlighter
    KeyboardShortcuts -->|"shortcuts"| UI_App
    RecordEngine -->|"audio_encoding"| SwiftLAME
    Assets -->|"resources"| UI_App
    XcodeProj -->|"builds"| UI_App
    XcodeProj -->|"builds"| RecordEngine
    XcodeProj -->|"builds"| AppleScript
    XcodeProj -->|"builds"| Assets

    %% Click Events
    click UI_App "https://github.com/lihaoyun6/quickrecorder/blob/main/QuickRecorder/QuickRecorderApp.swift"
    click ContentView "https://github.com/lihaoyun6/quickrecorder/blob/main/QuickRecorder/ViewModel/ContentView.swift"
    click SettingsView "https://github.com/lihaoyun6/quickrecorder/blob/main/QuickRecorder/ViewModel/SettingsView.swift"
    click RecordEngine "https://github.com/lihaoyun6/quickrecorder/blob/main/QuickRecorder/RecordEngine.swift"
    click AVContext "https://github.com/lihaoyun6/quickrecorder/blob/main/QuickRecorder/AVContext.swift"
    click SCContext "https://github.com/lihaoyun6/quickrecorder/blob/main/QuickRecorder/SCContext.swift"
    click AppleScript "https://github.com/lihaoyun6/quickrecorder/blob/main/QuickRecorder/Supports/AppleScript.swift"
    click Sparkle "https://github.com/lihaoyun6/quickrecorder/blob/main/QuickRecorder/Supports/Sparkle.swift"
    click SleepPreventer "https://github.com/lihaoyun6/quickrecorder/blob/main/QuickRecorder/Supports/SleepPreventer.swift"
    click WindowAccessor "https://github.com/lihaoyun6/quickrecorder/blob/main/QuickRecorder/Supports/WindowAccessor.swift"
    click WindowHighlighter "https://github.com/lihaoyun6/quickrecorder/blob/main/QuickRecorder/Supports/WindowHighlighter.swift"
    click Assets "https://github.com/lihaoyun6/quickrecorder/blob/main/QuickRecorder/Assets.xcassets"
    click BaseLproj "https://github.com/lihaoyun6/quickrecorder/blob/main/QuickRecorder/Base.lproj"
    click ItLproj "https://github.com/lihaoyun6/quickrecorder/blob/main/QuickRecorder/it.lproj"
    click ZHHans "https://github.com/lihaoyun6/quickrecorder/blob/main/QuickRecorder/zh-Hans.lproj"
    click ZHHant "https://github.com/lihaoyun6/quickrecorder/blob/main/QuickRecorder/zh-Hant.lproj"
    click InfoPlist "https://github.com/lihaoyun6/quickrecorder/blob/main/QuickRecorder/Info.plist"
    click Entitlements "https://github.com/lihaoyun6/quickrecorder/blob/main/QuickRecorder/QuickRecorder.entitlements"
    click XcodeProj "https://github.com/lihaoyun6/quickrecorder/blob/main/QuickRecorder.xcodeproj"

    %% Styles
    classDef ui fill:#C7E9F1,stroke:#000,stroke-width:2px;
    classDef engine fill:#F1C7C7,stroke:#000,stroke-width:2px;
    classDef support fill:#F1E9C7,stroke:#000,stroke-width:2px;
    classDef assets fill:#C7F1D1,stroke:#000,stroke-width:2px;
    classDef external fill:#E0C7F1,stroke:#000,stroke-width:2px;
    classDef build fill:#E9F1C7,stroke:#000,stroke-width:2px;
```
