How ronalusuriano008-ux/ytdlp works
1. Top-level shape
- This is a monorepo split into three runtime apps plus a shared package:
- apps/web = browser frontend
- apps/api = Node.js/Express backend
- apps/worker = Python media-processing service
- packages/shared = cross-app constants/contracts
- The intended system flow is: Web → API → Worker → yt-dlp/ffmpeg.
2. Frontend boundary: static, modular UI
- apps/web is not a React/Vue SPA; it is a static HTML/CSS/JavaScript frontend.
- Public entry pages live in apps/web/public/*.html for the main user areas: search/home, music, history, favorites, downloads, profile.
- The real behavior is organized under apps/web/src, with feature modules for auth, search, player, download, history, voice, websocket, background, downloads page.
- This suggests a page-oriented UI with reusable client-side modules rather than a server-rendered app.
3. API boundary: orchestration and transport
- apps/api/src/server.js is the Node entrypoint.
- The API is organized as Express routes:
- auth.routes.js
- search.routes.js
- stream.routes.js
- metadata.routes.js
- download.routes.js
- user.routes.js
- The API’s job is to accept browser requests, validate/shape them, coordinate worker calls, and expose progress/status to the frontend.
4. Worker boundary: media execution
- apps/worker is the execution layer for the heavy lifting.
- Python modules show the worker responsibilities clearly:
- ytdlp_runner.py for downloading/extracting via yt-dlp
- ffmpeg_runner.py for media conversion/remuxing via ffmpeg
- metadata.py for content inspection
- models/job.py for job state/data
- This layer isolates external binaries and long-running media tasks away from the Node API.
5. Job and queue flow
- The API contains services/queue.js, which implies download/processing requests are queued rather than handled synchronously.
- services/pythonClient.js is the bridge from Node to the Python worker.
- In practice, the architecture is likely: the web client submits a search/stream/download request, the API creates or forwards a job, and the worker processes it asynchronously.
- This separation is important for an architecture diagram because the worker is not just a library; it is a distinct service boundary.
6. Real-time progress
- apps/api/src/websocket/progress.gateway.js and apps/web/src/features/websocket/websocket.js indicate a WebSocket channel for live progress updates.
- This is the main feedback path for long-running downloads/conversions, which is essential because yt-dlp/ffmpeg jobs can take time.
- So the UI likely gets initial responses via REST, then listens on WebSockets for job progress and completion.
7. User/file tracking and persistence
- apps/api/src/services/userFileService.js suggests the API manages some form of user-associated file history or download records.
- The README mentions temporary JSON persistence, so this is probably lightweight state rather than a database-backed domain model.
- There is also a user.routes.js, implying user-oriented records like profile, history, or favorites are exposed through the API.
8. Shared contracts
- packages/shared/constants contains events.js, roles.js, and routes.js.
- This package acts as the contract layer between frontend, API, and worker, reducing drift in event names and route constants.
- For a diagram, this is a small but important boundary: it is not business logic, it is shared integration metadata.
9. Feature decomposition on the frontend
- The frontend modules map closely to user workflows:
- search: discovery and query history
- player: preview playback, loading, prebuffering, UI
- download: audio/video download state and status handling
- history and downloads: user-visible records
- voice and background: auxiliary UX features
- auth/session: browser session handling
- This makes the frontend a composition of feature islands around one shared API.
10. Runtime and deployment boundaries
- The stack is intentionally split by runtime:
- Node.js 18+ for API and web tooling
- Python 3.10+ for the worker
- yt-dlp and ffmpeg as external executables used only by the worker
- The README’s deployment model implies independent serving:
- static frontend via Nginx or similar
- API as a Node service
- worker as a Python service
- That separation is one of the main architectural decisions in the repo.
11. What to emphasize in a diagram
- Show the browser as the entry point.
- Show REST routes for search, metadata, stream, download, auth, user.
- Show WebSocket progress as a side channel from API back to browser.
- Show API-to-worker communication as the async processing boundary.
- Show the worker invoking yt-dlp/ffmpeg and returning structured results/progress.
12. Repository maturity signals
- The presence of mainv1 files in both web and worker suggests an evolving codebase with legacy paths preserved during refactoring.
- That usually means the current architecture is intentionally modular, but there may be older implementation variants still present.
- For architecture purposes, treat the current split into web / api / worker / shared as the authoritative structure.
Main entry points: server.js Server · src Feature modules · progress.gateway.js Progress gateway · public Public pages
Components 21
Web app
Static browser frontend and client-side modules
- Public pages · Page-oriented HTML entry points for main user areas
apps/web/public - Feature modules · Reusable frontend logic for auth, search, player, downloads, history, voice, and websocket
apps/web/src - Styles · Shared CSS and legacy styling
apps/web/assets/styles
API service
Node/Express orchestration layer
- Server · Node.js API bootstrap and HTTP composition
apps/api/src/server.js - Auth routes · Authentication and session-related endpoints
apps/api/src/routes/auth.routes.js - Search routes · Search and discovery endpoints
apps/api/src/routes/search.routes.js - Stream routes · Playback and stream delivery endpoints
apps/api/src/routes/stream.routes.js - Metadata routes · Track and media metadata endpoints
apps/api/src/routes/metadata.routes.js - Download routes · Download creation and status endpoints
apps/api/src/routes/download.routes.js - User routes · User-facing records such as history, favorites, and profile data
apps/api/src/routes/user.routes.js - Queue · Asynchronous coordination for long-running work
apps/api/src/services/queue.js - Python bridge · Node-to-worker integration for job submission and results
apps/api/src/services/pythonClient.js - User files · Lightweight tracking for user-associated file and download records
apps/api/src/services/userFileService.js - Progress gateway · Live progress channel back to the browser
apps/api/src/websocket/progress.gateway.js
Worker service
Python media execution layer
- Worker entry · Worker process entrypoint for media jobs
apps/worker/src/main.py - Downloader · yt-dlp and ffmpeg orchestration for fetch, extract, and convert
apps/worker/src/downloader - Job model · Worker job state and payload structure
apps/worker/src/models/job.py
Shared contracts
Cross-app constants and integration metadata
Other components
- Browser · User entry point for search, playback, and downloads
Connections 23
- Browser → Public pages: loads · Browser opens the static entry pages
- Public pages → Feature modules: uses · Pages are powered by client-side feature modules
- Public pages → Styles: styles · Pages share the common stylesheet layer
- Feature modules → Server: REST · Frontend features call the API for search, playback, and downloads
- Feature modules → Progress gateway: subscribes · Frontend listens for live progress updates
- Server → Auth routes: mounts · Express server exposes auth endpoints
- Server → Search routes: mounts · Express server exposes search endpoints
- Server → Stream routes: mounts · Express server exposes stream endpoints
- Server → Metadata routes: mounts · Express server exposes metadata endpoints
- Server → Download routes: mounts · Express server exposes download endpoints
- Server → User routes: mounts · Express server exposes user endpoints
- Download routes → Queue: enqueues · Download requests are queued for async processing
- Queue → Python bridge: dispatches · Queued jobs are forwarded to the Python worker bridge
- Python bridge → Worker entry: invokes · Node service hands work to the Python runtime
- Worker entry → Downloader: runs · Worker executes download and conversion pipeline steps
- Downloader → Job model: updates · Pipeline reads and writes job state
- Downloader → Progress gateway: progress · Worker-originated progress is surfaced back through the API channel
- Progress gateway → Browser: pushes · Browser receives live job updates
- User routes → User files: persists · User-facing endpoints use lightweight file tracking
- Server → Routes: imports · API reuses shared route constants
- Feature modules → Events: imports · Frontend reuses shared event names
- Progress gateway → Events: publishes · Progress gateway uses shared realtime events
- Server → Roles: imports · API uses shared role definitions