Let users upload videos, tag them with one or more entries, and watch them from a new Discovery Videos page. Backend: - Add Video and VideoEntry models and relations - Add video controller and /video routes - Add video thumbnail generation service (ffmpeg-static) - Add video upload storage location and config Frontend: - Add DiscoveryVideosPage with sidebar link and route - Add AddVideoDialog, VideoDropzone, EntryMultiSelect, VideoCard and VideoPlayerDialog components - Add discoveryVideos API client and useDiscoveryVideos hook - Add format helpers, video types and normalizers - Add skeleton for the page Docs: - Document the feature in docs-vault
5.5 KiB
title, tags, aliases
| title | tags | aliases | |||||||
|---|---|---|---|---|---|---|---|---|---|
| Discovery Videos |
|
|
Discovery Videos
Personal video vault page — upload local videos (recommendations, anything worth watching later), add a description, and link them to one or more Library entries.
Route: /discovery-videos (sidebar label: "Discover")
[!note] Naming This page is distinct from Pages#DiscoverPage, which is the TMDB browse page at
/discover/:category.
Overview
Responsibilities:
- Upload video files via drag & drop (up to 10 at once)
- Store a description per upload
- Link videos to one or many library entries (M:N)
- Display all saved videos in a lazy-loaded grid with inline playback
- Edit / delete videos (deletion also removes the file from disk)
Key Flows:
- Upload:
AddVideoDialog→ drop files → description + entry multi-select →POST /discovery-videos(multipart) → files stored todata/videos/with UUID names - Browse:
DiscoveryVideosPage→GET /discovery-videos?page=&limit=(24/page) → infinite scroll via IntersectionObserver - Play: clicking a card opens
VideoPlayerDialog— the video plays in the dialog; ↑/↓ (and ←/→ when the player isn't focused) navigate to the previous/next video. Streamed viaGET /discovery-videos/:id/streamwith HTTP Range support - Thumbnails (on demand): cards always request
GET /discovery-videos/:id/thumbnail; when no thumbnail exists yet, the endpoint generates it (ffmpeg frame at 1s) and serves it in the same response — nothing is generated eagerly or at startup
Entry linking UX: the picker in AddVideoDialog lists entries only once the user starts typing (debounced 250 ms) — the full library is never rendered at once.
Lazy Loading & Performance
| Layer | Mechanism |
|---|---|
| Route | React.lazy() + <Suspense> with DiscoveryVideosSkeleton |
| Data | Paginated API + useInfiniteQuery + IntersectionObserver sentinel (rootMargin: "400px") — only metadata travels, never video bytes |
| Thumbnails | <img loading="lazy"> requesting the thumbnail endpoint — generated on demand on first request (no eager/startup generation), deduped + limited to 2 concurrent ffmpeg jobs |
| Media | Video plays only inside the player dialog — nothing is fetched until the user opens it; res.sendFile → native Accept-Ranges/206 support → browser pulls only the segments it needs on seek/play |
Data Model
See Models#Video and Models#VideoEntry for field details, Database#Relationships for the relations.
videos (id, title, description, filename, original_name, mime_type, size, ...)
└── video_entries (video_id, entry_id) ── entries
API
| Method | Path | Description |
|---|---|---|
GET |
/discovery-videos?page=&limit= |
Paginated list (includes linked entries) |
POST |
/discovery-videos |
Multipart upload: videos[] (≤ 10), description, entryIds (JSON array) |
PUT |
/discovery-videos/:id |
Update title / description / entry links |
DELETE |
/discovery-videos/:id |
Delete record + files from disk |
GET |
/discovery-videos/:id/stream |
Video stream with HTTP Range support |
GET |
/discovery-videos/:id/thumbnail |
Thumbnail image — generated on demand when missing (served in the same response) |
Auth: stream URLs append ?token=<authToken> (the <video> tag cannot send Authorization headers). See API Reference.
Allowed extensions: mp4, webm, mov, m4v, mkv, avi. Note: mkv/avi may not play in browsers — mp4 (H.264) is recommended.
Important Files
Backend
backend/models/Video.js— video record modelbackend/models/VideoEntry.js— junction model (video ↔ entry)backend/controllers/videoController.js— list/upload/update/delete/stream/thumbnailbackend/routes/video.routes.js— mounted at/api/v1/discovery-videosbackend/services/mutlerStorageLocations.js—videosUploadmulter configbackend/services/videoThumbnailService.js— on-demand ffmpeg thumbnail generation (deduped, concurrency-limited)
Frontend
react_frontend/src/pages/DiscoveryVideosPage.tsx— page (grid + infinite scroll + player state)react_frontend/src/components/discovery-videos/VideoCard.tsx— thumbnail card with play overlayreact_frontend/src/components/discovery-videos/VideoPlayerDialog.tsx— playback dialog with ↑/↓ navigationreact_frontend/src/components/discovery-videos/AddVideoDialog.tsx— create/edit dialogreact_frontend/src/components/discovery-videos/VideoDropzone.tsx— native drag & dropreact_frontend/src/components/discovery-videos/EntryMultiSelect.tsx— library entry picker (reads from Stores)react_frontend/src/api/discoveryVideos.ts— API modulereact_frontend/src/hooks/useDiscoveryVideos.ts— query/mutations
Known Limitations
- Thumbnails are generated on demand (first request, ffmpeg frame at 1s) — the first load of a thumbnail takes a moment;
ffmpeg-staticmust ship in the packaged build (seebackend/pnpm-workspace.yamlbuild approval) - No transcoding — unsupported codecs will fail in the browser player
- No per-video watch state ("already watched") yet
- Multi-file uploads share one description + entry set (editable per video afterwards)
See Also
- Routing — route table
- Pages — page reference
- Models — Sequelize models
- Database — relationships
- API Reference — endpoint reference