155 lines
4.9 KiB
Plaintext
155 lines
4.9 KiB
Plaintext
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "sqlite"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model Project {
|
|
id String @id @default(uuid())
|
|
niche String
|
|
productType String
|
|
creativity String
|
|
aspectRatio String @default("3:4") // 1:1, 3:4, 4:5, 16:9, 9:16, etc.
|
|
useExactReference Boolean @default(false) // Strict Composition Mode
|
|
status String @default("draft") // draft, generated, finalized
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
sku String? // e.g. "WLR005"
|
|
config String? // JSON: { isStickerSet, setSize, basePrompt, characterCore }
|
|
|
|
assets Asset[]
|
|
seoData SeoData?
|
|
|
|
userId String?
|
|
user User? @relation(fields: [userId], references: [id])
|
|
}
|
|
|
|
model Asset {
|
|
id String @id @default(uuid())
|
|
projectId String
|
|
type String // master, mockup, reference, revision
|
|
path String // Local file path relative to /storage
|
|
prompt String? // The prompt that generated this asset
|
|
meta String? // JSON string for extra metadata (scenario name, etc.)
|
|
quality String @default("DRAFT") // DRAFT, MASTER, UPSCALED
|
|
createdAt DateTime @default(now())
|
|
|
|
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model SeoData {
|
|
id String @id @default(uuid())
|
|
projectId String @unique
|
|
title String
|
|
description String
|
|
keywords String // Stored as comma separated string or JSON
|
|
printingGuide String
|
|
suggestedPrice String
|
|
jsonLd String? // Structured Data (Schema.org)
|
|
attributes String? // JSON String: { primaryColor, occasion, etc. }
|
|
categoryPath String? // Suggested Category Path
|
|
|
|
project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model EtsyShop {
|
|
id String @id @default(uuid())
|
|
shopId String @unique
|
|
userId String
|
|
shopName String
|
|
accessToken String
|
|
refreshToken String
|
|
expiresAt BigInt
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model BrandProfile {
|
|
id String @id @default(uuid())
|
|
name String @unique
|
|
referencePaths String // JSON array of file paths relative to /storage
|
|
createdAt DateTime @default(now())
|
|
|
|
// Relations
|
|
userId String?
|
|
user User? @relation(fields: [userId], references: [id])
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(uuid())
|
|
email String @unique
|
|
passwordHash String? // Optional for Google Users
|
|
|
|
// OAuth Fields
|
|
googleId String? @unique
|
|
avatar String?
|
|
|
|
role String @default("USER") // USER, ADMIN
|
|
|
|
// SaaS / Beta Fields
|
|
credits Int @default(300) // Free credits (Generous tier)
|
|
plan String @default("FREE") // FREE, PRO
|
|
betaAccess Boolean @default(true) // Gated access
|
|
|
|
// New SaaS Fields (Phase 1)
|
|
apiKey String? // User's Personal Gemini API Key (Encrypted/Plain per policy)
|
|
etsyShopName String? // Manual Etsy Shop Name fallback
|
|
etsyShopLink String? // Manual Etsy Shop Link fallback
|
|
etsyShopLogo String? // Path to logo file
|
|
paymentMethod String? // Stripe Payment Method ID (Future)
|
|
subscriptionId String? // Stripe Subscription ID (Future)
|
|
|
|
skuSettings String? // JSON: { "Wall Art": {prefix: "WLR", next: 1} }
|
|
|
|
createdAt DateTime @default(now())
|
|
|
|
// Legal Compliance (Phase 6)
|
|
termsAcceptedAt DateTime? // User Agreement & IP Rights
|
|
kvkkAcceptedAt DateTime? // KVKK & Data Privacy
|
|
|
|
// Profit Analytics (Phase 7)
|
|
totalRevenue Float @default(0.0) // Total money paid by user (USD)
|
|
totalCost Float @default(0.0) // Total API cost incurred by user (USD, estimated)
|
|
|
|
projects Project[]
|
|
brandProfiles BrandProfile[]
|
|
etsyShops EtsyShop[]
|
|
usageLogs UsageLog[]
|
|
transactions Transaction[]
|
|
}
|
|
|
|
model UsageLog {
|
|
id String @id @default(uuid())
|
|
userId String
|
|
action String // GENERATE_MASTER, GENERATE_VARIANT, MOCKUP, PROMPT
|
|
cost Float // Estimated API cost in USD for this action
|
|
credits Int // Credits deducted
|
|
timestamp DateTime @default(now())
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model Transaction {
|
|
id String @id @default(uuid())
|
|
userId String
|
|
amount Float // USD Amount paid
|
|
credits Int // Credits added
|
|
type String // PURCHASE, ADMIN_GRANT, BONUS
|
|
createdAt DateTime @default(now())
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model SystemConfig {
|
|
key String @id @unique
|
|
value String
|
|
description String?
|
|
updatedAt DateTime @updatedAt
|
|
}
|