444 lines
33 KiB
HTML
444 lines
33 KiB
HTML
<!DOCTYPE HTML>
|
|
<html lang="en" class="navy" dir="ltr">
|
|
<head>
|
|
<!-- Book generated using mdBook -->
|
|
<meta charset="UTF-8">
|
|
<title>Overview - JellyTau Documentation</title>
|
|
|
|
|
|
<!-- Custom HTML head -->
|
|
|
|
<meta name="description" content="Requirements, traceability, and architecture for the JellyTau Jellyfin client.">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<meta name="theme-color" content="#ffffff">
|
|
|
|
<link rel="icon" href="../favicon.svg">
|
|
<link rel="shortcut icon" href="../favicon.png">
|
|
<link rel="stylesheet" href="../css/variables.css">
|
|
<link rel="stylesheet" href="../css/general.css">
|
|
<link rel="stylesheet" href="../css/chrome.css">
|
|
<link rel="stylesheet" href="../css/print.css" media="print">
|
|
|
|
<!-- Fonts -->
|
|
<link rel="stylesheet" href="../FontAwesome/css/font-awesome.css">
|
|
<link rel="stylesheet" href="../fonts/fonts.css">
|
|
|
|
<!-- Highlight.js Stylesheets -->
|
|
<link rel="stylesheet" href="../highlight.css">
|
|
<link rel="stylesheet" href="../tomorrow-night.css">
|
|
<link rel="stylesheet" href="../ayu-highlight.css">
|
|
|
|
<!-- Custom theme stylesheets -->
|
|
|
|
</head>
|
|
<body class="sidebar-visible no-js">
|
|
<div id="body-container">
|
|
<!-- Provide site root to javascript -->
|
|
<script>
|
|
var path_to_root = "../";
|
|
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "navy" : "navy";
|
|
</script>
|
|
|
|
<!-- Work around some values being stored in localStorage wrapped in quotes -->
|
|
<script>
|
|
try {
|
|
var theme = localStorage.getItem('mdbook-theme');
|
|
var sidebar = localStorage.getItem('mdbook-sidebar');
|
|
|
|
if (theme.startsWith('"') && theme.endsWith('"')) {
|
|
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
|
|
}
|
|
|
|
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
|
|
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
|
|
}
|
|
} catch (e) { }
|
|
</script>
|
|
|
|
<!-- Set the theme before any content is loaded, prevents flash -->
|
|
<script>
|
|
var theme;
|
|
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
|
|
if (theme === null || theme === undefined) { theme = default_theme; }
|
|
var html = document.querySelector('html');
|
|
html.classList.remove('navy')
|
|
html.classList.add(theme);
|
|
var body = document.querySelector('body');
|
|
body.classList.remove('no-js')
|
|
body.classList.add('js');
|
|
</script>
|
|
|
|
<input type="checkbox" id="sidebar-toggle-anchor" class="hidden">
|
|
|
|
<!-- Hide / unhide sidebar before it is displayed -->
|
|
<script>
|
|
var body = document.querySelector('body');
|
|
var sidebar = null;
|
|
var sidebar_toggle = document.getElementById("sidebar-toggle-anchor");
|
|
if (document.body.clientWidth >= 1080) {
|
|
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
|
|
sidebar = sidebar || 'visible';
|
|
} else {
|
|
sidebar = 'hidden';
|
|
}
|
|
sidebar_toggle.checked = sidebar === 'visible';
|
|
body.classList.remove('sidebar-visible');
|
|
body.classList.add("sidebar-" + sidebar);
|
|
</script>
|
|
|
|
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
|
|
<div class="sidebar-scrollbox">
|
|
<ol class="chapter"><li class="chapter-item expanded affix "><a href="../index.html">Introduction</a></li><li class="chapter-item expanded affix "><li class="part-title">Requirements & Traceability</li><li class="chapter-item expanded "><a href="../requirements.html"><strong aria-hidden="true">1.</strong> Requirements Specification</a></li><li class="chapter-item expanded "><a href="../traceability.html"><strong aria-hidden="true">2.</strong> Traceability Matrix</a></li><li class="chapter-item expanded "><a href="../traceability-ci.html"><strong aria-hidden="true">3.</strong> Traceability CI</a></li><li class="chapter-item expanded "><a href="../traces-quick-ref.html"><strong aria-hidden="true">4.</strong> Traces Quick Reference</a></li><li class="chapter-item expanded affix "><li class="part-title">Architecture</li><li class="chapter-item expanded "><a href="../architecture/index.html" class="active"><strong aria-hidden="true">5.</strong> Overview</a><a class="toggle"><div>❱</div></a></li><li><ol class="section"><li class="chapter-item "><a href="../architecture/01-rust-backend.html"><strong aria-hidden="true">5.1.</strong> Rust Backend</a></li><li class="chapter-item "><a href="../architecture/02-svelte-frontend.html"><strong aria-hidden="true">5.2.</strong> Svelte Frontend</a></li><li class="chapter-item "><a href="../architecture/03-data-flow.html"><strong aria-hidden="true">5.3.</strong> Data Flow</a></li><li class="chapter-item "><a href="../architecture/04-type-sync-and-threading.html"><strong aria-hidden="true">5.4.</strong> Type Sync & Threading</a></li><li class="chapter-item "><a href="../architecture/05-platform-backends.html"><strong aria-hidden="true">5.5.</strong> Platform Backends</a></li><li class="chapter-item "><a href="../architecture/06-downloads-and-offline.html"><strong aria-hidden="true">5.6.</strong> Downloads & Offline</a></li><li class="chapter-item "><a href="../architecture/07-connectivity.html"><strong aria-hidden="true">5.7.</strong> Connectivity</a></li><li class="chapter-item "><a href="../architecture/08-database-design.html"><strong aria-hidden="true">5.8.</strong> Database Design</a></li><li class="chapter-item "><a href="../architecture/09-security.html"><strong aria-hidden="true">5.9.</strong> Security</a></li></ol></li><li class="chapter-item expanded "><li class="part-title">UX</li><li class="chapter-item expanded "><a href="../ux-flows.html"><strong aria-hidden="true">6.</strong> UX Flows</a></li><li class="chapter-item expanded affix "><li class="part-title">Specs — Pending Work</li><li class="chapter-item expanded "><a href="../specs/index.html"><strong aria-hidden="true">7.</strong> Specs Index</a></li><li class="chapter-item expanded "><a href="../specs/SPEC-TEMPLATE.html"><strong aria-hidden="true">8.</strong> Spec Template</a></li><li class="chapter-item expanded "><a href="../specs/SPEC-REVIEW-CHECKLIST.html"><strong aria-hidden="true">9.</strong> Spec Review Checklist</a></li><li class="chapter-item expanded "><a href="../specs/playback-backend-unification.html"><strong aria-hidden="true">10.</strong> Playback Backend Unification</a></li><li class="chapter-item expanded "><a href="../specs/linux-native-video-spike.html"><strong aria-hidden="true">11.</strong> Linux Native Video Spike</a></li><li class="chapter-item expanded "><a href="../specs/backend-owned-stream-selection.html"><strong aria-hidden="true">12.</strong> Backend-Owned Stream Selection</a></li><li class="chapter-item expanded "><a href="../specs/player-facade-enforcement.html"><strong aria-hidden="true">13.</strong> Player Facade Enforcement</a></li><li class="chapter-item expanded "><a href="../specs/windows-native-audio-backend.html"><strong aria-hidden="true">14.</strong> Windows Native Audio Backend</a></li><li class="chapter-item expanded "><a href="../specs/libmpv2-migration.html"><strong aria-hidden="true">15.</strong> libmpv2 Migration</a></li><li class="chapter-item expanded "><a href="../specs/read-through-media-cache.html"><strong aria-hidden="true">16.</strong> Read-Through Media Cache</a></li><li class="chapter-item expanded "><a href="../specs/scoped-search.html"><strong aria-hidden="true">17.</strong> Scoped Search</a></li><li class="chapter-item expanded "><a href="../specs/scoped-search-boundary.html"><strong aria-hidden="true">18.</strong> Scoped Search Boundary</a></li><li class="chapter-item expanded "><a href="../specs/scoped-search-boundary-implementation.html"><strong aria-hidden="true">19.</strong> Scoped Search Boundary — Implementation</a></li><li class="chapter-item expanded "><a href="../specs/frontend-domain-model.html"><strong aria-hidden="true">20.</strong> Frontend Domain Model</a></li><li class="chapter-item expanded "><a href="../specs/desktop-native-video.html"><strong aria-hidden="true">21.</strong> Desktop Native Video</a></li><li class="chapter-item expanded "><a href="../specs/build-provenance.html"><strong aria-hidden="true">22.</strong> Build Provenance</a></li><li class="chapter-item expanded affix "><li class="part-title">Build & Release</li><li class="chapter-item expanded "><a href="../build/build-release.html"><strong aria-hidden="true">23.</strong> Build & Release</a></li><li class="chapter-item expanded "><a href="../release-checklist.html"><strong aria-hidden="true">24.</strong> Release Checklist</a></li><li class="chapter-item expanded "><a href="../native-player-verification.html"><strong aria-hidden="true">25.</strong> Native Player Verification</a></li><li class="chapter-item expanded "><a href="../build/build-desktop-packages.html"><strong aria-hidden="true">26.</strong> Desktop Packaging</a></li><li class="chapter-item expanded "><a href="../build/build-windows.html"><strong aria-hidden="true">27.</strong> Windows Build</a></li><li class="chapter-item expanded "><a href="../defect-windows.html"><strong aria-hidden="true">28.</strong> Defect Windows</a></li><li class="chapter-item expanded "><a href="../build/docker.html"><strong aria-hidden="true">29.</strong> Docker</a></li><li class="chapter-item expanded "><a href="../build/build-builder-image.html"><strong aria-hidden="true">30.</strong> Builder Image</a></li><li class="chapter-item expanded affix "><li class="spacer"></li><li class="chapter-item expanded affix "><a href="../api-redirect.html">Rust API Reference (rustdoc)</a></li></ol>
|
|
</div>
|
|
<div id="sidebar-resize-handle" class="sidebar-resize-handle">
|
|
<div class="sidebar-resize-indicator"></div>
|
|
</div>
|
|
</nav>
|
|
|
|
<!-- Track and set sidebar scroll position -->
|
|
<script>
|
|
var sidebarScrollbox = document.querySelector('#sidebar .sidebar-scrollbox');
|
|
sidebarScrollbox.addEventListener('click', function(e) {
|
|
if (e.target.tagName === 'A') {
|
|
sessionStorage.setItem('sidebar-scroll', sidebarScrollbox.scrollTop);
|
|
}
|
|
}, { passive: true });
|
|
var sidebarScrollTop = sessionStorage.getItem('sidebar-scroll');
|
|
sessionStorage.removeItem('sidebar-scroll');
|
|
if (sidebarScrollTop) {
|
|
// preserve sidebar scroll position when navigating via links within sidebar
|
|
sidebarScrollbox.scrollTop = sidebarScrollTop;
|
|
} else {
|
|
// scroll sidebar to current active section when navigating via "next/previous chapter" buttons
|
|
var activeSection = document.querySelector('#sidebar .active');
|
|
if (activeSection) {
|
|
activeSection.scrollIntoView({ block: 'center' });
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<div id="page-wrapper" class="page-wrapper">
|
|
|
|
<div class="page">
|
|
<div id="menu-bar-hover-placeholder"></div>
|
|
<div id="menu-bar" class="menu-bar sticky">
|
|
<div class="left-buttons">
|
|
<label id="sidebar-toggle" class="icon-button" for="sidebar-toggle-anchor" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
|
|
<i class="fa fa-bars"></i>
|
|
</label>
|
|
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
|
|
<i class="fa fa-paint-brush"></i>
|
|
</button>
|
|
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
|
|
<li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
|
|
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
|
|
</ul>
|
|
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
|
|
<i class="fa fa-search"></i>
|
|
</button>
|
|
</div>
|
|
|
|
<h1 class="menu-title">JellyTau Documentation</h1>
|
|
|
|
<div class="right-buttons">
|
|
<a href="../print.html" title="Print this book" aria-label="Print this book">
|
|
<i id="print-button" class="fa fa-print"></i>
|
|
</a>
|
|
<a href="https://gitea.tourolle.paris/dtourolle/jellytau" title="Git repository" aria-label="Git repository">
|
|
<i id="git-repository-button" class="fa fa-github"></i>
|
|
</a>
|
|
<a href="https://gitea.tourolle.paris/dtourolle/jellytau/_edit/master/docs/../docs/architecture/README.md" title="Suggest an edit" aria-label="Suggest an edit">
|
|
<i id="git-edit-button" class="fa fa-edit"></i>
|
|
</a>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div id="search-wrapper" class="hidden">
|
|
<form id="searchbar-outer" class="searchbar-outer">
|
|
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
|
|
</form>
|
|
<div id="searchresults-outer" class="searchresults-outer hidden">
|
|
<div id="searchresults-header" class="searchresults-header"></div>
|
|
<ul id="searchresults">
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
|
|
<script>
|
|
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
|
|
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
|
|
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
|
|
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
|
|
});
|
|
</script>
|
|
|
|
<div id="content" class="content">
|
|
<main>
|
|
<h1 id="jellytau-software-architecture"><a class="header" href="#jellytau-software-architecture">JellyTau Software Architecture</a></h1>
|
|
<p>This document describes the current architecture of JellyTau, a cross-platform Jellyfin client built with Tauri, SvelteKit, and Rust.</p>
|
|
<p><strong>Last Updated:</strong> 2026-06-20</p>
|
|
<h2 id="architecture-overview"><a class="header" href="#architecture-overview">Architecture Overview</a></h2>
|
|
<p>JellyTau uses a client-server architecture: business logic lives in a comprehensive Rust backend, while a UI-rich Svelte frontend handles presentation and interaction.</p>
|
|
<h3 id="architecture-principles"><a class="header" href="#architecture-principles">Architecture Principles</a></h3>
|
|
<ul>
|
|
<li><strong>Business Logic in Rust</strong>: Core logic — playback, repository, sync, downloads, connectivity — lives in Rust for performance, reliability, and type safety.</li>
|
|
<li><strong>Presentation in Svelte</strong>: The frontend (~20.5k non-test lines) owns UI, layout, navigation, and interaction state and invokes Rust commands. It is intentionally UI-heavy, <strong>not</strong> a thin wrapper. Largest pieces: components + routes (~14.6k lines), stores (~3.4k), api/services/utils (~2.4k); <code>VideoPlayer.svelte</code> alone is ~1.6k lines.</li>
|
|
<li><strong>Events + Polling hybrid</strong>: Rust emits events the frontend listens to, and the UI also polls status on short intervals in a few hot spots (e.g. queue status in <code>library/+layout.svelte</code>, playback progress in <code>VideoPlayer.svelte</code>).</li>
|
|
<li><strong>Unified player boundary</strong>: UI components control playback only through the frontend facade <code>src/lib/player/index.ts</code> (<code>playerController</code>), never by calling <code>commands.player*</code> directly. Webview-rendered HTML5 video reports its state back into Rust via <code>src/lib/player/html5Adapter.ts</code> and the <code>player_report_*</code> commands, so the <code>PlayerController</code> stays the single source of truth in both native (MPV/ExoPlayer) and HTML5 modes (see <a href="05-platform-backends.html">05-platform-backends.md</a>).</li>
|
|
<li><strong>Handle-Based Resources</strong>: UUID handles for stateful Rust objects.</li>
|
|
<li><strong>Cache-First</strong>: Parallel queries with intelligent fallback.</li>
|
|
<li><strong>Single source of truth for reachability</strong>: Server reachability is derived from the outcome of <em>real repository traffic</em>, not a side-channel poller. The <code>OnlineRepository</code> reports each server result to the <code>ConnectivityMonitor</code> (classified via <code>RepoError</code>), which applies a time-window debounce before declaring the server offline and recovers instantly on the first success. The standalone <code>/System/Info/Public</code> probe runs <em>only while offline</em>, as a recovery detector for idle sessions.</li>
|
|
<li><strong>Poison-tolerant locking</strong>: Shared <code>std::sync</code> state is accessed via the <code>MutexSafe</code>/<code>RwLockSafe</code> helpers in <code>utils/lock.rs</code>, which recover a poisoned lock instead of cascading a panic across the player.</li>
|
|
<li><strong>Graceful backend init</strong>: If a native player backend (MPV/ExoPlayer) fails to initialize, the app falls back to a no-op backend and emits a <code>backend-init-failed</code> event rather than crashing.</li>
|
|
</ul>
|
|
<pre><code class="language-mermaid">flowchart TB
|
|
subgraph Frontend["Svelte Frontend"]
|
|
subgraph Stores["Stores (Thin Wrappers)"]
|
|
auth["auth"]
|
|
player["player"]
|
|
queue["queue"]
|
|
library["library"]
|
|
connectivity["connectivity"]
|
|
playbackMode["playbackMode"]
|
|
end
|
|
subgraph Components
|
|
playerComp["player/"]
|
|
libraryComp["library/"]
|
|
Search["Search"]
|
|
end
|
|
subgraph Routes
|
|
routeLibrary["/library"]
|
|
routePlayer["/player"]
|
|
routeRoot["/"]
|
|
end
|
|
subgraph API["API Layer (Thin Client)"]
|
|
RepositoryClient["RepositoryClient<br/>(Handle-based)"]
|
|
JellyfinClient["JellyfinClient<br/>(Helper)"]
|
|
end
|
|
end
|
|
|
|
Frontend -->|"Tauri IPC (invoke)"| Backend
|
|
|
|
subgraph Backend["Rust Backend (Business Logic)"]
|
|
subgraph Commands["Tauri Commands (90+)"]
|
|
PlayerCmds["player.rs"]
|
|
RepoCmds["repository.rs (27)"]
|
|
PlaybackModeCmds["playback_mode.rs (5)"]
|
|
StorageCmds["storage.rs"]
|
|
ConnectivityCmds["connectivity.rs (7)"]
|
|
end
|
|
|
|
subgraph Core["Core Modules"]
|
|
MediaSessionManager["MediaSessionManager<br/>(Audio/Movie/TvShow/Idle)"]
|
|
|
|
PlayerController["PlayerController<br/>+ PlayerBackend<br/>+ QueueManager"]
|
|
|
|
Repository["Repository Layer<br/>HybridRepository (cache-first)<br/>OnlineRepository (HTTP)<br/>OfflineRepository (SQLite)"]
|
|
|
|
PlaybackModeManager["PlaybackModeManager<br/>(Local/Remote/Idle)"]
|
|
|
|
ConnectivityMonitor["ConnectivityMonitor<br/>(Adaptive polling)"]
|
|
|
|
HttpClient["HttpClient<br/>(Exponential backoff retry)"]
|
|
end
|
|
|
|
subgraph Storage["Storage Layer"]
|
|
DatabaseService["DatabaseService<br/>(Async trait)"]
|
|
SQLite["SQLite Database<br/>(13 tables)"]
|
|
end
|
|
|
|
Commands --> Core
|
|
Core --> Storage
|
|
Repository --> HttpClient
|
|
Repository --> DatabaseService
|
|
Repository -->|"reports server outcome<br/>(success / RepoError)"| ConnectivityMonitor
|
|
end
|
|
</code></pre>
|
|
<blockquote>
|
|
<p>The <code>Repository --> ConnectivityMonitor</code> edge is the source of truth for the offline/online banner: every server request the user actually makes updates reachability. The monitor's own polling is now an offline-only recovery probe (see <a href="07-connectivity.html">07-connectivity.md</a>).</p>
|
|
</blockquote>
|
|
<hr />
|
|
<h2 id="detailed-documentation"><a class="header" href="#detailed-documentation">Detailed Documentation</a></h2>
|
|
<p>Each major subsystem is documented in its own file in this directory:</p>
|
|
<div class="table-wrapper"><table><thead><tr><th>Document</th><th>Contents</th></tr></thead><tbody>
|
|
<tr><td><a href="01-rust-backend.html">01 - Rust Backend</a></td><td>Media session state machine, player state machine, playback mode, media items, queue manager, favorites (marking + browsing), player backend trait, player controller, playlist system, <strong>domain vocabulary owned by Rust</strong> (search scope, library exclusions, streaming quality ladder), <strong>background workers</strong> (catalog indexer, drains), Tauri commands</td></tr>
|
|
<tr><td><a href="02-svelte-frontend.html">02 - Svelte Frontend</a></td><td>Store structure, music library navigation, playback reporting, repository architecture, playback mode system, database service abstraction, component hierarchy, MiniPlayer, sleep timer, auto-play, navigation guard, playlist management UI, library mosaic, series/episode navigation, downloaded browse, safe-area insets, native-video store, logging</td></tr>
|
|
<tr><td><a href="03-data-flow.html">03 - Data Flow</a></td><td>Repository query flow (cache-first), locally-indexed search, playback initiation, playback mode transfer, queue navigation, volume control</td></tr>
|
|
<tr><td><a href="04-type-sync-and-threading.html">04 - Type Sync & Threading</a></td><td>Rust/TypeScript type synchronization, Tauri v2 IPC parameter naming convention, thread safety patterns</td></tr>
|
|
<tr><td><a href="05-platform-backends.html">05 - Platform Backends</a></td><td>Player events system, HTML5 video adapter, MpvBackend (Linux), ExoPlayerBackend (Android) incl. audio settings parity, <strong>native video compositing</strong>, MediaSession & remote volume, album art caching, backend initialization</td></tr>
|
|
<tr><td><a href="06-downloads-and-offline.html">06 - Downloads & Offline</a></td><td>Download manager, download worker, smart caching engine, <strong>one storage model (cache entries are downloads)</strong>, offline catalog visibility, download/offline commands, player integration, frontend store, UI components</td></tr>
|
|
<tr><td><a href="07-connectivity.html">07 - Connectivity</a></td><td>HTTP client with retry logic, connectivity monitor, network resilience architecture</td></tr>
|
|
<tr><td><a href="08-database-design.html">08 - Database Design</a></td><td>Entity relationships, all table definitions (servers, users, libraries, items, user_data, downloads, media_streams, sync_queue, thumbnails, playlists), key queries, data flow diagrams, storage estimates</td></tr>
|
|
<tr><td><a href="09-security.html">09 - Security</a></td><td>Authentication token storage, secure storage module, network security, webview CSP + asset-protocol scope, <strong>path confinement and input binding</strong>, local data protection</td></tr>
|
|
</tbody></table>
|
|
</div>
|
|
<hr />
|
|
<h2 id="file-structure-summary"><a class="header" href="#file-structure-summary">File Structure Summary</a></h2>
|
|
<pre><code>src-tauri/src/
|
|
├── lib.rs # Tauri app setup, state initialization
|
|
├── commands/ # Tauri command handlers (~245 #[tauri::command] fns)
|
|
│ ├── mod.rs # Command exports
|
|
│ ├── player/ # Player commands: queue, remote, session, settings, timers
|
|
│ ├── repository.rs # Repository commands (items, search, favourites, disk usage)
|
|
│ ├── catalog.rs # Catalog sync + the background index pass
|
|
│ ├── favorites.rs # Offline favourite drain
|
|
│ ├── library.rs # Library listing + folder exclusions
|
|
│ ├── playlist.rs # Playlist commands
|
|
│ ├── playback_mode.rs # Local/remote transfer
|
|
│ ├── playback_reporting.rs
|
|
│ ├── connectivity.rs # Connectivity commands
|
|
│ ├── storage/ # Storage & database commands: people, series_prefs, thumbnails
|
|
│ ├── download/ # Download commands: mod, pinning, smart_cache
|
|
│ ├── offline.rs # Offline commands
|
|
│ ├── device.rs # Device id / capabilities
|
|
│ ├── sessions.rs # Remote sessions
|
|
│ ├── sync.rs # Sync queue commands
|
|
│ └── sync_drain.rs # Background sync-queue drain
|
|
├── repository/ # Repository pattern implementation
|
|
│ ├── mod.rs # MediaRepository trait, handle management
|
|
│ ├── types.rs # RepoError, Library, MediaItem, etc.
|
|
│ ├── hybrid.rs # HybridRepository with cache-first racing
|
|
│ ├── online.rs # OnlineRepository (HTTP API)
|
|
│ └── offline.rs # OfflineRepository (SQLite queries)
|
|
├── playback_mode/ # Playback mode manager
|
|
│ └── mod.rs # PlaybackMode enum, transfer logic
|
|
├── connectivity/ # Connectivity monitoring
|
|
│ └── mod.rs # ConnectivityMonitor, adaptive polling
|
|
├── jellyfin/ # Jellyfin API client
|
|
│ ├── mod.rs # Module exports
|
|
│ ├── http_client.rs # HTTP client with retry logic
|
|
│ └── client.rs # JellyfinClient for API calls
|
|
├── storage/ # Database layer
|
|
│ ├── mod.rs # Database struct, migrations
|
|
│ ├── db_service.rs # DatabaseService trait (async wrapper)
|
|
│ ├── schema.rs # Table definitions
|
|
│ └── queries/ # Query modules
|
|
├── download/ # Download manager module
|
|
│ ├── mod.rs # DownloadManager, DownloadInfo, DownloadTask
|
|
│ ├── worker.rs # DownloadWorker, HTTP streaming, retry logic
|
|
│ ├── events.rs # DownloadEvent enum
|
|
│ └── cache.rs # SmartCache, CacheConfig, LRU eviction
|
|
└── player/ # Player subsystem
|
|
├── mod.rs # PlayerController
|
|
├── session.rs # MediaSessionManager, MediaSessionType
|
|
├── state.rs # PlayerState, PlayerEvent
|
|
├── media.rs # MediaItem, MediaSource, MediaType
|
|
├── queue.rs # QueueManager, RepeatMode
|
|
├── backend.rs # PlayerBackend trait, NullBackend
|
|
├── events.rs # PlayerStatusEvent, TauriEventEmitter
|
|
├── mpv/ # Linux MPV backend
|
|
│ ├── mod.rs # MpvBackend implementation
|
|
│ └── event_loop.rs # Dedicated thread for MPV operations
|
|
└── android/ # Android ExoPlayer backend
|
|
└── mod.rs # ExoPlayerBackend + JNI bindings
|
|
|
|
src/lib/
|
|
├── api/ # Thin API layer (~200 lines total)
|
|
│ ├── types.ts # TypeScript type definitions
|
|
│ ├── repository-client.ts # RepositoryClient wrapper (~100 lines)
|
|
│ ├── client.ts # JellyfinClient (helper for streaming)
|
|
│ └── sessions.ts # SessionsApi (remote session control)
|
|
├── player/ # Unified player boundary (frontend)
|
|
│ ├── index.ts # playerController facade — the only write-side entry point for playback
|
|
│ └── html5Adapter.ts # Reports webview <video> DOM events back into Rust (player_report_*)
|
|
├── services/
|
|
│ ├── playerEvents.ts # Tauri event listener for player events
|
|
│ └── playbackReporting.ts # Thin wrapper (~50 lines)
|
|
├── stores/ # Thin reactive wrappers over Rust commands
|
|
│ ├── index.ts # Re-exports
|
|
│ ├── auth.ts # Auth store (calls Rust commands)
|
|
│ ├── player.ts # Player store
|
|
│ ├── queue.ts # Queue store
|
|
│ ├── library.ts # Library store
|
|
│ ├── playbackMode.ts # Playback mode store (~150 lines)
|
|
│ ├── connectivity.ts # Connectivity store (~250 lines)
|
|
│ └── downloads.ts # Downloads store with event listeners
|
|
└── components/
|
|
├── Search.svelte
|
|
├── player/ # Player UI components
|
|
├── playlist/ # Playlist modals (Create, AddTo)
|
|
├── sessions/ # Remote session control UI
|
|
├── downloads/ # Download UI components
|
|
└── library/ # Library UI components + PlaylistDetailView
|
|
</code></pre>
|
|
<h2 id="key-architecture-changes"><a class="header" href="#key-architecture-changes">Key Architecture Changes</a></h2>
|
|
<p><strong>What moved to Rust (~3,500 lines of business logic):</strong></p>
|
|
<ol>
|
|
<li><strong>HTTP Client</strong> (338 lines) - Retry logic with exponential backoff</li>
|
|
<li><strong>Connectivity Monitor</strong> (301 lines) - Reachability derived from real repository traffic, time-window debounce, offline-only recovery probe, event emission</li>
|
|
<li><strong>Repository Pattern</strong> (1061 lines) - Cache-first hybrid with parallel racing</li>
|
|
<li><strong>Database Service</strong> - Async wrapper preventing UI freezing</li>
|
|
<li><strong>Playback Mode</strong> (303 lines) - Local/remote transfer coordination</li>
|
|
</ol>
|
|
<p><strong>Svelte/TypeScript frontend (~20.5k non-test lines, plus ~9.6k test lines):</strong></p>
|
|
<ul>
|
|
<li>Components + routes (~14.6k lines) — UI and presentation</li>
|
|
<li>Stores (~3.4k lines) — reactive state that invokes Rust commands and listens for events</li>
|
|
<li>api / services / utils (~2.4k lines) — typed clients, event listeners, conversion helpers</li>
|
|
</ul>
|
|
<p>The frontend is genuinely UI-heavy; business decisions live in Rust, but the UI owns layout, navigation, and interaction state.</p>
|
|
<p><strong>Total Commands:</strong> ~245 <code>#[tauri::command]</code> functions across 17 command modules
|
|
(~58k lines of Rust, ~37k non-test lines of TypeScript/Svelte).</p>
|
|
<blockquote>
|
|
<p>Counts and line totals in this file are periodic snapshots, not gates — the
|
|
authority is the tree. Regenerate with
|
|
<code>grep -rc '#\[tauri::command\]' src-tauri/src</code> and <code>wc -l</code>.</p>
|
|
</blockquote>
|
|
|
|
</main>
|
|
|
|
<nav class="nav-wrapper" aria-label="Page navigation">
|
|
<!-- Mobile navigation buttons -->
|
|
<a rel="prev" href="../traces-quick-ref.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
|
|
<i class="fa fa-angle-left"></i>
|
|
</a>
|
|
|
|
<a rel="next prefetch" href="../architecture/01-rust-backend.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
|
|
<i class="fa fa-angle-right"></i>
|
|
</a>
|
|
|
|
<div style="clear: both"></div>
|
|
</nav>
|
|
</div>
|
|
</div>
|
|
|
|
<nav class="nav-wide-wrapper" aria-label="Page navigation">
|
|
<a rel="prev" href="../traces-quick-ref.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
|
|
<i class="fa fa-angle-left"></i>
|
|
</a>
|
|
|
|
<a rel="next prefetch" href="../architecture/01-rust-backend.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
|
|
<i class="fa fa-angle-right"></i>
|
|
</a>
|
|
</nav>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
window.playground_copyable = true;
|
|
</script>
|
|
|
|
|
|
<script src="../elasticlunr.min.js"></script>
|
|
<script src="../mark.min.js"></script>
|
|
<script src="../searcher.js"></script>
|
|
|
|
<script src="../clipboard.min.js"></script>
|
|
<script src="../highlight.js"></script>
|
|
<script src="../book.js"></script>
|
|
|
|
<!-- Custom JS scripts -->
|
|
|
|
|
|
</div>
|
|
</body>
|
|
</html>
|