# developeracademy-postech/2024-macc-a15-commandr architecture

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

- Interactive diagram: https://gitdiagram.com/developeracademy-postech/2024-macc-a15-commandr
- Repository: https://github.com/developeracademy-postech/2024-macc-a15-commandr

## Overview

##### Main Components
- iOS App (RhythmTokTok):
- User Interface Layer: Contains ViewControllers, custom Views (e.g., PDFUploadProgressView, TitleInputView).
- Business Logic / Managers: Modules under “Managers” (e.g., ServerManager, MediaManager, PDFConvertManager, IOStoWatchConnectivityManager) and utility classes under “Utils”.
- Data Persistence: The CoreData module (including CoreDataStack and entity classes for notes and scores).
- Models: Data structures (Note, Score, Request, Measure, etc.) and enumerations that define app-specific states.
- Resource Management: Assets (images, fonts, Lottie animations, PDFs, and sound files) located under “Assets.xcassets” and “Resources”.

- Apple Watch App (RhythmTokTokWatchApp):
- Watch UI Components: Watch-specific Views (e.g., WatchCountdownView, WatchPlayView).
- Connectivity Manager: For synchronizing data and commands between the iOS app and the Watch (e.g., WatchtoiOSConnectivityManager).
- Watch-specific assets and complication support through a separate directory and the “ComplicationWidget” component.

- Backend / Server Interaction:
- Server Component: Represented logically by the ServerManager (and PHP/MySQL-based backend mentioned in the README). This part handles PDF conversion status, notifications, and user-specific data uploads/downloads.

##### Relationship and Interactions
- The iOS front-end communicates with the managers (business logic components) which handle core functionalities such as media playback, PDF conversion, and data persistence.
- The Data Persistence layer (CoreData) interacts with the Models to store user data, settings, and historical scores.
- An API layer (ServerManager) provides network communication with the external server (PHP/MySQL backend), using JSON and possibly secure data transfer methods (noting the integration of CryptoSwift).
- The Watch App aspects connect via WatchConnectivity modules. Data and commands flow bidirectionally between the iOS app and the Apple Watch app to keep alarm, music control, and haptic feedback in sync.
- The ComplicationWidget offers a quick glance at information via Apple Watch complications, refreshing visuals based on app states.

##### Architectural Patterns and Technologies
- MVC (or a variant like MVVM) role separation: The Views (both in the iOS app and Watch app) are kept separate from the underlying business logic in the managers.
- Reactive programming is likely utilized through Combine, which indicates asynchronous data streams and binding between the UI and business logic.
- Use of CoreData for local persistence and integration of system frameworks such as UIKit, SwiftUI, AVFoundation, PDFKit, and UserNotifications.

- To one side, attach the Apple Watch app ecosystem (including its UI and connectivity module) and show lines of communication.
- Drill down into each area:
- For the UI layer, include key screens as noted (Settings, ScoreList, PDF conversion flow, etc.).
- Detail how PDF conversion requests flow from the UI to the ServerManager and how completed requests trigger notifications.
- Lifecycle of local data storage using CoreData.
- A distinct section for external libraries (CryptoSwift, Lottie) that factor into security and animations.
- For the Watch app, not only indicate its separate asset and connectivity handling but also mark its role in controlling metronome features and haptic feedback.

## Diagram (Mermaid)

