Skip to main content

Technical Data Models

Internal data model specifications for the ViralSync platform. This section is useful for understanding how the API maps to underlying storage.


The Unified Job Model (jobs)

All long-running tasks share a single jobs table.

FieldTypeDescription
idstring (uuid)Unique job ID. Exposed as jobId in the API.
tenant_idstringWorkspace/brand identifier.
user_idstringID of the user who created the job.
kindenumagent | workflow | publish | render
typestringSpecific job subtype (e.g., render.movie, render.scene, render.assemble).
statusenumqueued | running | waiting | done | failed | cancelled
priorityenumlow | normal | high
parent_job_idstring | nullParent job ID for child jobs. null for top-level jobs.
providerstringExecuting runtime: modal, cloudrun, batch, local.
progressfloat0.0–1.0. Exposed as progress in the API.
current_phasestringCurrent phase label (e.g., rendering, assembling).
input_refstringR2 key or inline JSON for job input payload.
output_refstring | nullR2 key or URL for the job output. Becomes outputUrl in the API.
errortext | nullError message if status = "failed".
created_attimestampJob creation time (UTC).
updated_attimestampLast status update time (UTC).

Render-specific models

render_plans

The Render Plan is a compiled, immutable representation of the submitted movie JSON. Stored in Cloudflare R2 at path render-plans/{jobId}/plan.json.

{
"id": "rp_abc123",
"version": "1.0",
"project_id": "proj_abc123",
"parent_job_id": "job_a1b2c3d4e5f6",
"spec": {
"width": 1920,
"height": 1080,
"fps": 30,
"scenes": [
{
"id": "scene_1",
"duration": 5.0,
"bgColor": "#1a1a2e",
"layers": [ /* ... */ ]
}
]
},
"hash": "sha256:e3b0c44298fc1c149afb..."
}

The hash is a deterministic hash of the full spec content. Used for scene-level caching: if a scene's hash matches a previous render, the intermediate clip is reused.

render_scene_jobs (child job metadata)

Additional metadata attached to render.scene jobs:

FieldTypeDescription
scene_indexintegerZero-based position of the scene in the movie.
scene_idstringThe id field from the scene object in the movie JSON.
output_r2_keystringR2 storage path for the rendered scene intermediate: intermediates/{jobId}/scene_{index}.mp4.
duration_secondsfloatDuration of this scene in seconds.
cachedbooleanWhether this scene was served from cache (skipped rendering).

Render usage tracking (render_usage)

Tracks render minute consumption per user per billing period for quota enforcement.

FieldTypeDescription
user_idstringThe user account.
billing_periodstringFormat: YYYY-MM (e.g., "2026-04"). Resets on the 1st of each month.
render_minutes_consumedfloatTotal output video minutes consumed this period.
render_minutes_limitfloat | nullPlan limit. null = unlimited (Enterprise).
daily_render_minutesjsonbPer-day breakdown: { "2026-04-02": 2.5, "2026-04-03": 1.1 }. Used for Free-plan daily cap enforcement.
last_updated_attimestampLast write (set when a job completes).

How render minutes are recorded: When a render job transitions to done, the system reads mediaData.duration (seconds) from the job output, divides by 60, and adds to render_minutes_consumed for the current billing_period.


Subscription model (subscriptions)

Links users to their active plan.

FieldTypeDescription
user_idstringThe user account.
planenumfree | pro | business | enterprise
statusenumactive | trialing | past_due | cancelled
billing_intervalenummonthly | annual
current_period_starttimestampStart of current billing cycle.
current_period_endtimestampEnd of current billing cycle.
stripe_subscription_idstring | nullStripe subscription reference (null for free plan).
created_attimestampSubscription creation time.

Workflow models (job_executions)

Execution records for workflow automations.

FieldTypeDescription
workflow_idstringID of the associated workflow definition.
queue_namestringWorker queue: default, high-priority.
attemptsintegerNumber of execution attempts (incremented on retry).
payloadjsonbInput data passed to the workflow.
errortext | nullLast error message if the execution failed.
created_attimestampWhen this execution was queued.
completed_attimestamp | nullWhen this execution finished (success or failure).