Architecture
Status: built (ADR 0001 and ADR 0002); Jellyfin is the only server adapter. As of 2026-11-25 (main at 07d28476c, with the catalog port split by role in #967).
Start here
Section titled “Start here”- This guide is the “how do I make this change” part. What was built and why is
docs/architecture/README.md; the rules arerules.md, the modulesmodules.md. Both are generated: never edit them by hand. - Server ports are in
domain/.../domain/ports/(MediaServerwithServerSession, the catalog by role since #967 (ItemPort,ItemListPort,ItemExtrasPort,ServerInfoPort),UserDataPort,PlaybackPort;ServerConnector;UserDataSyncPort). The Jellyfin adapter isserver/jellyfin, bound inJellyfinServerModule. - Store ports are in
application/.../repository/(PendingUserDataStore, and since #967 the roles of the server store,StoredServers,ServerAddresses,StoredUsers,UserLocks, and of the download store,DownloadList,DownloadedItemRows,DownloadSources,DownloadMediaStreams,DownloadSegmentsAndTrickplay,DownloadUserData,QueuedDownloads; since #966 the reads of the repository’s stored fallback,StoredItems,StoredItemSources,StoredItemLists, andStoredTrackPreferences), implemented over Room indata/.../database/and bound inDatabaseModule. The downloaded files the repository reads areDownloadedFiles(DownloadedFilesOnDiskindata). - The rules are tests in
architecture/(./gradlew :architecture:test). When one fails, fix the code. Never add a line toarchitecture/baseline/to get past it. - The fakes and the contract suites are in
testing/(FakeMediaServer,FakeServerConnector,ItemContract, …). The fake and the Jellyfin adapter pass the same suites.FakeDownloaderis the fake of theDownloaderport inapplication(#970); the download queue’s tests use it. - Test fast:
./gradlew :domain:test :application:test :architecture:test(seconds, no Android), then./gradlew :testing:test.
What it does
Section titled “What it does”The apps (app/phone, app/tv) are the composition root. Features take the roles of the repository they use (ItemCatalog, ItemLists, PlaybackMedia, …, #967) or a port. domain and application are pure Kotlin and hold the ports. Four adapter modules implement them: server/jellyfin (the only module with the Jellyfin SDK), data (Room and nothing else, R20), ratings/mdblist and device (what asks Android about the device). Only the apps depend on an adapter; Hilt wires the ports to them there. Gradle is the boundary and the rule tests hold what Gradle cannot say (ADR 0001, decision 6).
Where the code is
Section titled “Where the code is”| Path | What |
|---|---|
domain/.../domain/ports/ |
The server ports, ActiveServer, DeviceCodecs |
http/.../http/ |
MediaHttpClient, the API’s OkHttp client that ExoPlayer streams media over (mpv: subtitle files only), provided by server/jellyfin (#964). Its own module because it names a library type, which no port may |
application/.../repository/ |
The roles of the repository (CurrentAccount, ItemCatalog, ItemLists, ItemExtras, UserDataUpdates, SeriesTrackPreferences, PlaybackMedia, PlaybackReports), the store ports, the download ports (DownloadQueuePort, DownloadDeleter, SmartDownloadChecker), the settings ports (DownloadSettings, CurrentServerId, NetworkTimeouts, …) |
application/.../application/downloads/ |
The download queue as a service (service/DownloadQueue.kt, ADR 0003 step 6) and the ports it calls (port/: Downloader, and DownloadPump, DownloadFailureNotice, DownloadQueueTexts and DownloadQueueLog, which downloads implements in DownloadQueueAndroid.kt). Its rules are in domain/.../domain/downloads/ (the state machine, nextDownloads) |
server/jellyfin/.../server/jellyfin/ |
JellyfinMediaServer, JellyfinCatalog, JellyfinUserData, JellyfinPlayback, JellyfinServerConnector; mappers/; SdkIds.kt, SdkEnums.kt, SdkErrors.kt, JellyfinCalls.kt |
server/jellyfin/.../di/JellyfinServerModule.kt |
What the adapter provides; the maps keyed by ServerTypeKey |
core/.../di/ServerModule.kt, core/.../core/server/ |
CurrentMediaServer (picks the adapter by type), ServerConnectors, UnsupportedMediaServer |
data/.../database/ |
ServerDatabase, ServerDatabaseDao, RoomServerStore, RoomDownloadStore (with RoomStoredLists and RoomStoredRows, #966), RoomPendingUserDataStore; the entities are in data/.../models/ |
data/.../data/di/ |
DatabaseModule (Room, the stores, DownloadedFiles) |
application/.../repository/MediaRepositoryImpl.kt, core/.../di/MediaRepositoryModule.kt |
The repository (#966: pure Kotlin over the server’s ports and the store roles; logs through AppLog, the log port of application), bound as each of its roles in core, which also passes it Dispatchers.IO and the system clock (#1104, R26) |
device/ |
The adapters over the device (#965): DeviceCodecProbe with DeviceCodec and CodecHelpers (DeviceCodecs, what the device profiles are built from), NetworkConnectivityImpl (NetworkConnectivity), NetworkSignalsImpl (NetworkSignals), RuntimePermissionsImpl (RuntimePermissions, #998), StorageVolumesImpl (StorageVolumes, #969); bound in DeviceModule |
core/.../di/AppPreferencesPorts.kt |
The settings ports of application, over AppPreferences: the adapters’ (#918) and, since #969, the view models’ (application/.../settings/ports/, CurrentServerSelection) |
testing/.../testing/ |
The fakes, ContractLibrary, the contract suites, ProxyCalls.kt, FakeRoles.kt (a Proxy fake of the roles a test needs) |
server/jellyfin/.../contract/ |
The adapter against the suites (JellyfinContractTests.kt), ContractServer, LiveServer, ContractRecordingsTest |
architecture/.../architecture/ |
The rule tests, ProjectTree, BuildFileDependencies, Baseline, and GeneratedDocsTest.kt with ArchitectureModel |
docs/architecture/model/ |
The LikeC4 model: modules.generated.c4 is generated, the other .c4 files are written by hand |
Recipe 1: an operation on a port, or a new port
Section titled “Recipe 1: an operation on a port, or a new port”An operation on an existing server port (say ItemListPort):
- Declare it in the port’s file in
domain/.../domain/ports/. Use our own types only: models ofdomain, ids asItemId,UserId,ServerId,MediaSourceId. Say in the KDoc how it fails. Forgotten: R5 fails on an Android or SDK import, R10 on an id typed asString. - Implement it in the adapter class (
JellyfinCatalog,JellyfinUserData,JellyfinPlayback). Run the request inside the class’scall { … }, which ispinnedCallfromJellyfinCalls.kt: it holds the request to oneActiveServerand turns the SDK’s failures intoServerException(asServerExceptioninSdkErrors.kt). Map SDK types inmappers/, ids throughSdkIds.kt, enums throughSdkEnums.kt. Forgotten: the adapter does not compile. An SDK type in the port’s signature fails R1. - Implement it in every other implementation. The compiler names them:
FakeMediaServerintesting,UnsupportedMediaServerincore(it throws),UnansweredServerindata’s tests, and test doubles such as those inCurrentMediaServerTest. InFakeMediaServer, go through its privatecall(name)so thatfailWith,stalland thecallslist work for the new operation. - Add tests to the port’s contract suite in
testing(ItemContract,ItemListContract,ItemExtrasContract,ServerInfoContract,UserDataContract,PlaybackContract,ServerConnectorContract): what it returns forContractLibrary, and its line in the suite’s failure tests (a failing, an unreachable and a stalling server)../gradlew :testing:testruns them on the fake. - Record the adapter’s answers.
ContractServerreplaysserver/jellyfin/src/test/resources/contract/and fails a test on a request without a recording. With the Docker test server running (test-serverskill):EPHYRA_TEST_SERVER=http://localhost:8096 ./gradlew :server:jellyfin:testDebugUnitTest --tests '*Contract*' -Dcontract.record=true, as the usercontract(see setup-and-servers, “How to test it”). What the test server does not hold is aContractLibrary.Part, with a recording written by hand ("handwritten": true).ContractRecordingsTestfails when a recording holds an id, a token or an address of the machine. - If not every server can do it, add a field to
ServerCapabilitiesand gate the call on it: no version checks (ADR 0001, decision 9).FakeMediaServerContractTest.ktruns the suites with every feature and with none (NONEthere lists every field). - Call it from
MediaRepositoryImpl(and declare it on the role it belongs to, recipe 6), or inject the port. A ViewModel never names an adapter class.
A new port:
- A new interface in
domain/.../domain/ports/, with failures asServerException. - If it is part of one server, add it as a property of
MediaServer. ThenJellyfinMediaServerbuilds it with itspin,CurrentMediaServergets a getter that delegates tocurrent(), andUnsupportedMediaServer,FakeMediaServerandUnansweredServerget one too. The compiler names each. - If it stands apart (as
ServerConnectorandUserDataSyncPortsdo), provide it inJellyfinServerModulewith@IntoMapand@ServerTypeKey(ServerType.JELLYFIN), and select by type incore(ServerModule,ServerConnectors). Forgotten: Hilt reports a missing binding when an app is built. - A new abstract suite in
testingthat extendsMediaServerContract, a subclass for the fake inFakeMediaServerContractTest.ktand one for the adapter inJellyfinContractTests.kt. Nothing fails when the suite is missing: the reviewer checks it. - Optional: a
portelement incomponents.c4(see recipe 3, step 6).
Recipe 2: a store port over Room
Section titled “Recipe 2: a store port over Room”- Declare the interface in
application/.../repository/. Types ofdomainonly. State of one user takes anAccountKey(serverId,userId), asPendingUserDataStoredoes. Forgotten: R5 fails on any import of Android, Room or somethingdatadeclares. A wildcard import ofdev.jdtech.jellyfin.models.*fails too, becausedata’s entities share that package: import the models by name. - Add the entity in
data/.../models/and list it inentitiesofServerDatabase; add the queries toServerDatabaseDao. - If the schema changes, raise
versioninServerDatabaseand add anAutoMigration(from, to)(with a spec when a table or column goes). A migration written by hand, likeMIGRATION_6_7, is also added inDatabaseModuleand toMIGRATIONSinServerDatabaseMigrationTest. The build writes the new schema todata/schemas/(room3 { schemaDirectory(…) }indata/build.gradle.kts): commit that file. Forgotten: inServerDatabaseMigrationTest,every exported schema migrates to the current oneanda fresh database has the schema of a migrated onefail. In the app a missing migration blocks startup for a supported schema. - Never change an existing file in
data/schemas/. An entity changed without a new version makes KSP rewrite the current JSON in place, and the build passes.released schemas are unchangedcatches it for the released versions it pins; for the current one, read the diff. - Write
Room<Name>Storeindata/.../database/overServerDatabaseDao. It maps rows to the models ofdomain; no entity leavesdata. A read whose rows are only sometimes needed as models (the stored fallback reads before it asks the server, and maps only when the server does not answer) returnsStoredRowsorStoredRow(#966): the rows are read at once, the mapping (more queries) runs onload. - Bind it with a
@ProvidesinDatabaseModule. Forgotten: Hilt reports a missing binding when an app is built. - Test it against a real in-memory database, as
RoomServerStoreTestdoes. A feature’s test may build the real store too:testImplementation(projects.data)is allowed in every module. - Callers inject the port. Forgotten: R4 fails on an import of
ServerDatabaseDaooutsidedata, R9 on a production dependency ondataoutside the apps.
A port for a setting is not a store over Room: declare it in application and implement it in AppPreferencesPorts.kt in core (R17). FakeResumeThresholdsStore in testing is the example of a fake for one. A setting a view model reads goes on the port of its area in application/.../settings/ports/ (R23, #969); a test of the view model can build the core implementation over an AppPreferences of test preferences, as CastAndCrewPreferenceTest does.
A PR with a Room migration that no review bot read gets an independent review before it merges (AGENTS.md).
Recipe 3: a Gradle module
Section titled “Recipe 3: a Gradle module”- Write
<module>/build.gradle.kts. Copy the nearest one:application/build.gradle.ktsfor pure Kotlin,ratings/mdblist/build.gradle.ktsfor an Android adapter with its own Hilt module. A JVM module registers atestDebugUnitTesttask that depends ontest, because CI runs./gradlew testDebugUnitTest. - Add
include(":<name>")tosettings.gradle.kts. Other modules then name it asprojects.<name>. - Add the dependencies. The apps take it with
implementation. An adapter is taken by the apps only;testingonly withtestImplementation(R8). - Add a line to
ArchitectureModel.MODULESinGeneratedDocsTest.kt: the layer and one plain sentence. Forgotten:every module has an entryfails. The test finds modules by their build files, not bysettings.gradle.kts. - Regenerate the docs and commit them:
EPHYRA_WRITE_GENERATED=1 ./gradlew :architecture:test --rerun --tests '*GeneratedDocsTest*'(PowerShell:$env:EPHYRA_WRITE_GENERATED=1; ./gradlew …). It writesmodules.md,rules.mdandmodules.generated.c4. Forgotten:the module page is up to dateandthe module model is up to datefail. A new dependency between two existing modules (including a test-only dependency such astestImplementation) needs the same step. - The model by hand, in
docs/architecture/model/:views.c4: themodulesview includes every module but the tooling modules it names. A new tooling module is added to thatexcludeline and to thetoolingview.- A new layer needs a value in
ArchitectureModel.Layerand anelementkind of the same name incontext.c4. components.c4, only when the module has parts worth showing: eachcomponentandportneeds alinkto its source file or folder in this repository, and an arrow from A to B is only accepted when a source of A names B.check-docs.pyfails on a missing link and on an arrow the code does not back.npm run check-modelindevsite/validates the LikeC4 files.
- For a new adapter, extend the rules that name modules by hand: a test in
DataDependencyTest(R9, as forratings/mdblistanddevice), theADAPTER_MODULESofAdapterDependencyTest(R18) and theMODULESlist inAdapterSettingsTest(R17). R7 guardsserver/jellyfinalone. Nothing fails when one is forgotten: the new module is just not checked. - By hand: the diagram and “What was built” in
README.md, anddocs/areas.yamlwhen the module is an area.
Recipe 4: a rule, and the baseline files
Section titled “Recipe 4: a rule, and the baseline files”- A rule is a test in
architecture/src/test/kotlin/dev/jdtech/jellyfin/architecture/. Its number is the start of the test’s name:R<n> <what it says>. Take the next free number. Several tests may share a number (R5, R9 and R10 have two each). - Read the tree through
ProjectTree(productionKotlinFiles,moduleBuildFiles) and build files throughBuildFileDependencies. Do not use Konsist’s own project scope: from the main checkout it would also parse every copy of the repository in the agents’ worktrees. - Make the rule prove that it looks at something. The existing rules assert that the files were found and that the allowed place does match (“so the check looks for the wrong text”), and have a test of the scanner on sample text. A test whose name after the number starts with
finds,countsorskipsis such a scanner test and is left out ofrules.md. - Write the failure message for the person who trips it: the file, what is wrong, what to use instead.
- Regenerate with the command of recipe 3, step 5.
rules.mdis built from the test names. Forgotten:the rules page is up to datefails. - By hand: the table in
README.md, the range of rule numbers inAGENTS.md, and therulesof the areas the rule touches indocs/areas.yaml.
A baseline is a file architecture/baseline/<name> read by Baseline: one entry per line, # for comments. assertExactly fails on a violation that is not listed and on a listed entry that no longer violates, so a cleanup deletes its line. architecture/baseline/uuid-imports.txt is an allowlist, not debt: files that may name java.util.UUID for a random value the app makes itself. It lists none since #918. architecture/baseline/player-media3.txt is one too (R27): the media session and its service, which name media3’s session API in the root package of player/local. The others hold exceptions with an issue each: pure-kotlin-imports.txt and pure-kotlin-libraries.txt (R19) and room-adapter-imports.txt (R20), all three empty since #968 took paging out of application and data. A new rule starts at zero, or with lines for what truly cannot move in its PR, each with its issue.
Recipe 5: a rule fails on your change
Section titled “Recipe 5: a rule fails on your change”Read the message: it names the file and what to use instead. Fix the code. Do not add a baseline line, do not move the file to where the rule does not look, and do not loosen the rule in the same PR as the code it would catch. If you think the rule is wrong, say so in the PR and change the rule with its scanner test.
The ones you are most likely to trip:
-
R5 (
DomainPurityTest): a file indomainorapplicationimportsandroid.,androidx., the SDK,dev.jdtech.jellyfin.database.or a typedatadeclares. Keep the type in its adapter and give the port a type ofdomain. -
R19 (
PureKotlinTest): a file indomainorapplicationimports anything butkotlin.,kotlinx.,java.,javax.crypto.ordev.jdtech.jellyfin., or their build file declares a library butlibs.kotlinx.*. The same fix as R5; a contract that has to name a library type (an OkHttp client) goes in a small module of its own, ashttpdoes. Its allowlists arearchitecture/baseline/pure-kotlin-*.txt, empty since #968. A list a screen pages is a plain read inapplication(ItemLists.getItemsPage: items from an index, the total on request) and aPagingSourcein the feature (IndexedItemsPagingSourceinmodes/film). -
R20 (
RoomAdapterTest): a file indataimports something of Android (android.,androidx.) but Room (androidx.room3.), SQLite (androidx.sqlite.) orandroid.content.Context. What asks the device (codecs, display, network) goes indevice, behind a port ofdomainorapplication; anything else goes behind a port in the module that owns it. Its allowlist isarchitecture/baseline/room-adapter-imports.txt, empty since #968. -
R10 (
StringIdsTest,UuidBoundaryTest): a parameter or property namedserverId,currentServerId,mediaSourceIdorsourceIdtyped asString(or a list or set of them), orjava.util.UUIDanywhere outsideserver/jellyfin. Use the id classes andtoServerId(),toMediaSourceId(),asString(); a random value comes fromkotlin.uuid.Uuid. -
R1, R2 (
SdkBoundaryTest): a file outsideserver/jellyfinmentions the SDK’s package or importsJellyfinApi. Add the operation to a port (recipe 1). -
R9, R4 (
DataDependencyTest,SdkBoundaryTest): a feature takesdatawithimplementation, or importsServerDatabaseDao. Use a store port (recipe 2); for a test,testImplementation. -
R22 (
AdapterPortsTest): a file of an adapter (data,server/jellyfin,ratings/mdblist,device) names a port that another adapter implements, such asdatanamingMediaServer. Composing two adapters is application logic: put it inapplication, over both ports, and bind it incore(asMediaRepositoryImplandAboutViewModeldo forDeviceCodecs, handingDeviceDecoderstoserver/jellyfin, #1012). -
R28 (
DeviceAdapterTest): a file outsidedeviceand the apps namesConnectivityManager(or itsCompat),checkSelfPermission,checkCallingOrSelfPermission,checkPermissionorgetGroupOfPlatformPermission. Take the port instead:NetworkConnectivity(online, metered, roaming),NetworkSignals(is there a network; a flow when the default one changes or one with internet comes back) orRuntimePermissions(granted, the group’s name, by the permission’s id). A feature passes the permission’s id (PermissionDefinitionsis insettings, whichdevicemay not take, R18). No baseline. -
R23 (
ViewModelSettingsTest): a view model outsidesettingsnamesAppPreferences,Context,Application,@ApplicationContextorAndroidViewModel, anywhere in its file. Take the settings port of the area (PlayerSettings,HomeSettings,DetailPageSettings,CurrentServerSelection, …) and add the setting to it if it is missing. For what theContextwas for, take a port:StorageVolumes(a folder, free space),RuntimePermissions,NetworkSignals, or a small one in the feature’s module, asPlayerTexts,PlayerMediaSessions,PlayerDevice(player/local) andAboutInfoSource(core) are. -
R24 (
SizeCeilingTest): one of the largest files of playback and downloads grew past its ceiling inarchitecture/size-ceilings.txt. Move a rule todomainorapplication(ADR 0003) instead of adding to the file. Moving code into a new file only to pass the check is a review finding. -
R25 (
ReportSenderTest): a file other thanPlaybackReportercallspostPlaybackStart,postPlaybackProgressorpostPlaybackStop, or a file other thanMediaRepositoryImpland the server adapter calls the playback port’sreportStart,reportProgressorreportStopped. Send the report throughPlaybackReporter: the local player tells it what happened, a player that decides its own reports (Cast) callssendDecidedStart,sendDecidedProgressorsendDecidedStop. -
R26 (
HiddenTimeTest): a file indomainnamesDispatchersor reads a clock (System.currentTimeMillis,System.nanoTime,Instant.now(),LocalDateTime.now(),Clock.systemUTC(), …), or a file inapplicationdoes so anywhere but in the default of a constructor parameter. Take the dispatcher (CoroutineDispatcher) or the clock (() -> Long) as a constructor parameter and let the Hilt module passDispatchers.IOorSystem::currentTimeMillis, asMediaRepositoryModuledoes forMediaRepositoryImpl(#1104). A test then passes a test dispatcher and a fixed clock and runs underrunTest.delayandwithTimeoutare fine. No baseline. -
R27 (
PlayerRulesMedia3Test): a file ofplayer/localoutside the packagesengine,mapping,presentationanddinames media3 (an import or a full name). A rule of the player takes our own types: map media3’s value in the view model or in a file ofmapping(asNETWORK_ERROR_CODESis forNetworkRecovery), and keep the engine’s work inengine. The allowlist holds onlyPlaybackService.kt, the media session’s service, whose class the manifest names (#970, step 18). -
R21 (
PortSizeTest): a port declares more than fifteen functions and properties, its inherited ones included. Split it by role (recipe 6).architecture/baseline/wide-ports.txtwould list a port still over, with its issue; it is empty since #967 split the server’s catalog port, the last one.
Also common: R11 for a type named Jellyfin… outside the adapter (NamesTest), and R17 for AppPreferences in data, server/jellyfin, ratings/mdblist, device or downloads (AdapterSettingsTest), and R18 for an adapter that takes a feature module (AdapterDependencyTest).
Recipe 6: an operation of the repository, and its roles
Section titled “Recipe 6: an operation of the repository, and its roles”MediaRepository was split by role in #967; the name is gone, and MediaRepositoryImpl in application (since #966) implements every role. Its tests are in application too, over FakeMediaServer and FakeRepositoryStores from testing, without Android; data’s tests check it over Room (roomMediaRepository in data’s tests).
- Find the role the operation belongs to, by who calls it:
CurrentAccount(the server and user in use),ItemCatalog(one item, a show’s seasons and episodes, next up, people),ItemLists(libraries, library items, favourites, search, Home’s rows, downloads),ItemExtras(what a detail page shows besides the item),UserDataUpdates(favourite and played),SeriesTrackPreferences,PlaybackMedia(sources, segments, trickplay, chapter images),PlaybackReports(the play session and the reports). What the server can do isCurrentServerCapabilitiesindomain, not a role. - Declare it there, implement it in
MediaRepositoryImpl. A role that would pass fifteen members fails R21: split it instead, and add the new role toMediaRepositoryImpl’s supertypes and a@ProvidestoMediaRepositoryModuleincore(each role is bound to the one@Singletoninstance; a second instance would lose the play sessions and the resume settings read). It reaches the database through the store roles only (#966): a new read goes on the role it belongs to (recipe 2), never onServerDatabaseDaofrom the repository. - A caller takes only the roles it uses, in its constructor. A test builds a fake of those roles with
FakeRoles(several) orfakeRole(one) fromtesting, or implements a small role directly (PlaybackReporterTest).
How to test it
Section titled “How to test it”./gradlew :domain:test :application:test :architecture:test # the pure modules and the rules: seconds, no Android./gradlew :testing:test # the fakes against the contract suites./gradlew :server:jellyfin:testDebugUnitTest # the adapter: contract recordings, mappers, requests./gradlew :data:testDebugUnitTest # Room stores, migrations, the repository./gradlew :core:testLibreDebugUnitTest # CurrentMediaServer, the selectors, the syncpython3 .claude/skills/start-work/scripts/check-docs.py # docs and model against the tree: about a second- One rule:
./gradlew :architecture:test --tests '*DomainPurityTest*'. - The rules read source files and build files, so nothing is compiled first. The task runs again when a Kotlin or build file, a baseline or a generated doc changes.
- Hilt bindings are only checked when an app is built:
./gradlew :app:phone:assembleLibreDebug :app:tv:assembleLibreDebug. - The adapter against a live server:
EPHYRA_TEST_SERVER, see recipe 1, step 5. CI runs it every Monday against the latest Jellyfin image (.github/workflows/live-contracts.yml, also by hand); a failure opens or updates the issue “ci: weekly live contract suites failed”. Other pull requests only replay; one that changes the workflow runs it live. - A migration is also checked on an emulator, as the upgrade checks of ADR 0002 were (its answer Q5): the previous build with data, then the new build over it, and the database compared.
Before a PR
Section titled “Before a PR”./gradlew ktfmtCheck./gradlew :domain:test :application:test :architecture:test :testing:test./gradlew testDebugUnitTestpython3 .claude/skills/start-work/scripts/check-docs.py- A new module, module dependency or rule: the generated docs are regenerated and committed.
- A new port or store: this guide, the guide of its area, and the
applicationordomainsentence inArchitectureModel.MODULESif it names the ports. - The
Docsworkflow (.github/workflows/docs.yml) runscheck-docs.pyon every pull request. For a pull request that changes a generated file it also runsGeneratedDocsTest, because a docs-only change does not run the unit tests. - A change no user can notice goes on a
refactor/branch, which publishes no beta.
Decisions and history
Section titled “Decisions and history”- ADR 0001: ports and adapters, one adapter module per server type, Gradle as the boundary and Konsist as the ratchet, capabilities as data. ADR 0002:
application, the three stores,AccountKey, opaque ids,MediaRepository(split into roles by #967). ADR 0003 (proposed, #970): use cases for playback and downloads, what a use case looks like here (a rule indomainor a service inapplication, with its scope, dispatcher and clock injected), the download state machine, and the order of the PRs. - #733: the tracking issue. #735: the
architecturemodule. #771:testingand the contract suites. - #758: the adapter as its own module (R7). #770: servers have a type; adapters in maps by
ServerType. - #896:
application(R5, R9). #899: the store ports,data’s own Hilt modules, R4 without exceptions,ActiveServer(R16). - #773, #902: ids as value classes (R10). #774: the names (R11). #918: settings through ports (R17).
- #928: the generated docs, the LikeC4 model and
check-docs.py. - The numbered files
1-inventory.mdto5-hexagonal-ddd.mdindocs/architecture/describe the app before the work. Where they differ from the code, the code is right.
Pitfalls
Section titled “Pitfalls”- Playback and Smart Downloads share state through
PlaybackEvents(#1143). The local player publishes download ids throughonQueuedDownloads; Smart Downloads readsqueuedDownloadIdsandholdsDownload. These ids accumulate until player release, because engine queue replacement is asynchronous and can fail. The contract stays inapplication; neither feature depends on the other’s implementation. - R1 is a text check.
SdkBoundaryTestlooks for the SDK’s package name in the code, with comments removed (as R10 and R17 do). A type used by its full name without an import, or a string that holds the name, still fails. - A folder is not a package. Moved files kept their package (ADR 0001, decision 8): the ports of
applicationare in packagedev.jdtech.jellyfin.repository, anddata’s entities sharedev.jdtech.jellyfin.modelswith the models ofdomain. That is why R5 forapplicationcompares names, not package prefixes. - No production Java outside the adapter. The rules read Kotlin only;
SdkBoundaryTestfails on a.javafile elsewhere instead of letting it pass unread. - Not everything is per server type yet.
ServerSession,MediaHttpClientandDeviceReportSourceare bound once, to Jellyfin, inJellyfinServerModule;MediaServer,ServerConnectorand the sync ports are maps byServerType(README, “Not done”). - A fake built with a proxy and an id. Ids are value classes, so a function that takes one has a mangled JVM name and a
Stringparameter. A fake made withjava.lang.reflect.Proxythat switches on the method name stops matching without an error: usefakeProxyfromProxyCalls.kt(#773). - The contract suites are JUnit 4, because the adapter’s subclasses need Robolectric (#699,
testing/build.gradle.kts). The tests ofdomain,applicationandarchitectureare JUnit Jupiter. - One device in a contract test. Every request of a contract test comes from the same device id, and Jellyfin keeps one token per device. A test that logs in and then has Quick Connect sign “another device” in (
ServerConnectorContract, #855) loses the first token to the second, so ending that first session answers 401 on the real server: such a test does not assert it. - The catalog’s parts are one object in the Jellyfin adapter.
JellyfinMediaServer,FakeMediaServer,UnsupportedMediaServerandUnansweredServerhand one object asitems,itemLists,itemExtrasandinfo; another adapter may use four. A test double ofMediaServerneeds all four properties, andCurrentMediaServerTestcompares each (#967). - A request pinned to a server. A port a caller takes from
CurrentMediaServeris held to theActiveServerof that moment (MediaServer.at, #899). An adapter call that skipspinnedCallfollows whatever server is switched to while it runs. architecture/paths are relative to the root. Agents work in worktrees under.claude, so every absolute path there contains.claude; a filter on the absolute path would drop every file (ProjectTree).- A green
check-docs.pysays that nothing named is gone, not that a sentence is true (AGENTS.md). It does not check that an arrow in the model is the right one, only that the source of A names B. - A store method that runs a lambda in a transaction. In
RoomDownloadStore.writeAndMarkToBeSyncedthe lambda’s receiver is the DAO, and the store has a method of the same name and signature (updatePlayState): namedatabase.explicitly inside, so the call cannot bind to the store’s own method (#966). - A newer schema blocks startup.
DatabaseModuleallows destructive fallback only from legacy schema 1.ServerDatabaseStartupopens the same Room instance used by the stores before phone or TV starts database-backed services. If it cannot open, the launcher shows how to recover (#1127).
Source: docs/areas/architecture.md · raw Markdown