Data Model Diagram
The ERD shows tables. This page shows the domain model the code works with, and the state machines that drive a title, a video asset and a membership through their lives.
Domain objects
Account (customers)
├── Subscription ── Plan (limits: max_streams, max_resolution, has_hdr, …)
│ └── Transactions
├── Devices ── Playback sessions
└── Profiles (1..max_profiles)
├── settings: kids, maturity_level, language, subtitle_style, autoplay, PIN
├── My List · Ratings · Reminders · Blocked titles
├── Playback progress (per title / episode)
└── Notifications
Title (movie | series)
├── Maturity rating · Genres · Moods · Credits (people)
├── Artwork (boxart, poster, backdrop, logo)
├── Trailers ── Video asset
├── Video asset (movie) ── Tracks (subtitles, captions, audio)
└── Seasons ── Episodes ── Video asset ── Tracks
Types used by the front end
| Type | File | Shape (abridged) |
|---|---|---|
Viewer |
src/lib/ott/catalog.ts |
customerId, profileId, maxLevel, isKids, country? |
TitleCard |
src/lib/ott/catalog.ts |
id, public_id, slug, title, type, year, maturity, runtime or seasons_count, quality, is_original, boxart, poster, backdrop, logo, synopsis, genres, moods, trailer_url, is_new, progress?, match? |
Row |
src/lib/ott/catalog.ts |
id, name (with {profile} or title filled in), type, shape (boxart/poster/top10), items |
TitleDetail |
src/lib/ott/catalog.ts |
card fields plus seasons with episodes and progress, credits, trailers, More Like This, list/rating/reminder state |
PlaybackInfo |
src/lib/ott/playback.ts |
title, episode, src, kind (hls/mp4), fallback, thumbnails, duration, start_at, markers, next episode, tracks, limits |
PlanLimits |
src/lib/ott/playback.ts |
max_streams, max_resolution, has_ads |
StreamingSettings |
src/lib/ott/settings.ts |
max_profiles, enforce_stream_limits, still_watching_after, autoplay defaults, hover_preview_delay_ms, next_episode_countdown_seconds, allowed_countries, default_maturity_level |
Title lifecycle
draft ──publish──▶ published ──archive──▶ archived
│ ▲
└──schedule──▶ scheduled
A published title is visible only when:
available_fromis empty or in the past (a future date shows it in Coming Soon with Remind Me, but it cannot be played),available_untilis empty or in the future,- its maturity level is within the profile's limit and it is not blocked for the profile,
- the viewer's country passes
countries_allow/countries_deny.
Publishing stamps published_at the first time.
Video asset lifecycle
upload / URL saved
│
▼
transcode_status = none ──"Convert to HLS"──▶ queued
(plays the MP4 or HLS URL) │ (a new MP4 upload also queues)
▼
processing ──(ffmpeg worker)──▶ ready
│ (plays capped HLS master,
▼ MP4 kept as fallback)
failed ──(retry ≤ 3 / re-run)──▶ queued
A job whose worker stops sending heartbeats for 10 minutes is reclaimed. Changing the asset's source URL resets the transcode state.
Membership lifecycle
checkout started
│
▼
pending ──capture verified──▶ active ──────cancel──────▶ cancelled
│ ▲ │
period ended, not paid │ │ renewal paid │ period ends
▼ │ ▼
on_hold ──30 days unpaid──▶ expired
- Streaming allowed in
activeandcancelled(untilexpires_at). - 7 days before
expires_atanactivemember gets a renewal reminder email. - Renewal extends from the old end date if it is still ahead, otherwise from the payment date.
- "Restart membership" turns a
cancelledsubscription that has not run out back intoactive. - Admins can extend (which also restores an on-hold membership) or cancel a subscription.
refundedis a recognised status (counted as churn in analytics), but there is no refund button; refunds are made in the gateway.
Playback session lifecycle
POST /playback/session ──▶ live (heartbeat every ~30 s)
│ 409 if live sessions ≥ plan.max_streams
├── PATCH {end:true} / sendBeacon session-end ──▶ ended
├── no heartbeat for 90 s ──▶ no longer counted as live
└── ended by "Sign out of all devices" or an admin ──▶ player receives 410 and stops
Progress and completion
- The player posts progress every ~10 s and on pause/exit.
- A title or episode is completed at 95 % or once playback passes
credits_start. - Continue Watching shows the most recent unfinished row per title; for a finished episode it offers the next one.
- "Remove from row" sets
hidden = trueand keeps the resume point.
© CreativeCape Solutions · creative-cape.com · support@creative-cape.com