Introducing a new way to review your PRs.

Read the announcement

calicastle / cali.so

Personal website for Cali Castle

View on GitHub

21 documents · Updated Sep 21, 2026

docs / media-management-platform

Media management platform

The Media management platform is a private catalog for reusable images. It moves owner-selected Originals into protected storage, creates safe public Renditions, keeps descriptive data under owner control, and turns eligible assets into an ordered public Photo Selection. It also gives the owner tools to review, publish, archive, recover, and permanently purge media without exposing private source data.

System scope

Media catalog

The catalog is the system of record for a Media Asset: the protected Original, its public Renditions, safe descriptive metadata, and its catalog state. An Upload Intent reserves the expected transfer before bytes arrive, while a Transfer Job represents an incomplete or failed attempt; only a ready Media Asset enters the usable catalog.

The catalog keeps processing state separate from catalog state. Processing state explains whether an asset is verified, being processed, ready, or needs retry or repair. Catalog state explains whether a ready asset is active, archived, or being purged.

References: lib/…/CONTEXT.md• L5-14 lib/…/CONTEXT.md• L17-29 lib/…/CONTEXT.md• L85-100 db/…/0005_media_catalog.sql• L1-52

Media lifecycle

The lifecycle connects private transfer work to public display through durable checks. The platform verifies the Original, derives Renditions, records the asset and metadata, lets the owner prepare a Draft Photo Selection, and exposes only the published snapshot to visitors.

This diagram shows the main path from an owner transfer to public delivery and the separate paths for recovery and retention.

flowchart LR
    A[Owner starts transfer] --> B[Upload Intent and Transfer Job]
    B --> C[Verify Original]
    C --> D[Process image and store Renditions]
    D --> E[Ready Media Asset]
    E --> F[Owner review and metadata]
    F --> G[Draft Photo Selection]
    G --> H[Publish immutable snapshot]
    H --> I[Public photos page and homepage preview]
    B --> J[Recovery or cleanup]
    E --> K[Archive]
    K --> L[Restore or Purge]
    L --> M[Remove storage and catalog record]

References: lib/…/service.ts• L434-665 lib/…/service.ts• L98-199 lib/…/service.ts• L268-337 lib/…/service.ts• L165-290

Privacy boundary

The platform separates private source material from public delivery. The Original remains protected and is never sent to visitors. Public responses contain only selected Renditions plus approved Alt Text and allowlisted display data such as a location label or camera details.

Capture Location is a private coordinate value extracted from the Original. The platform stores it in an encrypted envelope and may use it to help the owner create a Location Label, but it never publishes the coordinates directly. Image processing also strips embedded metadata from every Rendition while leaving the Original unchanged.

References: lib/…/CONTEXT.md• L32-69 lib/…/capture-location.ts• L55-99 lib/…/image.ts• L194-299 lib/…/repository.ts• L197-224

Ingestion and storage

Protected media store

The media store holds both protected Originals and delivery-ready Renditions. Storage access is governed by a Bunny-backed contract that keeps Original and transfer-chunk paths blocked from public delivery while allowing the public CDN to serve Renditions.

Image processing accepts supported still-image formats and produces no-upscale profiles for common display sizes. The catalog records each rendition so later review, publication, reconciliation, and purge work from known storage references rather than from an untracked file.

Detailed transfer, processing, storage-provider, rendition, and location rules are documented in Media ingestion and storage.

References: lib/…/contract.ts• L93-124 lib/…/contract.ts• L183-262 lib/…/image.ts• L8-12 lib/…/image.ts• L241-299 db/…/0005_media_catalog.sql• L54-78

Recovery and reconciliation

Reconciliation is the repair path for work that stops between transfer, verification, processing, and metadata generation. It resumes stale work when the stored inputs remain usable, removes expired intents that never became assets, and retries missing Alt Text Suggestions without making image recovery depend on the suggestion service.

The owner can also resume an individual recoverable asset. This keeps an interrupted transfer visible as work to recover instead of presenting it as a false empty catalog item.

References: lib/…/service.ts• L21-24 lib/…/service.ts• L98-199 lib/…/service.ts• L202-237 lib/…/CONTEXT.md• L23-29

Publication model

Draft and published selections

A Photo Selection is an ordered list of Media Assets. The owner changes the Draft Photo Selection in the private admin area, then publishes it as an immutable snapshot. Publication copies the data needed for display, including Rendition references, order, Focal Points, approved Alt Text, and display metadata; it does not alter the underlying Media Assets.

The publish step accepts only active, ready assets with the required public Renditions and approved bilingual Alt Text. Revision checks prevent one stale admin view from replacing newer work. A successful publish changes the active snapshot and invalidates the public selection cache.

