# NuvioTV Full Port Reversion Analysis (2026-05-28)

## What Was Attempted
Full port of 5 NuvioTV screens + addon system to UNSPOOLED. Approach: copy screens, rename packages, replace dependencies.

## Why It Was Reverted — Architectural Incompatibility

The NuvioTV screens depend on an entirely different architecture across 8 layers:

| Layer | NuvioTV | UNSPOOLED |
|---|---|---|
| Debrid providers | `core.debrid.DebridServiceProviders` (static registry) | `data.debrid.DebridService` + `DebridProviderAdapter` (DI-injected) |
| Debrid auth | Device code flow (QR, polling) | API key + token storage |
| Settings persistence | Profile-scoped DataStores (1 per profile) | Flat `PreferencesManager` + JSON DataStore |
| Home layout | `LayoutPreview` composable library | Netflix-style sidebar (`NavRail`) |
| Collections | Sync-orchestrated with TMDB/Trakt resolvers | Local-only data |
| Addon management | `AddonManagerViewModel` requiring `ProfileManager`, `CollectionSyncService`, `StartupSyncService` | Self-contained `AddonControlScreen` + `AddonsViewModel` |
| DI graph | 40+ Hilt modules (sync, plugins, Supabase, torrents) | ~15 modules |
| Theme | `NuvioColors` (38 named colors) | `NexColors` (27 named colors) |
| Resources | 200+ `R.string.debrid_*` entries | Different resource names |

## Three Porting Options

### Option A — Clean Adaptation (recommended)
Write each screen from scratch using UNSPOOLED's design system, data layer, and ViewModels. Same functionality, UNSPOOLED-native code. **~2-3 hours per screen.**

### Option B — Infrastructure Migration
Import NuvioTV's entire backend (40+ files: servers, APIs, DI modules, sync orchestrators, profile managers) and maintain them alongside UNSPOOLED's existing system. **Fragile, high maintenance burden.**

### Option C — Partial Bridge
Port individual screens with adapter ViewModels that map NuvioTV UI state to UNSPOOLED data stores. The `DebridSettingsScreen` with the `DebridServiceProviders` adapter layer compiled successfully before cleanup. **Incremental, reversible.**

## What DID Compile Before Reversion
- `DebridServiceProviders` registry (Torbox, Premiumize, RealDebrid)
- `DebridDeviceAuth` data classes
- Enhanced `DebridSettingsViewModel` with full NuvioTV API surface
- `DebridSettingsDataStore.setProviderApiKey()` generic setter
- `SettingsDialogWrapper` dialog shim
- `QrCodeOverlay` stub
- `DebridSettingsScreen` — 1,471-line port with all stream filters, instant playback, cloud library toggles

All of this was building green before the final cleanup.

## Session Pattern
When user says "restore clean state" or "revert port" — the project returns to its pre-port fileset. All ported files are removed, NexColors-only theme is restored, and a fresh build is verified.

## Key Lesson
**Porting screens between two apps with different DI graphs, component libraries, and data layers requires adapter ViewModels at minimum. Copying files and renaming packages fails because the dependency chains extend far beyond the screen file itself.** Always audit dependencies before porting.
