# pakerwreah/calendr architecture

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

- Interactive diagram: https://gitdiagram.com/pakerwreah/calendr
- Repository: https://github.com/pakerwreah/calendr

## Overview

##### Overall System Type and Purpose
- This is a full desktop application focused on rendering a menu bar calendar on macOS.
- It is implemented as an Xcode project (likely in Swift) and follows modern design patterns (e.g., MVVM) to separate concerns between the UI, business logic, and data providers.

##### Major Architectural Layers and Components
- Application Shell & Configuration:
– The Calendr.xcodeproj and Config directory hold build configurations, environment settings, and bridging headers. Include a “Configuration” or “App Bootstrap” block.
- UI Components (Presentation Layer):
– Frontend views and controls are spread over several directories:
▸ Main: Contains AppDelegate, main view controller, and handling of main application events and keyboard shortcuts.
▸ Calendar & MenuBar: Contains views and view models for rendering the calendar UI, event lists, next event displays, status item views, and context menus.
▸ Settings: Separate settings screens for appearance, auto-launch, auto-updater, etc.
▸ Previews: Contains code used to render SwiftUI previews and UI testing aids.
- Business Logic and Domain Model Layer:
– Models: Contains the definitions for calendars, events, date ranges, and other domain entities.
– View Models: Look at the various “ViewModel” classes placed in folders like Calendar, MenuBar, Events, and Settings. They encapsulate business logic and state management for each UI component.
- Service Providers (Back-end / Data Layer):
– Providers: Includes CalendarServiceProvider, DateProvider, GeocodeServiceProvider, LocalNotificationProvider, NetworkServiceProvider, ScreenProvider, SoundPlayer, WeatherServiceProvider, and WorkspaceServiceProvider.
– These components abstract out system services, external data integrations, and notifications.
- Extensions & Utilities:
– Extensions: Contains helper methods and category extensions to standard library types and AppKit components (NSView, NSButton, date formatters, etc.).
– Utils: Holds common utilities (e.g., caching, date parsing, etc.) and technical support classes for things like Sentry integration and testing hooks.
- Automation & Events:
– Automation: Contains scripts for AppleScript and calendar integration logic.
– Events: Implements event management and details logic across background processing and contextual menus.
- Testing and Mocks:
– CalendrTests and CalendrUITests directories hold the test cases.
– Mocks directories under both the main app and the test folders indicate dependency injection points for service providers, allowing simulation of external data/services for reliable testing.

##### Final Assembly
- Every major directory and file group (Assets, Calendar, Components, Providers, etc.) is represented.
- That the testing/mocking layer is depicted as supporting infrastructure for proper dependency substitution.

## Diagram (Mermaid)

