# saumsy/macboard architecture

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

- Interactive diagram: https://gitdiagram.com/saumsy/macboard
- Repository: https://github.com/saumsy/macboard

## Overview

##### Project Type & Purpose
- Macboard is a native macOS desktop application (built in Swift/SwiftUI, packaged via Xcode).
- Purpose: a lightweight clipboard manager that captures system clipboard items, persists them, and displays them via a minimal UI with filtering and shortcuts.

##### File Structure
Top‑level:
- Macboard.xcodeproj & related workspace files – Xcode project.
- Macboard/ – Contains all source code & assets.
- MacboardTests/ – Unit tests.
- appcast.xml, README.md, LICENSE – metadata & release feed.
Inside Macboard/:
- App entrypoints: AppDelegate.swift & MacboardApp.swift
- Helpers – utility classes (DataHelper, Functions, ViewHelper)
- Models/DataModel – CoreData model + PersistenceController
- Views – SwiftUI screens (ClipboardItems, DetailedView, SettingsViews, etc.)
- Info.plist & entitlements – macOS permissions

##### Core Architectural Patterns
- MVVM‑style:
- Views (SwiftUI) bind to model data via helpers or ObservableObjects.
- PersistenceController handles CoreData stack.
- Modularization: Extensions, Helpers, Models, Views are distinct layers.
- System integration: macOS clipboard API and keyboard shortcuts.

##### Main Components & Their Interactions
a. User Interface Layer
- SwiftUI Views (Clipboard list, DetailedView, Settings)
- Reads from Models via DataHelper/ViewHelper; writes user actions back.
b. Persistence Layer
- CoreData stack (PersistenceController, ClipboardItem entity)
- DataHelper mediates fetch/save operations.
c. System Clipboard Service
- macOS NSPasteboard observer (likely in Helpers or AppDelegate)
- Pushes new clipboard items into Persistence Layer.
d. Application Core
- AppDelegate/MacboardApp – handles lifecycle, hotkey registration, permissions.
e. Settings & Defaults
- UserDefaults extensions for storing configuration (shortcut mappings, theme, storage limits).
f. External Services
- System theme detection, file system (for DMG installation), optionally network for appcast.xml updates.

##### Important Patterns & Technologies
- SwiftUI’s declarative UI binds to @Published data from CoreData via NSFetchedResultsController or custom publishers.
- CoreData for local storage of clipboard history.
- UserDefaults for lightweight settings.
- macOS services: NSPasteboard, global hotkeys via MASShortcut or native APIs (in KeyboardShortcuts++).

