How harborstremio/harbor works
Purpose and entry points
Harbor is a self-contained desktop/web client for the open Stremio addon ecosystem; it supplies UI, playback, ranking, and local integrations, not media or bundled content addons. The React application starts at src/main.tsx, mounts src/App.tsx, and routes through src/router/router.tsx. Native builds enter through src-tauri/src/main.rs; src-tauri/src/lib.rs wires Tauri commands and lifecycle services.
Application layers and navigation
The TypeScript/React frontend owns rooms, title flows, player UI, state, and remote-service clients. Route-level screens in src/views/home.tsx, src/views/detail.tsx, and src/views/player.tsx compose reusable visual chrome and components. src/router/index.ts and src/router/sync.tsx form the navigation/deep-link boundary; view code should consume src/lib domain modules rather than invoke native or remote APIs ad hoc.
Metadata, catalogs, and account integrations
Stremio addon resources provide catalogs, metadata, streams, and subtitles, mediated by src/lib/stremio.ts, src/lib/addons.ts, and src/lib/streams/addons.ts. Provider adapters normalize/enrich external metadata—principally TMDB, Cinemeta, Kitsu/AniZip, ratings/artwork services—under src/lib/providers/. Account-specific sync is partitioned by service, e.g. src/lib/trakt/, src/lib/anilist/, and src/lib/simkl/; local settings, profiles, and credentials remain client-side via src/lib/settings.tsx, src/lib/settings/, and native src-tauri/src/settings_store.rs.
Stream acquisition and ranking
Pressing play collects addon offers concurrently, resolves/decorates them, then applies parse → trust → score → rank. Frontend orchestration and fallback behavior reside in src/lib/streams/pipeline.ts, src/lib/streams/resolve.ts, and src/lib/streams/scoring.ts. The authoritative pure-Rust engine is harbor-core/src/lib.rs, with stages in harbor-core/src/parser.rs, harbor-core/src/trust.rs, and harbor-core/src/scoring.rs; it is compiled to WASM for the UI. Debrid adapters and direct-torrent paths are separate boundaries at src/lib/debrid/registry.ts, src/lib/torrent/local-engine.ts, and src-tauri/src/torrent_engine.rs.
Playback and native media boundary
The player route coordinates stream selection, progress, subtitles, casting, party sync, and controls; native invocation is abstracted through src/lib/player/bridge.ts and src/lib/player/mpv.ts. Rust hosts libmpv and platform rendering in src-tauri/src/mpv.rs, src-tauri/src/mpv_render_linux.rs, and src-tauri/src/mpv_render_mac.rs; HTML5 is an alternative frontend engine in src/lib/player/html5/. Native services also expose downloads/transcoding, subtitle extraction/synchronization, local-library scans, and local HTTP/proxy functions through src-tauri/src/download.rs, src-tauri/src/transcode.rs, src-tauri/src/subsync/mod.rs, and src-tauri/src/web_server.rs.
Live, casting, and synchronized playback
IPTV ingests M3U/Xtream/XMLTV sources, persists playlists, resolves EPG/catch-up, and feeds Live/Multiview views through src/lib/iptv/ingest/load.ts, src/lib/iptv/store.ts, and src/views/live.tsx. LAN casting is implemented natively for Chromecast/DLNA/AirPlay/Roku in src-tauri/src/cast.rs, src-tauri/src/dlna.rs, and src-tauri/src/roku.rs, with HLS/subtitle/transcode support. Together watch parties use frontend protocol/client layers in src/lib/together/ and deploy/use a user-owned Cloudflare Worker relay at src-tauri/relay/worker.js.
Runtime, packaging, and infrastructure
Runtime targets are browser and Tauri 2 desktop shells using the system webview; frontend builds use Vite, while Rust handles OS integration. Native sidecars include libmpv, ffmpeg/ffprobe, yt-dlp, and Stremio Server, fetched by scripts/fetch-*.mjs into src-tauri/. Packaging is defined by src-tauri/tauri.conf.json, with platform variants and Flatpak manifests under flatpak/. Docker artifacts (Dockerfile, docker-compose.yaml) support containerized deployment; GitHub workflows build CI, Tauri, Flatpak, and core artifacts.
Main entry points: player.tsx Primary screens · lib.rs Tauri application · pipeline.ts Stream pipeline · bridge.ts Player bridge
Components 23
React frontend
Browser and Tauri-webview application layers.
- Frontend entry
src/main.tsx - App and routes
src/router/router.tsx - Primary screens · Home, detail, player, and live screens compose the user experience.
src/views/player.tsx - Deep-link sync
src/router/sync.tsx - Settings and profiles
src/lib/settings.tsx - IPTV ingest and store · Loads sources, persists playlists, and resolves EPG/catch-up.
src/lib/iptv/ingest/load.ts - Player bridge · Abstracts native player invocation from route UI.
src/lib/player/bridge.ts - HTML5 player · Alternative frontend playback engine.
- Together watch party
Stream pipeline
Addon acquisition and stream ranking.
- Stremio resources · Mediates catalogs, metadata, streams, and subtitles.
src/lib/stremio.ts - Metadata providers · Normalizes TMDB, Cinemeta, Kitsu/AniZip, ratings, and artwork.
- Account sync · Client integrations for Trakt, AniList, and SIMKL.
- Stream pipeline · Collects offers concurrently and applies resolution, fallback, and ranking.
src/lib/streams/pipeline.ts - Offer resolution
src/lib/streams/resolve.ts - Ranking engine · Authoritative pure engine for parse, trust, score, and rank.
harbor-core/src/lib.rs - Debrid and torrents · Debrid adapters and local torrent paths.
src/lib/debrid/registry.ts
Tauri native services
Rust commands, media services, and OS integrations.
- Tauri application · Wires commands and lifecycle services.
src-tauri/src/lib.rs - libmpv host · Hosts libmpv and platform rendering.
src-tauri/src/mpv.rs - Native media services · Downloads, transcoding, subtitle sync, local HTTP/proxy, and library scans.
src-tauri/src/transcode.rs - LAN casting · Chromecast, DLNA, AirPlay, and Roku with HLS/subtitle support.
src-tauri/src/cast.rs
External ecosystem
Remote addons, providers, accounts, and party relay.
- User-owned party relay
src-tauri/relay/worker.js - Stremio addon ecosystem · Supplies catalogs, metadata, streams, and subtitles.
- Metadata and account services
Connections 23
- Frontend entry → App and routes: mounts
- App and routes → Primary screens: renders routes
- Deep-link sync → App and routes: syncs navigation
- Primary screens → Stremio resources: uses domain client
- Primary screens → Stream pipeline: requests playable offers
- Primary screens → IPTV ingest and store: feeds live views
- Primary screens → Player bridge: coordinates playback
- Primary screens → Together watch party: synchronizes parties
- Stremio resources → Stremio addon ecosystem: fetches resources
- Metadata providers → Metadata and account services: enriches from
- Account sync → Metadata and account services: syncs with
- Settings and profiles → Tauri application: persists through commands
- Stream pipeline → Stremio resources: collects offers
- Stream pipeline → Offer resolution: resolves and decorates
- Offer resolution → Debrid and torrents: selects transport
- Stream pipeline → Ranking engine: ranks via WASM
- Player bridge → Tauri application: invokes commands
- Player bridge → HTML5 player: can use
- Tauri application → libmpv host: hosts playback
- Tauri application → Native media services: exposes services
- Tauri application → LAN casting: exposes casting
- Together watch party → User-owned party relay: relays sync protocol
- LAN casting → Native media services: uses transcode and HLS