# atpugvaraa/cisum architecture

> Architecture diagram of the GitHub repository atpugvaraa/cisum, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/atpugvaraa/cisum
- Repository: https://github.com/atpugvaraa/cisum

## Overview

#### Purpose and Targets
Cisum is a native Swift/SwiftUI music-player application with shared product logic and separate iOS and macOS hosts. It supports music discovery/search, playback and now-playing surfaces, playlist library/import, caching, and platform-integrated lyrics/live activities.

#### Application Entry Points
- iOS app bootstrap: `iOS/cisum/iOSApp.swift`; its root UI is `iOS/cisum/Views/ContentView.swift`.
- macOS host: `macOS/cisum/macOSApp.swift` and `macOS/cisum/ContentView.swift`.
- The iOS Lyrics extension/widget target is rooted at `iOS/Lyrics/LyricsBundle.swift`, with Live Activity and control implementations in `iOS/Lyrics/LyricsLiveActivity.swift` and `iOS/Lyrics/LyricsControl.swift`.
- Shared startup/service wiring is centralized in `Shared/Core/Services/AppBootstrap.swift`.

#### Shared State, Navigation, and Presentation
SwiftUI observable view models coordinate major screens: `Shared/Core/Observables/HomeViewModel.swift`, `Shared/Core/Observables/SearchViewModel.swift`, and `Shared/Core/Observables/PlayerViewModel.swift`. Navigation is abstracted from screens through `Shared/Navigation/Router.swift` and injected via `Shared/Core/Helpers/EnvironmentKeys/RouterEnvironmentKey.swift`. Player UI is intentionally reusable across surfaces through `Shared/Player/PlayerSurfaces.swift`, `Shared/Player/NowPlayingView.swift`, and `Shared/Player/DynamicPlayerIsland.swift`.

#### Discovery and Search Flow
The iOS tab/screen layer exposes Home, Discover, Search, and Library; representative roots are `iOS/cisum/Views/Home/HomeView.swift`, `iOS/cisum/Views/Discover/DiscoverView.swift`, and `iOS/cisum/Views/Search/SearchView.swift`. Search state feeds persistent/history and cache-hint services (`Shared/Core/Services/SearchHistoryStore.swift`, `Shared/Core/Services/SearchCacheHintStore.swift`) plus cached result storage in `Shared/Caching/SearchResultsCache.swift`. Suggestions are ranked at the service boundary by `Shared/Core/Services/SuggestionRanker.swift`.

#### Playback and Media Pipeline
`PlayerViewModel` is the primary control boundary between UI and playback state. Playback views use shared controls/sliders and consume artwork/metadata helpers. Metadata is normalized before presentation (`Shared/Core/Helpers/MusicMetadataNormalizer.swift`); video metadata can be cached (`Shared/Caching/VideoMetadataCache.swift`). Artwork processing, dominant-color extraction, and cache persistence are separated into `Shared/Core/Services/ArtworkVideoProcessor.swift`, `Shared/Core/Services/ArtworkDominantColorExtractor.swift`, and `Shared/Core/Services/MediaCacheStore.swift`. System-oriented controls include AirPlay and volume-button skipping (`Shared/Components/Buttons/AirPlayButton.swift`, `Shared/Core/Services/VolumeButtonSkipController.swift`).

#### Library and YouTube Import
Library persistence is modeled around playlists and playlist items (`Shared/Core/Models/CisumPlaylist.swift`, `Shared/Core/Models/CisumPlaylistItem.swift`) and managed by `Shared/Core/Services/PlaylistLibraryStore.swift`. The library UI and detail view are `iOS/cisum/Views/Library/LibraryView.swift` and `Shared/Library/PlaylistDetailView.swift`. YouTube playlist import is a staged boundary: UI sheet → `Shared/Core/Services/YouTubePlaylistImportService.swift` → job persistence in `Shared/Core/Services/PlaylistImportJobStore.swift`, using candidate/job/track entry models.

#### Infrastructure and Platform Boundaries
The project is built through separate Xcode projects/workspace: `iOS/iOS.xcodeproj`, `macOS/macOS.xcodeproj`, and `cisum.xcworkspace`. Swift Package dependencies are lockfile-managed under `cisum.xcworkspace/xcshareddata/swiftpm/Package.resolved`. iOS capabilities are declared in `iOS/cisum/cisum.entitlements`; the network condition boundary is monitored by `Shared/Core/Services/NetworkPathMonitor.swift`. Shared asset catalogs supply player imagery and icons in `Shared/Assets/Assets.xcassets`.

