Open source CapCut alternative.
TypeScript
// Cut web mode: cloud-resident projects. Docs and metadata live here; media
// bytes live in R2 under keys recorded on CutMediaObject. Rows carry a plain
// userId (better-auth id) with no FK so the tables stay self-contained.
model CutProject {
id String @id @default(cuid())
userId String
name String
doc Json
folderId String?
// Optimistic concurrency for autosave: PUT sends the version it loaded and
// conflicts 409 instead of clobbering a newer save from another device.
version Int @default(1)
// The transport that saved the current version and that save's place in
// its sequence, so a save following its own unacknowledged one applies.
writer String?
writerSeq Int?
previewKey String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([userId, updatedAt])
}
// A read-only share of one cloud project. The row id doubles as the link
// token: deleting the row kills the link, and re-sharing mints a fresh URL
// without moving the project. For a public share the token is the only gate,
// so share.ts always supplies a cryptographically random id (the cuid()
// default is a fallback only, never the token an attacker would see).
model CutProjectShare {
id String @id @default(cuid()) // link token (random, set in share.ts)
projectId String @unique
userId String // owner; content queries and R2 keys resolve under this id
access String @default("restricted") // restricted | public
emails Json @default("[]") // lowercased invitee emails
features Json @default("{}") // { chat, media, genai, subtitles, details } booleans
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([userId])
}
// One requested project copy — a share copy into a viewer's account, or an
// owner duplicating their own project. Copies move whole projects' worth of
// R2 objects, so they never run in the request that asked: the request writes
// this row and publishes its id to a Cloudflare Queue, the queue's serial
// consumer executes it, and the client polls this row for the outcome.
model CutCopyJob {
id String @id @default(cuid())
kind String @default("share") // share | duplicate
shareId String? // share: access re-checked against this row at drain time
projectId String? // duplicate: the owner's source project
userId String // destination account (the viewer, or the owner)
state String @default("queued") // queued | running | done | error
newProjectId String?
error String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([userId, createdAt])
}
model CutFolder {
id String @id @default(cuid())
userId String
name String
scope String @default("project") // project | library | note
// The folder this one is filed in; null is the top level. Note folders nest.
parentId String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([userId, scope, parentId])
}
// One R2 object. Quota and orphan GC read from here: `pending` rows were
// presigned but never completed and are collectible after a grace period.
model CutMediaObject {
id String @id @default(cuid())
userId String
projectId String?
r2Key String @unique
fileName String
mime String @default("")
bytes BigInt @default(0)
kind String @default("media") // media | export | preview | library | overlay
uploadState String @default("pending") // pending | complete
// Seeded starter-project media never counts toward the storage quota: usage
// is not added when the row lands, so nothing is subtracted when it goes.
quotaExempt Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([userId, kind])
@@index([projectId, kind])
}
// One AI chat thread of a cloud project, stored as the same slimmed payload
// the client keeps in localStorage. The thread id is client-generated, so the
// key is (projectId, id); ownership is checked against CutProject on write.
model CutChatThread {
id String
userId String
projectId String
data Json
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@id([projectId, id])
@@index([userId, projectId, updatedAt])
}
model CutLibraryAsset {
id String @id @default(cuid())
userId String
mediaObjectId String
folderId String?
meta Json?
// Set when someone deleted this asset. The bytes leave at once; the row
// stays as a tombstone so the iOS app takes the same clip off the phone,
// and the nightly sweep drops it once every device has had time to see it.
deletedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([userId, createdAt])
@@index([userId, folderId, id])
}
model CutTemplate {
id String @id @default(cuid())
userId String
name String
doc Json
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([userId, createdAt])
}
model CutStorageUsage {
userId String @id
bytes BigInt @default(0)
updatedAt DateTime @updatedAt
}
// One synced note, shared by the iOS app and the desktop Notes tab. The id is
// client-generated (the phone's UUID). `updatedAt` is the last-writer-wins
// clock and comes from the writing client; a delete keeps the row as a
// tombstone so the other side drops its copy on the next merge.
model CutNote {
// Library placement is independent of the phone’s note folders.
libraryLocation Json?
id String @id
userId String
title String @default("")
body String @default("")
colorIndex Int @default(0)
// The CutFolder (scope "note") this note is filed in; null is the top level.
folderId String?
// CutNoteLabel ids this note carries. Labels ride the note's own
// last-writer-wins write; ids naming no label are dropped on read.
labelIds String[] @default([])
updatedAt DateTime
deletedAt DateTime?
createdAt DateTime @default(now())
@@index([userId, updatedAt])
}
// One note label, shared by the iOS app and the desktop Notes tab. Like note
// folders: the id is client-generated, one PUT creates and renames, and the
// listing is the truth — a label missing from it was deleted.
model CutNoteLabel {
id String @id
userId String
name String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([userId])
}
// Set once an account has been seen from the iOS app. The desktop shows its
// mobile surfaces (Camera Roll, Notes) only for accounts with this row.
model CutPhoneLink {
userId String @id
lastSeenAt DateTime @updatedAt
}
// Work the render worker executes: exports, hover preview proxies, URL
// imports. The client polls through the hosted API; only the worker claims
// rows.
model CutRenderJob {
id String @id @default(cuid())
userId String
projectId String?
kind String // export | preview | hls | import_url
state String @default("queued") // queued | running | done | error | canceled | dismissed
progress Float @default(0)
spec Json
outputKey String?
outName String?
result Json?
error String?
claimedAt DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([userId, createdAt])
@@index([state, createdAt])
}