How nirvanasangsara-ai/phosphor-hud works
Phosphor is a cross-platform AI subscription-usage HUD, led by a native macOS menu-bar app. The main workflow is local provider/account discovery and usage collection, followed by quota and burn-rate calculation, then a consolidated panel with reset and billing context. Local session logs also support token-cost and subscription-ROI views; optional GitHub PR metrics add a separate engineering-efficiency feature. Windows ports core calculations into a Tauri HUD. The graph includes documented capabilities whose implementation was not sampled; those links cite the README rather than imply source inspection.
Main entry points: Views.swift HUD views · Store.swift Usage store · collect.rs HUD collection · App.swift App lifecycle
Components 31
macOS HUD
- App lifecycle
Sources/Phosphor/App.swift - HUD views
Sources/Phosphor/Views.swift - Usage store
Sources/Phosphor/Store.swift - Accounts
Sources/Phosphor/Accounts.swift - PR dashboard
Sources/Phosphor/DevStatsView.swift - Theme system
Sources/Phosphor/Theme.swift - Built-in themes
Sources/Phosphor/BuiltinThemes.swift - Quota icon color
Sources/PhosphorCore/IconColor.swift - CRT icon
Sources/Phosphor/CRTIcon.swift - Localization
Sources/PhosphorCore/L10n.swift - Service connection
Sources/Phosphor/Connect.swift
Usage and insights
- Provider readers
Sources/Phosphor/Providers.swift - Provider discovery
Sources/Phosphor/Registry.swift - OAuth refresh
Sources/Phosphor/AuthRefresh.swift - Log scanning
Sources/PhosphorCore/LogScanner.swift - Log parsers
Sources/PhosphorCore/LogParsers.swift - Token accounting
Sources/PhosphorCore/TokenUsage.swift - Quota forecast
Sources/PhosphorCore/Forecast.swift - Usage pricing
Sources/PhosphorCore/Pricing.swift - PR insights
Sources/Phosphor/DevStats.swift - Status readings
Sources/PhosphorCore/ServiceStatus.swift
Windows HUD
- HUD collection
windows/phosphor-core/src/collect.rs - Quota readings
windows/phosphor-core/src/quota.rs - Local paths
windows/phosphor-core/src/paths.rs - Pricing math
windows/phosphor-core/src/pricing.rs - Time utilities
windows/phosphor-core/src/timeutil.rs - Usage ledger
windows/phosphor-core/src/ledger.rs - Windows HUD
windows/phosphor-hud/ui/app.js
External services
- GitHub services
- AI providers
Other components
- User
Connections 30
- User → App lifecycle: opens HUD
- App lifecycle → HUD views: shows panel
- App lifecycle → Usage store: refreshes readings
- Usage store → Provider discovery: discovers services
- Usage store → Provider readers: collects usage
- Provider readers → OAuth refresh: refreshes tokens
Sources/Phosphor/Providers.swift - Provider readers → AI providers: reads provider usage
Sources/Phosphor/Providers.swift - Usage store → Accounts: loads account details
- HUD views → Quota forecast: shows burn rate
Sources/Phosphor/Views.swift - Usage store → Log scanning: scans local sessions
- Log scanning → Log parsers: parses records
Sources/PhosphorCore/LogScanner.swift - Log scanning → Token accounting: aggregates tokens
Sources/Phosphor/UsageLogs.swift - HUD views → Usage pricing: shows ROI
- PR dashboard → PR insights: shows PR metrics
- PR insights → GitHub services: queries read-only
- HUD views → Theme system: renders themed HUD
Sources/Phosphor/Views.swift - Theme system → Built-in themes: loads defaults
Sources/Phosphor/Theme.swift - HUD views → Quota icon color: colors quota bars
Sources/Phosphor/Views.swift - HUD views → CRT icon: renders icon
Sources/Phosphor/Views.swift - HUD views → Localization: localizes interface
- HUD views → Service connection: offers setup guidance
Sources/Phosphor/Views.swift - HUD views → Status readings: shows status dots
- User → Windows HUD: uses Windows HUD
- Windows HUD → HUD collection: requests readings
- HUD collection → Quota readings: collects quotas
windows/phosphor-core/src/collect.rs - HUD collection → Local paths: reads local files
windows/phosphor-core/src/collect.rs - HUD collection → Usage ledger: uses session logs
windows/phosphor-core/src/collect.rs - Usage ledger → Pricing math: prices usage
windows/phosphor-core/src/ledger.rs - Quota readings → Time utilities: formats reset times
windows/phosphor-core/src/quota.rs - HUD collection → AI providers: reads provider limits
windows/phosphor-core/src/collect.rs