##### Final Checklist
- Title (“Macboard High‑Level Architecture”) and version/date.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Interface Layer
    subgraph "User Interface (SwiftUI Views)"
        direction TB
        UI1["ClipboardItems"]:::ui
        UI2["DetailedView"]:::ui
        UI3["Accessibility"]:::ui
        UI4["Updates"]:::ui
        UI5["AboutSettingsView"]:::ui
        UI6["GeneralSettingsView"]:::ui
        UI7["KeyboardSettingsView"]:::ui
        UI8["StorageSettingsView"]:::ui
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        direction TB
        DB[(ClipboardItem Entity)]:::persistence
        PC["PersistenceController"]:::persistence
    end

    %% System Services
    subgraph "System Services (macOS)"
        direction TB
        NS["NSPasteboard Listener"]:::system
    end

    %% Keyboard Shortcuts Manager
    subgraph "Keyboard Shortcuts Manager"
        direction TB
        KM["KeyboardShortcuts++"]:::system
    end

    %% Settings & Defaults
    subgraph "Settings & Defaults"
        direction TB
        UD["Defaults++"]:::config
        US["Settings++"]:::config
    end

    %% Business Logic Helpers
    subgraph "Business Logic Helpers"
        direction TB
        BH1["DataHelper"]:::logic
        BH2["Functions"]:::logic
        BH3["ViewHelper"]:::logic
    end

    %% Generic Extensions
    subgraph "Extensions (Utilities)"
        direction TB
        EX1["Bool+Comparable"]:::extension
        EX2["Color+Hex"]:::extension
        EX3["Date+TimeAgo"]:::extension
        EX4["String++"]:::extension
        EX5["View++"]:::extension
    end

    %% Application Core
    subgraph "Application Core"
        direction TB
        AC1["MacboardApp"]:::system
        AC2["AppDelegate"]:::system
    end

    %% Assets
    subgraph "Assets"
        direction TB
        AS["Assets.xcassets"]:::config
    end

    %% External Services
    subgraph "External Services"
        direction TB
        ES["appcast.xml"]:::config
    end

    %% Connections
    NS -->|"observe"| PC
    PC -->|"store/retrieve"| DB
    DB -->|"model data"| PC
    UI1 -->|"fetch/save"| PC
    UI2 -->|"modify/delete"| PC
    UI5 -->|"read/write"| UD
    UI6 -->|"read/write"| UD
    UI7 -->|"read/write"| UD
    UI8 -->|"read/write"| UD
    AC2 -->|"register hotkeys"| KM
    KM -->|"toggle UI"| UI1
    KM -->|"toggle UI"| UI2
    UI1 -->|"use helpers"| BH3
    UI2 -->|"use helpers"| BH3
    BH1 -->|"wraps PC"| PC
    BH2 -->|"utility funcs"| UI1
    EX4 -->|"string utils"| BH1
    EX2 -->|"color utils"| UI1

    %% Click Events
    click UI1 "https://github.com/saumsy/macboard/blob/main/Macboard/Views/ClipboardItems.swift"
    click UI2 "https://github.com/saumsy/macboard/blob/main/Macboard/Views/DetailedView.swift"
    click UI3 "https://github.com/saumsy/macboard/blob/main/Macboard/Views/Accessibility.swift"
    click UI4 "https://github.com/saumsy/macboard/blob/main/Macboard/Views/Updates.swift"
    click UI5 "https://github.com/saumsy/macboard/blob/main/Macboard/Views/SettingsViews/AboutSettingsView.swift"
    click UI6 "https://github.com/saumsy/macboard/blob/main/Macboard/Views/SettingsViews/GeneralSettingsView.swift"
    click UI7 "https://github.com/saumsy/macboard/blob/main/Macboard/Views/SettingsViews/KeyboardSettingsView.swift"
    click UI8 "https://github.com/saumsy/macboard/blob/main/Macboard/Views/SettingsViews/StorageSettingsView.swift"
    click DB "https://github.com/saumsy/macboard/blob/main/Macboard/Models/DataModel/ClipboardItem.xcdatamodeld"
    click PC "https://github.com/saumsy/macboard/blob/main/Macboard/Models/DataModel/PersistanceController.swift"
    click AC2 "https://github.com/saumsy/macboard/blob/main/Macboard/AppDelegate.swift"
    click KM "https://github.com/saumsy/macboard/blob/main/Macboard/Extensions/KeyboardShortcuts++.swift"
    click UD "https://github.com/saumsy/macboard/blob/main/Macboard/Extensions/Defaults++.swift"
    click US "https://github.com/saumsy/macboard/blob/main/Macboard/Extensions/Settings++.swift"
    click BH1 "https://github.com/saumsy/macboard/blob/main/Macboard/Helpers/DataHelper.swift"
    click BH2 "https://github.com/saumsy/macboard/blob/main/Macboard/Helpers/Functions.swift"
    click BH3 "https://github.com/saumsy/macboard/blob/main/Macboard/Helpers/ViewHelper.swift"
    click EX1 "https://github.com/saumsy/macboard/blob/main/Macboard/Extensions/Bool+Comparable.swift"
    click EX2 "https://github.com/saumsy/macboard/blob/main/Macboard/Extensions/Color+Hex.swift"
    click EX3 "https://github.com/saumsy/macboard/blob/main/Macboard/Extensions/Date+TimeAgo.swift"
    click EX4 "https://github.com/saumsy/macboard/blob/main/Macboard/Extensions/String++.swift"
    click EX5 "https://github.com/saumsy/macboard/blob/main/Macboard/Extensions/View++.swift"
    click AC1 "https://github.com/saumsy/macboard/blob/main/Macboard/MacboardApp.swift"
    click AS "https://github.com/saumsy/macboard/blob/main/Macboard/Assets.xcassets"
    click ES "https://github.com/saumsy/macboard/blob/main/appcast.xml"

    %% Styles
    classDef ui fill:#e0f3e0,stroke:#2d7a2d
    classDef logic fill:#e0ecf8,stroke:#316ac5
    classDef persistence fill:#fde8d8,stroke:#d97706
    classDef system fill:#f3e8fd,stroke:#7c3aed
    classDef config fill:#f3f4f6,stroke:#6b7280
    classDef extension fill:#eef2ff,stroke:#4338ca
```
