git-subtree-dir: ios git-subtree-mainline:52968df567git-subtree-split:2220a0d4f2
4.0 KiB
4.0 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
QueueCube is a SwiftUI-based jukebox client application for iOS and macOS (via Mac Catalyst). It provides a frontend for controlling a server-based jukebox system that supports playlist management, favorites, and playback controls.
Architecture
Core Components
- API.swift: Central networking layer that handles all communication with the jukebox server. Includes REST API methods for playback control, playlist management, and WebSocket events for real-time updates.
- ContentView.swift: Main view controller containing the
MainViewModelthat coordinates between UI components and API calls. Handles WebSocket event processing and data flow. - Server.swift: Represents individual jukebox servers with support for both manual configuration and Bonjour service discovery.
- Settings.swift: Manages multiple server configurations stored in UserDefaults with validation through
SettingsViewModelthat tests connectivity on URL changes.
Data Flow
- Multiple Server Support: Array of
Serverobjects stored in UserDefaults with selected server tracking - Settings: Server configurations validated asynchronously via API calls with live connectivity testing
- Real-time Updates: WebSocket connection provides live updates for playlist changes, playback state, and volume
- API Integration: All server communication goes through the
APIstruct using a fluentRequestBuilderpattern - State Management: Uses SwiftUI's
@Observablepattern for reactive UI updates
Request Builder Pattern
The API layer uses a fluent builder pattern for HTTP requests:
try await request()
.path("/nowplaying")
.json()
This provides type-safe, composable API calls with automatic error handling and connection state management.
Key Features
- Real-time sync: WebSocket events automatically refresh UI when server state changes
- Cross-platform: Supports iOS, iPadOS, and macOS via Mac Catalyst
- Settings validation: Live server connectivity testing with visual feedback
- Error handling: Connection state management with user-friendly error displays
Development Commands
Building
# Build for iOS Simulator
xcodebuild -project QueueCube.xcodeproj -scheme QueueCube -destination 'platform=iOS Simulator,name=iPhone 15' build
# Build for Mac Catalyst
xcodebuild -project QueueCube.xcodeproj -scheme QueueCube -destination 'platform=macOS,variant=Mac Catalyst' build
Running
- Open
QueueCube.xcodeprojin Xcode - Select target device (iOS Simulator or Mac)
- Run with Cmd+R
API Endpoints Reference
The server API includes these endpoints:
GET /nowplaying- Current playback statusGET /playlist- Current playlist itemsGET /favorites- User favoritesPOST /play,/pause,/skip,/previous- Playback controlsPOST /playlist- Add media URL to playlistDELETE /playlist/{index}- Remove playlist itemPOST /volume- Set volume levelWS /events- WebSocket for real-time updates
UI Structure
View Hierarchy
QueueCubeApp
└── ContentView (coordination layer)
└── MainView (tab management)
├── PlaylistView (with embedded NowPlayingView)
├── FavoritesView (favorites management)
└── SettingsView (server configuration)
├── ServerListSettingsView
├── AddServerView
└── GeneralSettingsView
Key Views
- ContentView: Main coordinator that manages API instances and global state
- MainView: Tab-based navigation container with platform-specific adaptations
- PlaylistView: Scrollable list of queued media with reorder/delete actions, includes embedded NowPlayingView
- NowPlayingView: Playback controls and current track display
- AddMediaBarView: Input field for adding new media URLs to playlist
- SettingsView: Multi-server configuration with live validation and service discovery