Skip to content

Payload Data Model

Last refreshed: 2026-07-28

Registry

Payload config: src/payload.config.ts.

Anuva app collections are registered through AnuvaxCollections in src/collections/anuvax/index.ts. Upgrade-path orchestration state is not registered as Payload V1 collections; current API, CLI, and worker paths use the in-memory AnuvaRepository.

Core App Collections

  • workspaces: tenant boundary and ownership root.
  • users: Better Auth user document with workspace/default brand kit fields.
  • brand_kits: workspace brand assets and settings.
  • media_assets: workspace media library with source context, asset query metadata, and optional video sections.
  • voiceover_audio_assets: generated or stored voiceover audio.
  • rag_sources, rag_chunks, rag_ingestion_jobs: RAG ingestion and retrieval data.
  • video_use_cases, taxonomy_categories: generation taxonomy and catalog support data.
  • presentations, presentation_scenes, presentation_compilations: Presentation Video state, typed surface plans, and immutable Bento aggregate revisions.
  • presentation_editor_drafts: recoverable workspace/user/presentation-scoped Bento save proposals and conflict state.
  • video_generation_jobs, presentation_generation_jobs: render/generation queues.
  • ai_interactions: AI metering/audit records.
  • sets, set_variants, bots, bot_variants: content store and virtual studio options.
  • content_entitlements: workspace/user access grants.
  • subscription_plans, user_subscriptions, ai_model_conversion_rates, credit_wallets, credit_transactions, credit_packs, credit_pack_purchases: billing, coins, and entitlements.
  • zoho_billing_customers, zoho_webhook_events, billing_reconciliation_reports: Zoho integration state.
  • notifications, audit_logs: operational records.
erDiagram
  WORKSPACES ||--o{ USERS : owns
  WORKSPACES ||--o{ BRAND_KITS : owns
  WORKSPACES ||--o{ RAG_SOURCES : owns
  RAG_SOURCES ||--o{ RAG_CHUNKS : contains
  RAG_SOURCES ||--o{ RAG_INGESTION_JOBS : queues
  WORKSPACES ||--o{ PRESENTATIONS : owns
  PRESENTATIONS ||--o{ PRESENTATION_SCENES : contains
  PRESENTATIONS ||--o{ PRESENTATION_COMPILATIONS : snapshots
  PRESENTATIONS ||--o{ PRESENTATION_GENERATION_JOBS : queues
  PRESENTATION_SCENES ||--o{ MEDIA_ASSETS : attaches
  PRESENTATION_GENERATION_JOBS ||--o{ MEDIA_ASSETS : creates
  WORKSPACES ||--o{ CREDIT_WALLETS : owns
  CREDIT_WALLETS ||--o{ CREDIT_TRANSACTIONS : records

Prompt text for Presentation Video and RAG refinements is code-owned in Mastra workflow, agent, and tool helpers. Payload no longer registers an anuva_prompts collection.

PresentationConfig Revisions

presentation_scenes.surfacePlanJson stores the validated per-scene plan for Main, Companion, and Emphasis. Scene media and voiceover records retain lowercase byte checksums used by aggregate asset declarations.

presentation_compilations is append-only for PresentationConfig v2. Revision records store aggregate identity, integer version, revision and parent revision, content checksum, compatibility versions, asset manifest, validation result, public aggregate, and internal evidence. presentations.latestCompilation selects the last accepted revision.

The repository service queries revisions by both workspace and presentation. Optional expected revision/checksum fields provide optimistic conflict primitives. A mismatch leaves the current pointer unchanged.

Editor revision records add a unique revision key, scoped client request identity, authoring source, authenticated author, editor save trigger, and safe operation attribution. presentation_editor_drafts has one durable key per workspace/presentation/user and tracks active, conflicted, resolved, or discarded state. Migration 20260728_030000_add_bento_editor_authoring adds and backfills these fields.

Upgrade Runtime State

Upgrade runtime state for contracts, runs, artifacts, sources, quality metrics, conversation turns, and idempotency is held by src/lib/anuva/repository.ts.

flowchart LR
  api["Upgrade API callers"] --> service["Anuva orchestration service"]
  cli["scripts/anuva-cli.ts"] --> service
  worker["scripts/anuva-worker.ts"] --> service
  service --> repository["In-memory AnuvaRepository"]
  repository -. future gap .-> durable["Durable repository store"]
  payload["Payload app collections"] -. not used for V1 upgrade state .-> repository

A durable store for AnuvaRepository is deferred. Do not reintroduce Payload collections for this state without a new persistence design.

CMS Collections And Globals

  • blog: public blog content.
  • payload-uploads: public CMS upload collection.
  • private-uploads: private upload collection.
  • Globals: global-footer, global-terms, global-privacy.

Schema Ownership

Collection schema changes usually affect:

  • src/collections/**
  • src/payload.config.ts
  • src/payload-types.ts
  • src/app/(payload)/admin/importMap.js when admin components change
  • tests and docs that depend on collection shapes

Schema Change Checklist

  1. Update collection schema.
  2. Preserve workspace relationship and access-control behavior.
  3. Regenerate types with pnpm generate:types.
  4. Regenerate import map with pnpm generate:importmap if admin components changed.
  5. Run pnpm typecheck and targeted tests.
  6. Update docs/core or docs/state if behavior or map changed.