Main entry points: [`Shared/Core/Observables/PlayerViewModel.swift`](https://github.com/atpugvaraa/cisum/blob/main/Shared/Core/Observables/PlayerViewModel.swift) (Player View Model), [`Shared/Core/Services/AppBootstrap.swift`](https://github.com/atpugvaraa/cisum/blob/main/Shared/Core/Services/AppBootstrap.swift) (App Bootstrap), [`Shared/Core/Observables/HomeViewModel.swift`](https://github.com/atpugvaraa/cisum/blob/main/Shared/Core/Observables/HomeViewModel.swift) (Screen View Models), [`iOS/cisum/Views/ContentView.swift`](https://github.com/atpugvaraa/cisum/blob/main/iOS/cisum/Views/ContentView.swift) (iOS Root UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_hosts["App Hosts"]
  node_ios_app["iOS App<br/>SwiftUI host<br/>[iOSApp.swift]"]
  node_ios_content["iOS Root UI<br/>SwiftUI root<br/>[ContentView.swift]"]
  node_macos_app["macOS App<br/>SwiftUI host<br/>[macOSApp.swift]"]
end

subgraph group_ui["Shared UI &amp; State"]
  node_router["Router<br/>navigation<br/>[Router.swift]"]
  node_screen_viewmodels["Screen View Models<br/>observable state"]
  node_discovery_screens["Discovery Screens<br/>SwiftUI screens<br/>[HomeView.swift]"]
  node_player_surfaces["Player Surfaces<br/>reusable SwiftUI"]
  node_player_viewmodel{{"Player View Model<br/>playback boundary"}}
  node_library_ui["Library UI<br/>SwiftUI screens<br/>[LibraryView.swift]"]
end

subgraph group_services["Domain Services"]
  node_bootstrap{{"App Bootstrap<br/>service wiring<br/>[AppBootstrap.swift]"}}
  node_search_services["Search Services<br/>search state"]
  node_search_cache[("Search Results Cache")]
  node_media_pipeline["Media Pipeline<br/>metadata and artwork"]
  node_media_cache[("Media Cache Store<br/>cache persistence")]
  node_playlist_library[("Playlist Library Store<br/>library persistence")]
  node_youtube_import["YouTube Playlist Import<br/>staged import"]
  node_import_jobs[("Import Job Store<br/>job persistence")]
end

subgraph group_platform["Platform Integration"]
  node_lyrics_extension["Lyrics Extension<br/>widget extension<br/>[LyricsBundle.swift]"]
  node_system_controls["System Playback Controls<br/>platform controls"]
  node_network_monitor["Network Path Monitor<br/>connectivity boundary"]
end

node_ios_app -->|"hosts"| node_ios_content
node_ios_app -->|"starts"| node_bootstrap
node_macos_app -->|"starts"| node_bootstrap
node_bootstrap -->|"wires"| node_router
node_bootstrap -->|"wires"| node_screen_viewmodels
node_ios_content -->|"presents"| node_discovery_screens
node_discovery_screens -->|"navigates via"| node_router
node_discovery_screens -->|"binds"| node_screen_viewmodels
node_screen_viewmodels -->|"search state"| node_search_services
node_search_services -->|"reads and writes"| node_search_cache
node_ios_content -->|"presents"| node_library_ui
node_library_ui -->|"manages"| node_playlist_library
node_library_ui -->|"imports"| node_youtube_import
node_youtube_import -->|"persists jobs"| node_import_jobs
node_screen_viewmodels -->|"selects media"| node_player_viewmodel
node_player_viewmodel -->|"drives"| node_player_surfaces
node_player_viewmodel -->|"requests metadata"| node_media_pipeline
node_media_pipeline -->|"persists media"| node_media_cache
node_player_viewmodel -->|"integrates"| node_system_controls
node_player_viewmodel -->|"updates now playing"| node_lyrics_extension
node_bootstrap -->|"monitors connectivity"| node_network_monitor

click node_ios_app "https://github.com/atpugvaraa/cisum/blob/main/iOS/cisum/iOSApp.swift"
click node_ios_content "https://github.com/atpugvaraa/cisum/blob/main/iOS/cisum/Views/ContentView.swift"
click node_macos_app "https://github.com/atpugvaraa/cisum/blob/main/macOS/cisum/macOSApp.swift"
click node_bootstrap "https://github.com/atpugvaraa/cisum/blob/main/Shared/Core/Services/AppBootstrap.swift"
click node_router "https://github.com/atpugvaraa/cisum/blob/main/Shared/Navigation/Router.swift"
click node_screen_viewmodels "https://github.com/atpugvaraa/cisum/blob/main/Shared/Core/Observables/HomeViewModel.swift"
click node_discovery_screens "https://github.com/atpugvaraa/cisum/blob/main/iOS/cisum/Views/Home/HomeView.swift"
click node_search_services "https://github.com/atpugvaraa/cisum/blob/main/Shared/Core/Services/SearchHistoryStore.swift"
click node_search_cache "https://github.com/atpugvaraa/cisum/blob/main/Shared/Caching/SearchResultsCache.swift"
click node_player_surfaces "https://github.com/atpugvaraa/cisum/blob/main/Shared/Player/PlayerSurfaces.swift"
click node_player_viewmodel "https://github.com/atpugvaraa/cisum/blob/main/Shared/Core/Observables/PlayerViewModel.swift"
click node_media_pipeline "https://github.com/atpugvaraa/cisum/blob/main/Shared/Core/Helpers/MusicMetadataNormalizer.swift"
click node_media_cache "https://github.com/atpugvaraa/cisum/blob/main/Shared/Core/Services/MediaCacheStore.swift"
click node_playlist_library "https://github.com/atpugvaraa/cisum/blob/main/Shared/Core/Services/PlaylistLibraryStore.swift"
click node_library_ui "https://github.com/atpugvaraa/cisum/blob/main/iOS/cisum/Views/Library/LibraryView.swift"
click node_youtube_import "https://github.com/atpugvaraa/cisum/blob/main/Shared/Core/Services/YouTubePlaylistImportService.swift"
click node_import_jobs "https://github.com/atpugvaraa/cisum/blob/main/Shared/Core/Services/PlaylistImportJobStore.swift"
click node_lyrics_extension "https://github.com/atpugvaraa/cisum/blob/main/iOS/Lyrics/LyricsBundle.swift"
click node_system_controls "https://github.com/atpugvaraa/cisum/blob/main/Shared/Core/Services/VolumeButtonSkipController.swift"
click node_network_monitor "https://github.com/atpugvaraa/cisum/blob/main/Shared/Core/Services/NetworkPathMonitor.swift"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_ios_app,node_ios_content,node_macos_app toneBlue
class node_router,node_screen_viewmodels,node_discovery_screens,node_player_surfaces,node_player_viewmodel,node_library_ui toneAmber
class node_bootstrap,node_search_services,node_search_cache,node_media_pipeline,node_media_cache,node_playlist_library,node_youtube_import,node_import_jobs toneMint
class node_lyrics_extension,node_system_controls,node_network_monitor toneRose
```

## Components

### App Hosts

- [iOS App](https://github.com/atpugvaraa/cisum/blob/main/iOS/cisum/iOSApp.swift): SwiftUI host · `iOS/cisum/iOSApp.swift`
- [iOS Root UI](https://github.com/atpugvaraa/cisum/blob/main/iOS/cisum/Views/ContentView.swift): SwiftUI root · `iOS/cisum/Views/ContentView.swift`
- [macOS App](https://github.com/atpugvaraa/cisum/blob/main/macOS/cisum/macOSApp.swift): SwiftUI host · `macOS/cisum/macOSApp.swift`

### Shared UI & State

- [Router](https://github.com/atpugvaraa/cisum/blob/main/Shared/Navigation/Router.swift): navigation · Injected navigation boundary for screens. · `Shared/Navigation/Router.swift`
- [Screen View Models](https://github.com/atpugvaraa/cisum/blob/main/Shared/Core/Observables/HomeViewModel.swift): observable state · Home, search, and player presentation state. · `Shared/Core/Observables/HomeViewModel.swift`
- [Discovery Screens](https://github.com/atpugvaraa/cisum/blob/main/iOS/cisum/Views/Home/HomeView.swift): SwiftUI screens · Home, Discover, and Search entry surfaces. · `iOS/cisum/Views/Home/HomeView.swift`
- [Player Surfaces](https://github.com/atpugvaraa/cisum/blob/main/Shared/Player/PlayerSurfaces.swift): reusable SwiftUI · Now-playing and dynamic player island UI. · `Shared/Player/PlayerSurfaces.swift`
- [Player View Model](https://github.com/atpugvaraa/cisum/blob/main/Shared/Core/Observables/PlayerViewModel.swift): playback boundary · Primary UI control boundary for playback state. · `Shared/Core/Observables/PlayerViewModel.swift`
- [Library UI](https://github.com/atpugvaraa/cisum/blob/main/iOS/cisum/Views/Library/LibraryView.swift): SwiftUI screens · Library and playlist detail presentation. · `iOS/cisum/Views/Library/LibraryView.swift`

### Domain Services

- [App Bootstrap](https://github.com/atpugvaraa/cisum/blob/main/Shared/Core/Services/AppBootstrap.swift): service wiring · Central shared startup and service composition. · `Shared/Core/Services/AppBootstrap.swift`
- [Search Services](https://github.com/atpugvaraa/cisum/blob/main/Shared/Core/Services/SearchHistoryStore.swift): search state · History, cache hints, and suggestion ranking. · `Shared/Core/Services/SearchHistoryStore.swift`
- [Search Results Cache](https://github.com/atpugvaraa/cisum/blob/main/Shared/Caching/SearchResultsCache.swift): cache · `Shared/Caching/SearchResultsCache.swift`
- [Media Pipeline](https://github.com/atpugvaraa/cisum/blob/main/Shared/Core/Helpers/MusicMetadataNormalizer.swift): metadata and artwork · Normalizes metadata and processes artwork colors. · `Shared/Core/Helpers/MusicMetadataNormalizer.swift`
- [Media Cache Store](https://github.com/atpugvaraa/cisum/blob/main/Shared/Core/Services/MediaCacheStore.swift): cache persistence · `Shared/Core/Services/MediaCacheStore.swift`
- [Playlist Library Store](https://github.com/atpugvaraa/cisum/blob/main/Shared/Core/Services/PlaylistLibraryStore.swift): library persistence · Manages playlist and playlist-item models. · `Shared/Core/Services/PlaylistLibraryStore.swift`
- [YouTube Playlist Import](https://github.com/atpugvaraa/cisum/blob/main/Shared/Core/Services/YouTubePlaylistImportService.swift): staged import · Creates persisted playlist import jobs from UI requests. · `Shared/Core/Services/YouTubePlaylistImportService.swift`
- [Import Job Store](https://github.com/atpugvaraa/cisum/blob/main/Shared/Core/Services/PlaylistImportJobStore.swift): job persistence · `Shared/Core/Services/PlaylistImportJobStore.swift`

### Platform Integration

- [Lyrics Extension](https://github.com/atpugvaraa/cisum/blob/main/iOS/Lyrics/LyricsBundle.swift): widget extension · Live Activity and control target. · `iOS/Lyrics/LyricsBundle.swift`
- [System Playback Controls](https://github.com/atpugvaraa/cisum/blob/main/Shared/Core/Services/VolumeButtonSkipController.swift): platform controls · AirPlay and volume-button skip integration. · `Shared/Core/Services/VolumeButtonSkipController.swift`
- [Network Path Monitor](https://github.com/atpugvaraa/cisum/blob/main/Shared/Core/Services/NetworkPathMonitor.swift): connectivity boundary · `Shared/Core/Services/NetworkPathMonitor.swift`

## Connections

- iOS App → iOS Root UI: hosts
- iOS App → App Bootstrap: starts
- macOS App → App Bootstrap: starts
- App Bootstrap → Router: wires
- App Bootstrap → Screen View Models: wires
- iOS Root UI → Discovery Screens: presents
- Discovery Screens → Router: navigates via
- Discovery Screens → Screen View Models: binds
- Screen View Models → Search Services: search state
- Search Services → Search Results Cache: reads and writes
- iOS Root UI → Library UI: presents
- Library UI → Playlist Library Store: manages
- Library UI → YouTube Playlist Import: imports
- YouTube Playlist Import → Import Job Store: persists jobs
- Screen View Models → Player View Model: selects media
- Player View Model → Player Surfaces: drives
- Player View Model → Media Pipeline: requests metadata
- Media Pipeline → Media Cache Store: persists media
- Player View Model → System Playback Controls: integrates
- Player View Model → Lyrics Extension: updates now playing
- App Bootstrap → Network Path Monitor: monitors connectivity
