// This is your Prisma schema file, // learn more about it in the docs: https://pris.ly/d/prisma-schema generator client { provider = "prisma-client-js" } datasource db { provider = "sqlite" url = env("DATABASE_URL") } // ============================================ // MODELOS BASE // ============================================ model User { id String @id @default(cuid()) email String @unique name String? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } model Project { id String @id @default(cuid()) name String description String? style String @default("default") status String @default("active") createdAt DateTime @default(now()) updatedAt DateTime @updatedAt repos Repo[] analyses Analysis[] contents Content[] } model Repo { id String @id @default(cuid()) url String name String status String @default("cloned") projectId String? project Project? @relation(fields: [projectId], references: [id]) analyses Analysis[] createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } model Analysis { id String @id @default(cuid()) type String result String summary String? repoId String? repo Repo? @relation(fields: [repoId], references: [id]) projectId String? project Project? @relation(fields: [projectId], references: [id]) createdAt DateTime @default(now()) } model AgentTask { id String @id @default(cuid()) type String status String @default("pending") input String output String? createdAt DateTime @default(now()) completedAt DateTime? } // ============================================ // MODELOS DE CONTENIDO MULTIMEDIA // ============================================ model Content { id String @id @default(cuid()) type String // "image", "video", "audio", "text", "reel", "story", "carousel" title String description String? prompt String optimizedPrompt String? filePath String? thumbnail String? platform String @default("general") status String @default("pending") metadata String? projectId String? project Project? @relation(fields: [projectId], references: [id]) characterId String? character Character? @relation(fields: [characterId], references: [id]) petId String? pet Pet? @relation(fields: [petId], references: [id]) censorFlags CensorFlag[] posts Post[] createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } model Character { id String @id @default(cuid()) name String description String? referenceImage String? traits String? contents Content[] pets Pet[] createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } // ============================================ // MODELOS DE CENSURA // ============================================ model CensorRule { id String @id @default(cuid()) platform String category String rule String severity String @default("medium") autoAction String @default("warn") isActive Boolean @default(true) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } model CensorFlag { id String @id @default(cuid()) contentId String content Content @relation(fields: [contentId], references: [id]) category String reason String severity String action String createdAt DateTime @default(now()) } // ============================================ // MODELOS DE MONETIZACIÓN // ============================================ model MonetizationPlatform { id String @id @default(cuid()) name String // OnlyFans, Patreon, Fansly, etc. type String // "subscription", "tips", "ppv", "mixed" url String? apiKey String? // Encriptado accountId String? accountName String? legalTerms String? // JSON con términos legales contentRules String? // JSON con reglas de contenido feePercentage Float? payoutSchedule String? isActive Boolean @default(true) isVerified Boolean @default(false) metadata String? posts Post[] earnings Earning[] subscribers Subscriber[] createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } model Subscriber { id String @id @default(cuid()) platformId String platform MonetizationPlatform @relation(fields: [platformId], references: [id]) externalId String? username String? tier String? // Nivel de suscripción status String @default("active") // active, expired, cancelled joinedAt DateTime? expiresAt DateTime? totalSpent Float @default(0) metadata String? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } model Earning { id String @id @default(cuid()) platformId String platform MonetizationPlatform @relation(fields: [platformId], references: [id]) type String // subscription, tip, ppv, referral amount Float currency String @default("USD") postId String? subscriberId String? status String @default("pending") // pending, processed, paid processedAt DateTime? metadata String? createdAt DateTime @default(now()) } // ============================================ // MODELOS DE PUBLICACIÓN // ============================================ model Post { id String @id @default(cuid()) title String? caption String? hashtags String? // JSON array type String // reel, photo, carousel, story, post status String @default("draft") // draft, scheduled, published, failed contentId String? content Content? @relation(fields: [contentId], references: [id]) platformId String? platform MonetizationPlatform? @relation(fields: [platformId], references: [id]) scheduledAt DateTime? publishedAt DateTime? externalPostId String? // ID en la plataforma externa postUrl String? // URL del post publicado engagementStats String? // JSON con likes, views, shares, etc. storyId String? story Story? @relation(fields: [storyId], references: [id]) metadata String? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } // ============================================ // MODELOS DE STORYTELLING // ============================================ model Story { id String @id @default(cuid()) title String description String? genre String? // romance, drama, comedy, thriller, etc. targetAudience String? // Demografía objetivo tone String? // romantic, funny, dramatic, mysterious structure String? // JSON con estructura narrativa characterIds String? // JSON array de IDs de personajes totalEpisodes Int @default(1) currentEpisode Int @default(1) status String @default("draft") // draft, active, completed, paused monetizationStrategy String? // JSON con estrategia de monetización posts Post[] episodes StoryEpisode[] analytics StoryAnalytics? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } model StoryEpisode { id String @id @default(cuid()) storyId String story Story @relation(fields: [storyId], references: [id]) episodeNum Int title String synopsis String? content String // Guión o descripción detallada hook String? // Gancho para la siguiente episodio cliffhanger String? status String @default("draft") scheduledAt DateTime? publishedAt DateTime? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } model StoryAnalytics { id String @id @default(cuid()) storyId String @unique story Story @relation(fields: [storyId], references: [id]) totalViews Int @default(0) totalEngagement Float @default(0) avgWatchTime Float? // En segundos completionRate Float? // Porcentaje revenue Float @default(0) subscriberGain Int @default(0) bestPerformingEpisode Int? metadata String? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } // ============================================ // MODELOS DE AUTOMATIZACIÓN // ============================================ model Automation { id String @id @default(cuid()) name String description String? type String // content_generation, posting, engagement, monetization trigger String // schedule, event, manual, webhook triggerConfig String? // JSON con configuración del trigger actions String // JSON array de acciones a ejecutar isActive Boolean @default(true) lastRunAt DateTime? nextRunAt DateTime? runCount Int @default(0) metadata String? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } model AutomationLog { id String @id @default(cuid()) automationId String? status String // success, failed, partial input String? output String? error String? duration Int? // Milisegundos createdAt DateTime @default(now()) } // ============================================ // MODELOS DE TENDENCIAS // ============================================ model Trend { id String @id @default(cuid()) platform String type String // hashtag, sound, challenge, topic name String description String? volume Int? growth Float? startDate DateTime? endDate DateTime? relatedTags String? // JSON array contentIdeas String? // JSON con ideas de contenido isActive Boolean @default(true) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } // ============================================ // MODELOS DE PLANTILLAS // ============================================ model PromptTemplate { id String @id @default(cuid()) name String category String template String variables String platform String @default("general") isActive Boolean @default(true) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } model ContentTemplate { id String @id @default(cuid()) name String type String // reel, carousel, story, post platform String structure String // JSON con estructura del contenido hooks String? // JSON array de ganchos ctas String? // JSON array de call-to-actions hashtags String? // JSON array de hashtags bestTimes String? // JSON con mejores horarios isActive Boolean @default(true) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } // ============================================ // MODELOS DE MASCOTAS/COMPAÑEROS // ============================================ model Pet { id String @id @default(cuid()) name String type String // dog, cat, bird, etc. breed String? description String? referenceImage String? traits String? // JSON con características personality String? // playful, calm, energetic color String? accessories String? // JSON array de accesorios characterId String? character Character? @relation(fields: [characterId], references: [id], onDelete: Cascade) contents Content[] isActive Boolean @default(true) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } // ============================================ // MODELOS DE INFLUENCERS IA DE REFERENCIA // ============================================ model AIInfluencer { id String @id @default(cuid()) name String handle String? platform String followers Int? engagement Float? niche String? style String? // JSON con estilo de contenido contentTypes String? // JSON array de tipos de contenido postingSchedule String? // JSON con horarios visualStyle String? // JSON con estilo visual monetizationType String? // JSON con tipo de monetización signatureElements String? // JSON con elementos distintivos petCompanion Boolean @default(false) petType String? analysis String? // JSON con análisis detallado lessons String? // JSON con lecciones aprendidas isActive Boolean @default(true) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } // ============================================ // MODELOS DE ESTRATEGIAS VIRALES // ============================================ model ViralStrategy { id String @id @default(cuid()) name String description String? platform String contentType String // reel, post, story, carousel hook String? // Gancho inicial structure String? // JSON con estructura viral elements String? // JSON con elementos clave estimatedReach Int? difficulty String @default("medium") timeframe String? // Tiempo para viralizar examples String? // JSON con ejemplos tags String? // JSON array de tags successRate Float? isActive Boolean @default(true) createdAt DateTime @default(now()) updatedAt DateTime @updatedAt }