Detailed selection rules, publication revisions, withdrawal behavior, and public delivery are documented in Photo selection and publication.

References: lib/…/CONTEXT.md• L118-133 lib/…/repository.ts• L126-145 lib/…/repository.ts• L351-515 lib/…/service.ts• L127-187

Public photo experience

The public photos route and homepage preview read the active Published Photo Selection. They render the ordered Renditions with localized Alt Text and show optional location and camera details in the expanded photo view. They do not read Originals or draft catalog state.

This separation lets the owner prepare changes without changing what visitors see. A failed publication leaves the prior active snapshot in place, while a later cache refresh makes a successful publication visible.

References: app/…/photos-page.tsx• L11-30 components/published-photo-wall.tsx• L86-147 lib/…/repository.ts• L562-681 lib/…/server.ts• L71-111

Operational administration

Owner review

The protected Media admin area gives the owner one view of active assets, archived assets, transfer work, and the current Draft Photo Selection. Review actions edit display metadata, approve Alt Text, and move assets between active and archived catalog views.

Alt Text Suggestions provide a bilingual starting point from a public Rendition. The first suggestion can become approved Alt Text when no approved text exists; later suggestions do not replace text that the owner has approved. The owner remains responsible for the final wording.

References: app/…/page.tsx• L54-69 lib/…/server.ts• L44-73 lib/…/service.ts• L214-265 lib/…/service.ts• L123-206 lib/…/CONTEXT.md• L72-83

Archive and purge

Archive is a reversible catalog action. It hides an asset from normal library views and new selections, withdraws it from draft and published selections, and allows a short Undo window or a later Restore to return it to the library.

Purge is irreversible. It first withdraws the asset from publication, then tracks deletion of each Rendition, its CDN cache, and the Original before completing the catalog removal. The recorded progress makes a failed purge retryable without treating partially removed media as complete.

Detailed review, reconciliation, purge progress, and internal operations are documented in Media administration and retention.

References: lib/…/CONTEXT.md• L102-115 lib/…/service.ts• L268-337 lib/…/service.ts• L21-43 lib/…/service.ts• L196-290 db/…/0008_media_purge_progress.sql• L1-31

Change checklist

When these files or sections are changed, remember to consider these:

  • When rendition profiles or public image rules change, align image processing, rendition catalog checks, publication snapshots, and the public image reader.
  • When display metadata or Alt Text rules change, align owner review, selection eligibility, snapshot fields, and localized public rendering.
  • When archive or purge behavior changes, check draft withdrawal, active publication withdrawal, cache invalidation, and undo or retry state together.
  • When transfer states or recovery rules change, check Upload Intent completion, Transfer Job views, reconciliation thresholds, and cleanup of Original chunks.
  • When storage paths or CDN rules change, confirm that Originals and transfer chunks remain blocked and that published Rendition URLs still match the delivery contract.

Important failure modes

TriggerConsequenceGuard
The Original or a Rendition fails checksum or size verificationThe asset cannot safely become ready or public and may enter repair-required stateVerify stored bytes against the durable transfer or rendition manifest
A selected asset is not ready, active, fully rendered, or approved for Alt TextDraft save or publication rejects the ineligible assetRecheck eligibility inside the selection operation
An owner publishes from an outdated draft revisionNewer curation can be overwritten or produce an ambiguous publicationUse expected revision checks and retry from the current draft
A published asset is archived or purged without public cache invalidationVisitors can continue to see a withdrawn snapshot until the cache expiresInvalidate the published-selection cache after publication withdrawal
Storage deletion fails during purgeThe asset remains in an incomplete purge state and some files may remainRecord each deletion step and retry the leased purge job
A public storage rule exposes Original or transfer-chunk pathsPrivate source data becomes reachable through the CDNVerify the Bunny storage and edge-path contract before release

Key files

FileWhy to read it
lib/…/CONTEXT.mdDefines the media terms, product boundaries, and privacy rules used across the platform
lib/…/server.tsShows how storage, catalog, selection, review, recovery, Alt Text, and purge services form one owner-facing system
lib/…/service.tsShows the boundary between a transfer attempt and a ready Media Asset
lib/…/repository.tsShows how draft choices become an immutable public snapshot and public data shape
lib/…/service.tsShows owner metadata review and reversible catalog state changes
lib/…/service.tsShows durable, resumable retention cleanup across storage and the catalog
lib/…/service.tsShows recovery of interrupted transfer and processing work
app/…/page.tsxShows the private media library and transfer administration surface
app/…/page.tsxShows the private curation and publication surface
app/…/photos-page.tsxShows the public entry point for the active photo publication
components/published-photo-wall.tsxShows how published Renditions and approved display data reach visitors
lib/…/contract.tsDefines the storage and CDN boundary that protects private media