Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / uniflix / AGENTS.md
| 1 | # AGENTS.md — uniflix/ (':uniflix') |
| 2 | |
| 3 | > Scoped supplement. Global rules in root `AGENTS.md` apply. Stay inside `uniflix/` + allowed shared modules. Do not root-scan. |
| 4 | |
| 5 | _Install: ./install uniflix (dev by default)._ |
| 6 | - Gradle: :uniflix / dir: uniflix/ |
| 7 | - Package roots present: ui, data, domain, platform |
| 8 | - Entry files: MainActivity.kt, Route.kt, Navigation.kt |
| 9 | - Deps: :library:network, :library:image, :library:room, media3 exoplayer/hls, datastore-preferences, quickjs-kt, chicory-runtime |
| 10 | - Metadata: metadata_data/uniflix.md (present) |
| 11 | - Rust: no / screenshotTest: yes |
| 12 | |
| 13 | ## Overview |
| 14 | **Purpose:** TMDB catalog browser (trending/top-rated/search, watchlist, lists, |
| 15 | resume) with playback supplied by user-installed Stremio-style URL addons. Ships |
| 16 | with no provider and no secrets — with zero addons the app is catalog-only and |
| 17 | Watch/Detail link to the addon manager. |
| 18 | **Key features:** |
| 19 | - Addon manager: add-by-URL, enable/disable, default star, priority ordering, per-addon settings, error badges |
| 20 | - `StreamProvider` is the single player-facing contract; `PluginRegistry` resolves default-first then priority fallbacks |
| 21 | - Pure-HTTP addon protocol subset: `manifest.json` + `GET {base}/stream/{type}/{id}.json` with `tmdb:` ids |
| 22 | - Installable JS plugins (`.js` import): QuickJS runtime + generic host (`__ufetch` via NetworkClient, `__uwasm_*` via Chicory, `__uaesgcm_open`, `__urand`); sync-only contract, WASM travels inside the plugin file |
| 23 | **Architecture / data-flow:** `ui/` (Home→Detail→Watch, AddonsScreen/AddonDetailScreen) → `platform/` (`DetailViewModel` resolves via `RegistryFactory.AllInstalled`, `AddonsViewModel` owns install/order toggles + `addJsPlugin`) -> (`data/` (`AddonStreamProvider` HTTP impl, `JsStreamProvider`/`JsPluginEngine` JS impl, `UniflixRepository` over Room v3 `AddonEntity` with `kind`/`jsSource`) with pure `domain/` (`AddonManifest` validation, `JsPluginManifest` parsing, `PluginRegistry` ordering). `Navigation`: `Home`/`Movies`/`Series`/`Search`/`Detail`/`Watch`/`Lists`/`ContinueWatching`/`Addons`/`AddonDetail(dbId)`/`AddAddonDialog` routes; the TV graph (`ui/tv/TvRoute`) mirrors this with its own `AddAddonDialog`. Stateless bodies (`DetailContent`, `ListsContent`, `ContinueWatchingContent`, `AddonDetailContent`, `AddonsContent`) back the route screenshot captures in `src/screenshotTest`. The TV watch server/subtitle/quality pickers stay local to the live player (see the `DIALOG LOCAL EXCEPTION` in `ui/tv/TvWatch.kt`). |
| 24 | **Entry points + reading order:** `Route` (`Home` / `Movies` / `Series` / `Search` / `Detail` / `Watch` / `Lists` / `ContinueWatching` / `Addons` / `AddonDetail` / `AddAddonDialog`) → `MainActivity.kt` → `Navigation.kt` → `platform/AddonsViewModel.kt` + `platform/DetailViewModel.kt` → `domain/PluginRegistry.kt` + `data/AddonStreamProvider.kt`. |
| 25 | **Gotchas:** |
| 26 | - Manifest `resources` accepts Stremio string-or-object forms; only `stream` for movie/series validates |
| 27 | - URL addons enforce HTTPS except loopback/private (dev); remote `http://` is rejected as `InsecureUrl` |
| 28 | - `UniflixDatabase` is v3, with `Migration(1,2)` adding `AddonEntity` and `Migration(2,3)` adding `kind`/`jsSource`; default addon id lives in DataStore, ordering in Room priority |
| 29 | - Private `personal/uniflix_strem/` keeps the native Strem provider + hardcoded TMDB key — never copy those into `uniflix/` |
| 30 | - Backup: `platform/AppBackupAgent` (declared in the manifest) carries the DB via `SqlCipherDbCodec` (plaintext in the payload, re-encrypted on restore) + the `uniflix_addons` DataStore; the raw `uniflix-db` file and `secure_prefs.xml` are excluded in `data_extraction_rules.xml` — the wrapped passphrase is device-bound, so a raw restored DB cannot be opened |
| 31 | |
| 32 | ## Key files |
| 33 | ### Root — entry + navigation |
| 34 | - com/vayunmathur/uniflix/MainActivity.kt |
| 35 | - com/vayunmathur/uniflix/Navigation.kt |
| 36 | - com/vayunmathur/uniflix/Route.kt |
| 37 | ### domain/ — pure addon protocol + resolution order (no Android) |
| 38 | - com/vayunmathur/uniflix/domain/StreamProvider.kt — player contract both plugin kinds implement |
| 39 | - com/vayunmathur/uniflix/domain/PluginRegistry.kt — default-first, priority fallback ordering |
| 40 | - com/vayunmathur/uniflix/domain/AddonManifest.kt — manifest parse + validate |
| 41 | - com/vayunmathur/uniflix/domain/AddonModels.kt — tmdb: id mapping, stream→VideoSource |
| 42 | - com/vayunmathur/uniflix/domain/JsPluginManifest.kt — JS plugin header + wasm section parse |
| 43 | ### data/ — HTTP provider, JS engine, Room, prefs |
| 44 | - com/vayunmathur/uniflix/data/AddonStreamProvider.kt — URL addon as StreamProvider |
| 45 | - com/vayunmathur/uniflix/data/JsPluginEngine.kt — QuickJS + Chicory host, sync-only contract |
| 46 | - com/vayunmathur/uniflix/data/JsStreamProvider.kt — JS plugin as StreamProvider |
| 47 | - com/vayunmathur/uniflix/data/AddonEntity.kt — installed-addon entity + DAO |
| 48 | - com/vayunmathur/uniflix/data/UniflixDatabase.kt — Room v3 + Migration(1,2) + Migration(2,3) |
| 49 | - com/vayunmathur/uniflix/data/UniflixRepository.kt — singleton incl. addon flows |
| 50 | - com/vayunmathur/uniflix/data/AddonPrefs.kt — default addon id (DataStore) |
| 51 | - com/vayunmathur/uniflix/data/TmdbKeyStore.kt — user key only, no default |
| 52 | ### platform/ — ViewModels |
| 53 | - com/vayunmathur/uniflix/platform/DetailViewModel.kt — registry injection + RegistryFactory |
| 54 | - com/vayunmathur/uniflix/platform/AddonsViewModel.kt — manager state |
| 55 | - com/vayunmathur/uniflix/platform/AppBackupAgent.kt — platform backup via SqlCipherDbCodec + uniflix_addons DataStore |
| 56 | ### ui/ — catalog + manager |
| 57 | - com/vayunmathur/uniflix/ui/AddonsScreen.kt — manager list host (pushes `Route.AddAddonDialog`) |
| 58 | - com/vayunmathur/uniflix/ui/AddonDetailScreen.kt — per-addon settings host |
| 59 | - com/vayunmathur/uniflix/ui/AddonDetailContent.kt, ListsContent.kt, ContinueWatchingContent.kt, DetailContent.kt — stateless screenshot slices (Detail notes are a host-supplied slot) |
| 60 | - com/vayunmathur/uniflix/ui/AddonDialogEntries.kt — `DialogPage()` entry for `Route.AddAddonDialog` |
| 61 | - com/vayunmathur/uniflix/ui/tv/TvAddonDialogEntries.kt — `DialogPage()` entry for `TvRoute.AddAddonDialog` |
| 62 | - com/vayunmathur/uniflix/ui/dialogs/AddAddonDialog.kt — add-by-URL |
| 63 | |
| 64 | ## Verify (this module only) |
| 65 | ``` |
| 66 | ./gradlew :uniflix:compileDevKotlin |
| 67 | ./gradlew :uniflix:lint |
| 68 | ./gradlew :uniflix:checkMetadata |
| 69 | ``` |