# Modules

<!-- Generated by architecture/…/GeneratedDocsTest.kt from the build files and the rule tests. Don't edit: -->
<!-- EPHYRA_WRITE_GENERATED=1 ./gradlew :architecture:test --rerun --tests '*GeneratedDocsTest*' -->

The Gradle modules and what each depends on, read from their `build.gradle.kts`. The graph leaves out test-only dependencies (`testImplementation`, …), the arrows of the apps, which depend on every module, and the arrows into `domain` and `application`, which every module may use (`application` → `domain` stays). The table has every dependency. The rules that guard these arrows are in [rules.md](rules.md); the interactive model is [model/](model/).

```mermaid
flowchart TD
  subgraph app["Apps (composition root)"]
    appPhone["app/phone"]
    appTv["app/tv"]
  end
  subgraph feature["Features"]
    core["core"]
    downloads["downloads"]
    modesFilm["modes/film"]
    playerCast["player/cast"]
    playerCore["player/core"]
    playerLocal["player/local"]
    settings["settings"]
    setup["setup"]
  end
  subgraph application["Application"]
    application["application"]
  end
  subgraph domain["Domain"]
    domain["domain"]
  end
  subgraph adapter["Adapters"]
    data["data"]
    device["device"]
    ratingsMdblist["ratings/mdblist"]
    serverJellyfin["server/jellyfin"]
  end
  subgraph shared["Shared contracts"]
    http["http"]
  end
  application --> domain
  core --> playerCore
  core --> settings
  downloads --> settings
  modesFilm --> core
  modesFilm --> settings
  playerCast --> core
  playerCast --> playerCore
  playerCast --> playerLocal
  playerCast --> settings
  playerLocal --> core
  playerLocal --> http
  playerLocal --> playerCore
  playerLocal --> settings
  serverJellyfin --> http
  setup --> core
  setup --> settings
```

| Module | Layer | What | Depends on | Test-only |
|---|---|---|---|---|
| `app/phone` | Apps (composition root) | The phone app: screens, navigation and layouts; with app/tv the composition root. | `application`, `baselineprofile`, `core`, `data`, `device`, `domain`, `downloads`, `http`, `modes/film`, `player/cast`, `player/core`, `player/local`, `ratings/mdblist`, `server/jellyfin`, `settings`, `setup` |  |
| `app/tv` | Apps (composition root) | The Android TV app: its own screens in its ce package, next to upstream's (TV ADR 0001). | `application`, `core`, `data`, `device`, `domain`, `http`, `modes/film`, `player/core`, `player/local`, `ratings/mdblist`, `server/jellyfin`, `settings`, `setup` | `testing` |
| `application` | Application | Pure Kotlin: the repository's roles (ItemCatalog, ItemLists, PlaybackMedia, …) and their implementation MediaRepositoryImpl over the server's ports and the stores, the store ports (the roles of the server and download stores, PendingUserDataStore) the event flows (DataChangeEvents, ReloadPolicy, …) and the download queue (DownloadQueue, with its port Downloader). | `domain` | `testing` |
| `architecture` | Tests and tooling | The Konsist rules over the source tree, their allowlists in architecture/baseline/, and the generated architecture docs. |  |  |
| `baselineprofile` | Tests and tooling | Macrobenchmark: the baseline profile and startup benchmark of app/phone. | `app/phone` |  |
| `baselineprofile-tv` | Tests and tooling | Macrobenchmark: the baseline profile and startup benchmark of app/tv. | `app/tv` |  |
| `core` | Features | Hilt modules, the server in use (CurrentMediaServer), its session keeper and reachability, the sync worker, DownloaderViewModel, MainViewModel and shared Composables. | `application`, `domain`, `player/core`, `settings` | `data`, `testing` |
| `data` | Adapters | Room: the database and the stores (Room*Store) behind the store ports, and the downloaded files (DownloadedFilesOnDisk); no SDK, and of Android only Room (R20). | `application`, `domain` | `testing` |
| `device` | Adapters | The adapters over the device: the codec probe (DeviceCodecs, what the device profile is built from), the connectivity check (NetworkConnectivity), the network callbacks (NetworkSignals) and the permission states (RuntimePermissions), with its own Hilt module. | `application`, `domain` |  |
| `domain` | Domain | Pure Kotlin, no Android or SDK: the models (Item, Movie, ItemSource, …), the ids, PlayState, DownloadState, Ticks, ActiveServer and the server ports. |  |  |
| `downloads` | Features | The download engine (DownloaderImpl, MediaDownloadEngine), the Android side of the download queue (its service, notice and words), smart downloads and their workers. | `application`, `domain`, `settings` | `data`, `testing` |
| `http` | Shared contracts | MediaHttpClient, the API's OkHttp client: provided by server/jellyfin, used by the player (ExoPlayer's media, mpv's subtitle files), so they share the API's connections. |  |  |
| `modes/film` | Features | The view models with their State and Action classes for home, library, search, the item screens and downloads. | `application`, `core`, `domain`, `settings` | `data`, `testing` |
| `player/cast` | Features | Google Cast: the session and playback on a receiver; real in the proprietary flavour, stubs in libre. | `application`, `core`, `domain`, `player/core`, `player/local`, `settings` | `testing` |
| `player/core` | Features | The player models shared by the player and its callers: PlayerItem, Track, Trickplay. | `domain` |  |
| `player/local` | Features | The player: PlayerViewModel and playback, on ExoPlayer or mpv behind PlayerEngine (in its engine package). | `application`, `core`, `domain`, `http`, `player/core`, `settings` | `data`, `testing` |
| `ratings/mdblist` | Adapters | The MDBList adapter of the external ratings on the movie and show pages: its HTTP client and the ratings cache on disk, with its own Hilt module. | `application`, `domain` |  |
| `server/jellyfin` | Adapters | The Jellyfin adapter, the only module with the Jellyfin SDK: JellyfinApi, the mappers, the port implementations, the device profiles and its own Hilt module. | `application`, `domain`, `http` | `data`, `device`, `settings`, `testing` |
| `settings` | Features | AppPreferences (over SharedPreferences), a view model per settings page over one SettingsTree, and the preference models; the screens are in the apps. | `application`, `domain` |  |
| `setup` | Features | Server discovery, signing in and the onboarding flow. | `application`, `core`, `domain`, `settings` | `data`, `testing` |
| `testing` | Tests and tooling | Test only (R8): FakeMediaServer, FakeServerConnector and the contract suites a server adapter passes. | `application`, `domain` |  |
