# wkaisertexas/screentimelapse architecture

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

- Interactive diagram: https://gitdiagram.com/wkaisertexas/screentimelapse
- Repository: https://github.com/wkaisertexas/screentimelapse

## Overview

##### Main Components
- User Interface Layer:
- SwiftUI Views: Files such as ContentView.swift, OnboardingView.swift, PreferencesView.swift.
- View Models: OnboardingViewModel.swift, PreferencesViewModel.swift, RecorderViewModel.swift.
- Core Capture & Recording:
- Screen and Camera Modules: Camera.swift, CameraRecorder.swift, Recordable.swift.
- Recording Logic: VideoConfiguration.swift and the integration of hardware accelerated encoding.
- Data Management and Persistence:
- PersistenceManager.swift manages saving/retrieval of settings or recording data.
- Data Models: ScreenTimeLapse.xcdatamodeld representing Core Data models.
- Utilities and Support Modules:
- Logger.swift for logging actions and events.
- ReviewManager.swift for handling user feedback or reviews from within the app.
- Utils.swift for common helper functions.
- External Systems and Frameworks:
- Apple frameworks such as ScreenCaptureKit, AVFoundation, and CoreMedia.
- The integration with system features (like macOS’s menu bar functionality).

##### Architectural Patterns and Principles
- That the project uses a modular structure where recording, persistence, and utility services are decoupled.

##### Relevant Technologies, Frameworks, and Libraries
- SwiftUI – for declarative UI
- ScreenCaptureKit – for screen recording features
- AVFoundation & CoreMedia – for video processing and encoding
- Core Data (or similar persistence mechanism) – as suggested by the xcdatamodeld file for storing screen time lapse configurations/captured data

- Use clear labels for each block:
- “UI Layer” with subdivisions: “Menu Bar & SwiftUI Views” and “View Models” (Onboarding, Preferences, Recorder).
- “Capture & Recording Module” with subdivisions: “Screen Capture (CameraRecorder/Camera)”, “Recording Logic”, “Video Configuration”.
- “Data & Persistence” showing PersistenceManager and Data Model (ScreenTimeLapse).
- “Utilities” covering Logger, ReviewManager, Utils.
- “External Services” depicting third-party Apple frameworks.
- From “Capture Module” to “Data & Persistence” (store/retrieve configuration and video data).
- “Utilities” to both UI and core modules indicating contextual logging and review prompts.
- Rectangles for module blocks.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "UI Layer"
        subgraph "SwiftUI Views"
            CV("ContentView.swift"):::ui
            OV("OnboardingView.swift"):::ui
            PV("PreferencesView.swift"):::ui
        end
        subgraph "View Models"
            OVM("OnboardingViewModel.swift"):::ui
            PVM("PreferencesViewModel.swift"):::ui
            RVM("RecorderViewModel.swift"):::ui
        end
    end

    subgraph "Capture & Recording Module"
        CAM("Camera.swift"):::core
        CR("CameraRecorder.swift"):::core
        REC("Recordable.swift"):::core
        VC("VideoConfiguration.swift"):::core
    end

    subgraph "Data & Persistence"
        PM("PersistenceManager.swift"):::persistence
        SDM("ScreenTimeLapse.xcdatamodeld"):::persistence
    end

    subgraph "Utilities"
        LOG("Logger.swift"):::utilities
        RM("ReviewManager.swift"):::utilities
        UT("Utils.swift"):::utilities
    end

    subgraph "External Services"
        SC("ScreenCaptureKit"):::external
        AV("AVFoundation"):::external
        CM("CoreMedia"):::external
    end

    %% Relationships between UI Layer and Core Capture Module
    RVM -->|"startRecording"| CR

    %% Relationships within Capture Module
    CR -->|"usesCamera"| CAM
    CR -->|"applyConfig"| VC
    CR -->|"storeVideo"| PM

    %% Relationships between UI and Persistence
    PVM -->|"saveSettings"| PM

    %% Utilities interactions (cross-cutting concerns)
    RVM -->|"logs"| LOG
    CR -->|"logs"| LOG
    PVM -->|"feedback"| RM
    RVM -->|"helper"| UT
    CR -->|"helper"| UT

    %% External Services dependencies from Capture Module
    CR -->|"captureVia"| SC
    VC -->|"encodeVideo"| AV
    VC -->|"encodeMedia"| CM

    %% Persistence Data Model connection
    PM -->|"manageData"| SDM

    %% Styles
    classDef ui fill:#E0F7FA,stroke:#006064,stroke-width:2px;
    classDef core fill:#FFF9C4,stroke:#F57F17,stroke-width:2px;
    classDef persistence fill:#FFCCBC,stroke:#E64A19,stroke-width:2px;
    classDef utilities fill:#C8E6C9,stroke:#388E3C,stroke-width:2px;
    classDef external fill:#E1BEE7,stroke:#8E24AA,stroke-width:2px;

    %% Click Events
    click CV "https://github.com/wkaisertexas/screentimelapse/blob/main/TimeLapze/ContentView.swift"
    click OV "https://github.com/wkaisertexas/screentimelapse/blob/main/TimeLapze/OnboardingView.swift"
    click PV "https://github.com/wkaisertexas/screentimelapse/blob/main/TimeLapze/PreferencesView.swift"
    click OVM "https://github.com/wkaisertexas/screentimelapse/blob/main/TimeLapze/OnboardingViewModel.swift"
    click PVM "https://github.com/wkaisertexas/screentimelapse/blob/main/TimeLapze/PreferencesViewModel.swift"
    click RVM "https://github.com/wkaisertexas/screentimelapse/blob/main/TimeLapze/RecorderViewModel.swift"
    click CAM "https://github.com/wkaisertexas/screentimelapse/blob/main/TimeLapze/Camera.swift"
    click CR "https://github.com/wkaisertexas/screentimelapse/blob/main/TimeLapze/CameraRecorder.swift"
    click REC "https://github.com/wkaisertexas/screentimelapse/blob/main/TimeLapze/Recordable.swift"
    click VC "https://github.com/wkaisertexas/screentimelapse/blob/main/TimeLapze/VideoConfiguration.swift"
    click PM "https://github.com/wkaisertexas/screentimelapse/blob/main/TimeLapze/PersistenceManager.swift"
    click SDM "https://github.com/wkaisertexas/screentimelapse/blob/main/TimeLapze/ScreenTimeLapse.xcdatamodeld"
    click LOG "https://github.com/wkaisertexas/screentimelapse/blob/main/TimeLapze/Logger.swift"
    click RM "https://github.com/wkaisertexas/screentimelapse/blob/main/TimeLapze/ReviewManager.swift"
    click UT "https://github.com/wkaisertexas/screentimelapse/blob/main/TimeLapze/Utils.swift"
```