```mermaid
graph TD
    %% iOS Application
    subgraph "iOS App (RhythmTokTok)"
        %% UI Layer
        subgraph "UI Layer"
            IV["\"ViewControllers\""]:::ui
            IV2["\"Views\""]:::ui
        end
        %% Business Logic / Managers
        subgraph "Business Logic"
            M["\"Managers\""]:::manager
        end
        %% Data Persistence
        subgraph "Data Persistence"
            CD["\"CoreData\""]:::db
        end
        %% Models
        subgraph "Models"
            MD["\"Models\""]:::model
        end
        %% Resource Management
        subgraph "Resources"
            AR["\"Assets.xcassets & Resources\""]:::resource
            CS["\"CryptoSwift\""]:::external
            FT["\"Fonts\""]:::external
            LT["\"Lottie\""]:::external
        end
    end

    %% Apple Watch Application
    subgraph "Apple Watch App (RhythmTokTokWatchApp)"
        %% Watch UI Components
        subgraph "Watch UI"
            WUI["\"Watch UI Components\""]:::uiWatch
        end
        %% Connectivity Manager Modules
        subgraph "Connectivity"
            WC["\"Watch Connectivity Manager\""]:::managerWatch
            HM["\"Haptic Schedule Manager\""]:::managerWatch
        end
        CW["\"Complication Widget\""]:::widget
    end

    %% External Server Component
    Backend["\"Server\""]:::server

    %% Connections within iOS App
    IV -->|"actions"| M
    IV2 -->|"actions"| M
    M -->|"persist"| CD
    CD -->|"data"| M
    M -->|"update"| MD
    M -->|"sync"| Backend
    M -->|"animation"| LT
    M -->|"security"| CS

    %% Watch Connectivity between iOS and Apple Watch App
    M -->|"watchConnect"| WC
    WC -->|"iOSResponse"| M
    WUI -->|"commands"| WC
    WC -->|"haptic"| HM
    HM -->|"feedback"| WUI

    %% Class definitions for color styling
    classDef ui fill:#ffcccc,stroke:#cc0000,stroke-width:2px;
    classDef manager fill:#ccffcc,stroke:#009900,stroke-width:2px;
    classDef db fill:#ffffcc,stroke:#999900,stroke-width:2px;
    classDef model fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef resource fill:#e6ccff,stroke:#6600cc,stroke-width:2px;
    classDef external fill:#c9daf8,stroke:#6fa8dc,stroke-width:2px;
    classDef uiWatch fill:#ffebcc,stroke:#cc6600,stroke-width:2px;
    classDef managerWatch fill:#d9ead3,stroke:#6aa84f,stroke-width:2px;
    classDef widget fill:#d0e0e3,stroke:#115577,stroke-width:2px;
    classDef server fill:#f4cccc,stroke:#cc0000,stroke-width:2px;

    %% Click Events from Component Mapping
    click IV "https://github.com/developeracademy-postech/2024-macc-a15-commandr/tree/dev/RhythmTokTok/ViewControllers"
    click IV2 "https://github.com/developeracademy-postech/2024-macc-a15-commandr/tree/dev/RhythmTokTok/Views"
    click M "https://github.com/developeracademy-postech/2024-macc-a15-commandr/tree/dev/RhythmTokTok/Managers"
    click CD "https://github.com/developeracademy-postech/2024-macc-a15-commandr/tree/dev/RhythmTokTok/CoreData"
    click MD "https://github.com/developeracademy-postech/2024-macc-a15-commandr/tree/dev/RhythmTokTok/Models"
    click AR "https://github.com/developeracademy-postech/2024-macc-a15-commandr/blob/dev/RhythmTokTok/Assets.xcassets"
    click CS "https://github.com/developeracademy-postech/2024-macc-a15-commandr/tree/dev/CryptoSwift"
    click FT "https://github.com/developeracademy-postech/2024-macc-a15-commandr/tree/dev/Fonts"
    click LT "https://github.com/developeracademy-postech/2024-macc-a15-commandr/tree/dev/Lottie"
    click WUI "https://github.com/developeracademy-postech/2024-macc-a15-commandr/tree/dev/RhythmTokTokWatchApp/View"
    click WC "https://github.com/developeracademy-postech/2024-macc-a15-commandr/blob/dev/RhythmTokTokWatchApp/Manager/WatchtoiOSConnectivityManager.swift"
    click HM "https://github.com/developeracademy-postech/2024-macc-a15-commandr/blob/dev/RhythmTokTokWatchApp/Manager/HapticScheduleManager.swift"
    click CW "https://github.com/developeracademy-postech/2024-macc-a15-commandr/tree/dev/ComplicationWidget"
    click Backend "https://github.com/developeracademy-postech/2024-macc-a15-commandr/blob/dev/RhythmTokTok/Managers/ServerManager.swift"
```
