Knowledge Base updated: 2026-10-11
Invidious knowledge base
Invidious is a Crystal-based alternative web frontend and API server for YouTube. Its application layer registers browser and API routes, retrieves and normalizes upstream data, renders HTML or JSON, and maintains optional user state.
The main parts are the HTTP server and route handlers, YouTube integration and media helpers, account/library features, database-backed persistence and migrations, and deployment tooling. Runtime configuration controls upstream access, privacy behavior, tokens, proxying, and service operation.
Critical persistent state includes PostgreSQL-backed users, sessions, subscriptions, playlists, channels, videos, and migration metadata. Deployment state is supplied through configuration, container definitions, database initialization assets, and service manifests.
flowchart TD
Browser[Browser / API client] --> Server[Crystal HTTP server]
Server --> Middleware[Middleware and assets]
Server --> Routes[Web and API route families]
Routes --> Features[Feature handlers]
Features --> YouTube[YouTube integration]
Features --> Render[Templates and serializers]
YouTube --> Render
Features --> DB[(PostgreSQL)]
Features --> Jobs[Background jobs]
Jobs --> DB
Config[Runtime configuration] --> Server
Config --> YouTube
Deploy[Container and service deployment] --> Server
Deploy --> DB
Render --> Browser
Glossary
- Invidious — the Crystal application that provides web and API access to YouTube content.
- Instance — a deployed Invidious server with its own configuration, database, and operational policies.
- PO Token — a request token used by some YouTube access flows.
- Preferences — persisted or cookie-derived viewer settings that affect rendering and playback behavior.
- Shard — a Crystal dependency declared in shard.yml and resolved in shard.lock.
Codebase-wide invariants
- Route behavior is registered through the application’s route setup and delegated handlers; changes to
src/invidious/routes/**must preserve the corresponding route-family contract. - Persistent schema changes must be represented through migration and schema assets, not only model code; see
config/migrate/**andconfig/sql/**. - Runtime behavior is configuration-driven rather than hard-coded for a deployment; see
src/invidious/config.crand configuration templates underconfig/**. - API v1 consumers receive transformed response objects rather than raw internal domain objects; see
src/invidious/routes/api/v1/**andsrc/invidious/helpers/serialization/**. - Crystal dependencies are jointly defined by shard.yml and the locked resolution in shard.lock.
Routing table
src/invidious.cr,src/invidious/routes/**-> Application bootstrap and request routingsrc/invidious/helpers/**,src/invidious/middleware/**,assets/**-> HTTP middleware and static assetssrc/invidious/routes/**,src/invidious/routes/api/**-> Web and API route familiessrc/invidious/yt_backend/**,src/invidious/helpers/youtube/**-> YouTube backend integrationsrc/invidious/routes/watch.cr,src/invidious/routes/embed.cr,src/invidious/helpers/video/**-> Video watch and playbacksrc/invidious/routes/channels.cr,src/invidious/routes/feed.cr,src/invidious/helpers/channel/**-> Channel content and subscriptionssrc/invidious/routes/search.cr,src/invidious/routes/trending.cr,src/invidious/routes/mixes.cr-> Search, discovery, and mixessrc/invidious/routes/comments.cr,src/invidious/comments/**,src/invidious/helpers/comments/**-> Comments and community contentsrc/invidious/routes/login.cr,src/invidious/routes/preferences.cr,src/invidious/user/**-> Accounts, sessions, and preferencessrc/invidious/routes/data_control.cr,src/invidious/helpers/import_export/**-> User data import and exportsrc/invidious/routes/playlists.cr,src/invidious/playlists/**-> Playlists and personal librarysrc/invidious/database/**,config/migrate/**,config/sql/**-> Persistence and schema migrationssrc/invidious/jobs/**,src/invidious/routes/notifications.cr-> Background jobs and notificationssrc/invidious/views/**,src/invidious/locales/**,src/invidious/helpers/serialization/**-> Rendering, API serialization, and localizationsrc/invidious/routes/api/v1/**,src/invidious/helpers/serialization/**-> API v1 response serializationsrc/invidious/config.cr, config/config.example.yml,src/invidious/helpers/token_manager.cr-> Configuration and runtime security- shard.yml, shard.lock,
Makefile,spec/**,scripts/**-> Build, test, and development workflow docker/**, docker-compose.yml, docker-compose*.yml,kubernetes/**,config/sql/**-> Container, database, and service deployment