```mermaid
graph TD
    CalendrApp("Calendr Application"):::app

    %% Configuration & Bootstrapping
    subgraph "Configuration & Bootstrapping"
        Xcode("Xcode Project"):::config
        ConfigDir("Configuration Directory"):::config
    end

    %% UI/Presentation Layer
    subgraph "UI/Presentation Layer"
        Main("Main (AppDelegate, MainViewController)"):::ui
        CalView("Calendar Views"):::ui
        MenuBar("MenuBar & Status Items"):::ui
        Settings("Settings Screens"):::ui
        Assets("Assets (Images, Icons, Strings)"):::ui
        Previews("Previews (SwiftUI & Testing)"):::ui
    end

    %% Business Logic & Domain Models
    subgraph "Business Logic & Domain Models"
        DModels("Domain Models"):::domain
        subgraph "View Models"
            CVM("CalendarViewModel"):::vm
            NEVM("NextEventViewModel"):::vm
            SIVM("StatusItemViewModel"):::vm
            EDVM("EventDetailsViewModel"):::vm
            ELVM("EventListViewModel"):::vm
            EVM("EventViewModel"):::vm
            CPVM("CalendarPickerViewModel"):::vm
            SMVM("SettingsViewModel"):::vm
        end
    end

    %% Service Providers
    subgraph "Service Providers"
        Providers("Providers"):::provider
    end

    %% Extensions & Utilities
    subgraph "Extensions & Utilities"
        Extensions("Extensions"):::util
        Utils("Utils"):::util
    end

    %% Automation & Events
    subgraph "Automation & Events"
        Automation("Automation Scripts"):::automation
        EventMgr("Event Manager"):::automation
    end

    %% Testing & Mocks
    subgraph "Testing & Mocks"
        Tests("Tests (Unit & UI)"):::test
        Mocks("Mocks"):::test
    end

    %% Core Application Relationships
    CalendrApp --> Xcode
    CalendrApp --> ConfigDir
    CalendrApp --> Main
    CalendrApp --> CalView
    CalendrApp --> MenuBar
    CalendrApp --> Settings
    CalendrApp --> Assets
    CalendrApp --> Previews
    CalendrApp --> DModels
    CalendrApp --> CVM
    CalendrApp --> NEVM
    CalendrApp --> SIVM
    CalendrApp --> EDVM
    CalendrApp --> ELVM
    CalendrApp --> EVM
    CalendrApp --> CPVM
    CalendrApp --> SMVM
    CalendrApp --> Providers
    CalendrApp --> Extensions
    CalendrApp --> Utils
    CalendrApp --> Automation
    CalendrApp --> EventMgr
    CalendrApp --> Tests
    CalendrApp --> Mocks

    %% UI to ViewModel Interactions
    Main -->|"triggers"| CVM
    CalView -->|"renders"| CVM
    MenuBar -->|"updates"| NEVM
    MenuBar -->|"updates"| SIVM
    Settings -->|"configures"| CPVM
    Settings -->|"configures"| SMVM

    %% ViewModels to Domain Models
    CVM -->|"updates"| DModels
    NEVM -->|"updates"| DModels
    SIVM -->|"updates"| DModels
    EDVM -->|"updates"| DModels
    ELVM -->|"updates"| DModels
    EVM -->|"updates"| DModels
    CPVM -->|"updates"| DModels
    SMVM -->|"updates"| DModels

    %% ViewModels to Service Providers
    CVM -->|"fetches"| Providers
    NEVM -->|"fetches"| Providers
    SIVM -->|"fetches"| Providers
    EDVM -->|"fetches"| Providers
    ELVM -->|"fetches"| Providers
    EVM -->|"fetches"| Providers
    CPVM -->|"fetches"| Providers
    SMVM -->|"fetches"| Providers

    %% Automation & Events interactions
    Automation -->|"triggers"| Providers
    EventMgr -->|"manages"| Providers

    %% Testing interactions
    Tests -->|"validates"| Mocks
    Tests -->|"simulates"| Providers

    %% Extensions & Utilities support
    Extensions -->|"supports"| DModels
    Utils -->|"supports"| DModels
    Extensions -->|"supports"| Main
    Utils -->|"supports"| Main

    %% Styling Classes
    classDef app fill:#f9f,stroke:#333,stroke-width:2px;
    classDef config fill:#bbf,stroke:#333,stroke-width:2px;
    classDef ui fill:#cfc,stroke:#333,stroke-width:2px;
    classDef domain fill:#fc9,stroke:#333,stroke-width:2px;
    classDef vm fill:#fcf,stroke:#333,stroke-width:2px;
    classDef provider fill:#9cf,stroke:#333,stroke-width:2px;
    classDef util fill:#ff9,stroke:#333,stroke-width:2px;
    classDef automation fill:#9f9,stroke:#333,stroke-width:2px;
    classDef test fill:#f99,stroke:#333,stroke-width:2px;

    %% Click Events
    click Xcode "https://github.com/pakerwreah/calendr/blob/master/Calendr.xcodeproj"
    click ConfigDir "https://github.com/pakerwreah/calendr/tree/master/Calendr/Config"
    click Main "https://github.com/pakerwreah/calendr/tree/master/Calendr/Main"
    click CalView "https://github.com/pakerwreah/calendr/tree/master/Calendr/Calendar"
    click MenuBar "https://github.com/pakerwreah/calendr/tree/master/Calendr/MenuBar"
    click Settings "https://github.com/pakerwreah/calendr/tree/master/Calendr/Settings"
    click Assets "https://github.com/pakerwreah/calendr/tree/master/Calendr/Assets"
    click Previews "https://github.com/pakerwreah/calendr/tree/master/Calendr/Previews"
    click DModels "https://github.com/pakerwreah/calendr/tree/master/Calendr/Models"
    click CVM "https://github.com/pakerwreah/calendr/tree/master/Calendr/Calendar"
    click NEVM "https://github.com/pakerwreah/calendr/tree/master/Calendr/MenuBar"
    click SIVM "https://github.com/pakerwreah/calendr/tree/master/Calendr/MenuBar"
    click EDVM "https://github.com/pakerwreah/calendr/tree/master/Calendr/Events"
    click ELVM "https://github.com/pakerwreah/calendr/tree/master/Calendr/Events"
    click EVM "https://github.com/pakerwreah/calendr/tree/master/Calendr/Events"
    click CPVM "https://github.com/pakerwreah/calendr/tree/master/Calendr/Settings"
    click SMVM "https://github.com/pakerwreah/calendr/tree/master/Calendr/Settings"
    click Providers "https://github.com/pakerwreah/calendr/tree/master/Calendr/Providers"
    click Extensions "https://github.com/pakerwreah/calendr/tree/master/Calendr/Extensions"
    click Utils "https://github.com/pakerwreah/calendr/tree/master/Calendr/Utils"
    click Automation "https://github.com/pakerwreah/calendr/tree/master/Calendr/Automation"
    click EventMgr "https://github.com/pakerwreah/calendr/tree/master/Calendr/Events"
    click Tests "https://github.com/pakerwreah/calendr/tree/master/CalendrTests"
    click Mocks "https://github.com/pakerwreah/calendr/tree/master/Calendr/Mocks"
```
