How chhabraadhruv/buzzpair works
Project Type and Purpose
• Native macOS menu-bar application (built in Swift/SwiftUI within Xcode)
• Purpose: Discover Google Fast Pair BLE devices, manage connections, control ANC/volume/EQ, display battery levels, send system notifications.
File Structure
• Top-level files:
– README.md – project overview
• Implicit Xcode project (BuzzPair.xcodeproj) containing Swift source code:
– SwiftUI Views (UI)
– ViewModels (Combine)
– Services/Managers (Bluetooth scanning, pairing, audio control, notifications)
– Resources (assets, Info.plist, entitlements)
Extract Key Architecture from the README
• Features imply these core subsystems:
– Device Discovery & Pairing (Google Fast Pair protocol over BLE)
– Audio Controls (ANC modes, volume, EQ)
– Battery Monitoring (BLE characteristics)
– Menu-Bar Integration & UI (SwiftUI)
– Notifications (UserNotifications framework)
Main Components and Boundaries
a. Presentation Layer
– MenuBarController + SwiftUI Views
– ViewModels (expose device list, connection state, control commands)
b. Domain & Business Logic
– FastPairManager (implements Google Fast Pair handshake & GATT profiles)
– AudioControlManager (sets ANC/Transparency/Off modes)
– BatteryMonitor (reads and publishes battery level updates)
– SettingsManager (persists user preferences)
c. Infrastructure Layer
– CoreBluetooth Framework (BLE scanning, GATT operations)
– UserNotifications Framework (system-level alerts)
– AVFoundation/System Audio APIs (volume, EQ)
– Local Storage (UserDefaults or on-disk plist for preferences)
d. External Services
– Google Fast Pair Service on the device (BLE GATT server)
Component Interactions
• On launch: MenuBarController initializes FastPairManager & BatteryMonitor
• FastPairManager scans via CoreBluetooth → detects BLE advertisement → performs pairing → notifies ViewModel
• ViewModel updates SwiftUI Views → user triggers ANC/volume/EQ commands → routed to AudioControlManager → invokes AVFoundation
• BatteryMonitor polls GATT characteristic via CoreBluetooth → updates ViewModel → UI updates battery gauge
• Notification triggers on “device found” → SettingsManager checks user prefs → UserNotifications delivers alert
Architectural Patterns & Principles
• MVVM pattern with SwiftUI + Combine
• Separation of Concerns: UI, Domain Logic, Infrastructure
• Dependency Injection: inject CoreBluetooth and UserNotifications services into managers
• Observer/Publish-Subscribe (Combine) for state propagation
• Clean layering to facilitate unit testing of managers without UI