How dhrvjgd/grabbr works
Purpose and Application Boundaries
Grabbr is a cross-platform desktop multimedia downloader for YouTube and Instagram. It packages a Svelte renderer inside an Electrobun/Bun desktop process, using local yt-dlp, FFmpeg, and ffprobe binaries; it also includes a separate public marketing web app. Core entry points are apps/desktop/src/index.ts, apps/ui/src/main.ts, and apps/web/src/routes/+page.svelte.
Desktop Host and IPC Boundary
The Electrobun main process owns native lifecycle, window integration, single-instance behavior, local persistence, process execution, and updates. apps/desktop/src/index.ts initializes this host; apps/desktop/src/rpc/index.ts exposes typed request/response handlers and one-way messages. Shared RPC shapes form the explicit renderer/main contract in packages/contracts/src/rpc.ts; the renderer accesses it through apps/ui/src/lib/rpc.ts.
Renderer Application
The UI is a Svelte 5 SPA providing URL submission, download controls, preferences, and status/toast presentation. apps/ui/src/app.svelte composes the application; apps/ui/src/lib/components/input-url.svelte initiates user download requests; apps/ui/src/lib/components/options/index.svelte organizes audio, video, encoding, sorting, update, and experimental preferences. Event listeners consume main-process download and updater messages in apps/ui/src/lib/listeners/download.ts and apps/ui/src/lib/listeners/updater.ts.
Download Execution Pipeline
A submitted URL and saved/current options cross RPC into the desktop download service at apps/desktop/src/services/download.ts. That service constructs yt-dlp and optional FFmpeg post-processing arguments from apps/desktop/src/lib/args/index.ts, including media-specific behavior in apps/desktop/src/lib/args/audio/index.ts and apps/desktop/src/lib/args/video/index.ts. Child-process spawning, output parsing, and lifecycle control are isolated in apps/desktop/src/lib/procs.ts; progress and terminal results are emitted back through apps/desktop/src/callbacks/download.ts.
Media Binaries and Hardware Decisions
The application ships or downloads platform-specific yt-dlp, FFmpeg, and ffprobe dependencies before builds via apps/desktop/scripts/pre-build/download-binaries.ts. Runtime binary resolution is centralized in apps/desktop/src/lib/binary-paths.ts. Shared media semantics and preference types live in packages/shared/src/ytdlp.ts, packages/shared/src/ffmpeg.ts, and packages/shared/src/preferences.ts; system GPU/vendor detection informing hardware encoding occurs in apps/desktop/src/lib/system-info.ts.
Local State and Update Services
Preferences are persisted locally in SQLite (bun:sqlite) behind apps/desktop/src/services/preferences.ts, with storage/cache concerns in apps/desktop/src/lib/store.ts. The UI maintains reactive preference state in apps/ui/src/lib/preferences.svelte.ts. apps/desktop/src/services/update.ts separates yt-dlp version/update operations and app auto-update integration from download work, keeping external update mechanisms outside renderer trust boundaries.
Packaging, Distribution, and Web Presence
apps/desktop/electrobun.config.ts defines desktop packaging across Windows, macOS, and Linux; pre/post build scripts prepare binaries and patch packaged artifacts. Release automation is in .github/workflows/release.yml. The independent SvelteKit/Vercel web app under apps/web/src/routes/+layout.svelte and apps/web/src/routes/+page.svelte serves product content rather than participating in desktop download execution.
Main entry points: index.ts RPC handlers · app.svelte Grabbr UI · download.ts Download service · procs.ts Process runner
Components 23
Desktop Renderer
Svelte SPA running in the desktop window.
- Renderer entry
apps/ui/src/main.ts - Grabbr UI · Composes submission, controls, preferences, and status UI.
apps/ui/src/app.svelte - URL submission
apps/ui/src/lib/components/input-url.svelte - Download preferences
apps/ui/src/lib/components/options/index.svelte - Renderer RPC client
apps/ui/src/lib/rpc.ts - Reactive preferences
apps/ui/src/lib/preferences.svelte.ts - Download event listener
apps/ui/src/lib/listeners/download.ts - Updater event listener
apps/ui/src/lib/listeners/updater.ts
Desktop Host
Electrobun/Bun main-process boundary.
- Desktop host entry
apps/desktop/src/index.ts - RPC handlers
apps/desktop/src/rpc/index.ts - Download service
apps/desktop/src/services/download.ts - Preferences service
apps/desktop/src/services/preferences.ts - SQLite store
apps/desktop/src/lib/store.ts - Update service · Handles yt-dlp updates and app auto-update integration.
apps/desktop/src/services/update.ts
Media Execution
Local binary preparation and download pipeline.
- Media argument builder · Builds yt-dlp and FFmpeg arguments, including audio and video behavior.
apps/desktop/src/lib/args/index.ts - Process runner · Spawns tools, parses output, and controls process lifecycle.
apps/desktop/src/lib/procs.ts - Download callbacks · Emits progress and terminal download results.
apps/desktop/src/callbacks/download.ts - Media binaries · Prepared per platform and resolved at runtime.
apps/desktop/src/lib/binary-paths.ts
Distribution
Desktop packaging, releases, and public site.
- Desktop packaging · Builds Windows, macOS, and Linux artifacts.
apps/desktop/electrobun.config.ts - Release automation
.github/workflows/release.yml - Marketing web app · Independent product-content site.
apps/web/src/routes/+page.svelte
Other components
- RPC contract · Typed renderer/main request and event boundary.
packages/contracts/src/rpc.ts - Shared media semantics · Media and preference types shared across runtimes.
packages/shared/src/ytdlp.ts
Connections 22
- Desktop host entry → RPC handlers: initializes
- Renderer entry → Grabbr UI: mounts
- Grabbr UI → URL submission: renders
- Grabbr UI → Download preferences: renders
- URL submission → Renderer RPC client: submits URL
- Download preferences → Reactive preferences: edits
- Reactive preferences → Renderer RPC client: supplies options
- Renderer RPC client → RPC contract: implements
- RPC handlers → RPC contract: implements
- RPC handlers → Download service: dispatches download
- RPC handlers → Preferences service: dispatches preferences
- RPC handlers → Update service: dispatches updates
- Preferences service → SQLite store: persists to
- Download service → Media argument builder: builds arguments
- Download service → Process runner: executes via
- Media argument builder → Shared media semantics: uses media types
- Process runner → Media binaries: runs
- Process runner → Download callbacks: reports lifecycle
- Download callbacks → Download event listener: sends download events
- Update service → Updater event listener: sends updater events
- Desktop packaging → Media binaries: packages
- Release automation → Desktop packaging: publishes