diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000000000000000000000000000000000..03ae297d5b8bb6c7ceb9d4321f29f4fefe912c6e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +**/.git +**/.vs +**/bin +**/obj +**/output +**/.env +**/node_modules +*.md +.dockerignore +docker-compose*.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..e68ae0d0cc0d2b90f311a8ca8aef0e4ceac0bc48 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base +WORKDIR /app +EXPOSE 7860 + +RUN apt-get update && apt-get install -y ffmpeg python3 curl && curl -L https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp -o /usr/local/bin/yt-dlp && chmod a+rx /usr/local/bin/yt-dlp && rm -rf /var/lib/apt/lists/* + +FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build +WORKDIR /src +COPY src/ClipForge.Api/ClipForge.Api.csproj ClipForge.Api/ +COPY src/ClipForge.Core/ClipForge.Core.csproj ClipForge.Core/ +COPY src/ClipForge.Infrastructure/ClipForge.Infrastructure.csproj ClipForge.Infrastructure/ +COPY src/ClipForge.Workers/ClipForge.Workers.csproj ClipForge.Workers/ +COPY src/ClipForge.Contracts/ClipForge.Contracts.csproj ClipForge.Contracts/ +RUN dotnet restore ClipForge.Api/ClipForge.Api.csproj +COPY src/ . +RUN dotnet publish ClipForge.Api/ClipForge.Api.csproj -c Release -o /app/publish /p:UseAppHost=false + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +RUN mkdir -p /app/output/audio /app/output/videos /app/output/thumbnails /app/output/subtitles /app/output/temp +ENV ASPNETCORE_URLS=http://+:7860 +ENV ASPNETCORE_ENVIRONMENT=Production +ENTRYPOINT ["dotnet", "ClipForge.Api.dll"] diff --git a/src/ClipForge.Api/ClipForge.Api.csproj b/src/ClipForge.Api/ClipForge.Api.csproj new file mode 100644 index 0000000000000000000000000000000000000000..5d6882cd5e1e4ec4290cc5422bcd78bc2435ace2 --- /dev/null +++ b/src/ClipForge.Api/ClipForge.Api.csproj @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + net9.0 + enable + enable + + + diff --git a/src/ClipForge.Api/Endpoints/IdeaEndpoints.cs b/src/ClipForge.Api/Endpoints/IdeaEndpoints.cs new file mode 100644 index 0000000000000000000000000000000000000000..efcd27e8a0f2e350c0d4a3a5a6de41c48af6672a --- /dev/null +++ b/src/ClipForge.Api/Endpoints/IdeaEndpoints.cs @@ -0,0 +1,54 @@ +using ClipForge.Contracts.Requests; +using ClipForge.Contracts.Responses; +using ClipForge.Core.Interfaces; +using ClipForge.Core.Interfaces.Services; + +namespace ClipForge.Api.Endpoints; + +public static class IdeaEndpoints +{ + public static void MapIdeaEndpoints(this WebApplication app) + { + var group = app.MapGroup("/api/ideas").WithTags("Ideas"); + + group.MapPost("/generate", async (GenerateIdeaRequest request, IIdeaGenerationService service) => + { + if (request.Count > 1) + { + var ideas = await service.GenerateBatchIdeasAsync(request.Niche, request.Count, request.Platform); + return Results.Ok(ideas.Select(MapToResponse)); + } + + var idea = await service.GenerateIdeaAsync(request.Niche, request.Platform); + return Results.Ok(MapToResponse(idea)); + }); + + group.MapGet("/", async (IVideoIdeaRepository repository) => + { + var ideas = await repository.GetAllAsync(); + return Results.Ok(ideas.Select(MapToResponse)); + }); + + group.MapGet("/{id:guid}", async (Guid id, IVideoIdeaRepository repository) => + { + var idea = await repository.GetByIdAsync(id); + return idea is null ? Results.NotFound() : Results.Ok(MapToResponse(idea)); + }); + + group.MapGet("/status/{status}", async (string status, IVideoIdeaRepository repository) => + { + var ideas = await repository.GetByStatusAsync(status); + return Results.Ok(ideas.Select(MapToResponse)); + }); + + group.MapGet("/niche/{niche}", async (string niche, IVideoIdeaRepository repository) => + { + var ideas = await repository.GetByNicheAsync(niche); + return Results.Ok(ideas.Select(MapToResponse)); + }); + } + + private static VideoIdeaResponse MapToResponse(ClipForge.Core.Entities.VideoIdea idea) => new( + idea.Id, idea.Topic, idea.Title, idea.Hook, idea.TargetAudience, + idea.Platform, idea.Status, idea.Niche, idea.Tags, idea.CreatedAt); +} diff --git a/src/ClipForge.Api/Endpoints/PipelineEndpoints.cs b/src/ClipForge.Api/Endpoints/PipelineEndpoints.cs new file mode 100644 index 0000000000000000000000000000000000000000..cafa68cbb10008e24df8403b06e9c19a21263aea --- /dev/null +++ b/src/ClipForge.Api/Endpoints/PipelineEndpoints.cs @@ -0,0 +1,45 @@ +using ClipForge.Contracts.Requests; +using ClipForge.Core.Interfaces.Services; +using ClipForge.Workers.Jobs; +using Hangfire; + +namespace ClipForge.Api.Endpoints; + +public static class PipelineEndpoints +{ + public static void MapPipelineEndpoints(this WebApplication app) + { + var group = app.MapGroup("/api/pipeline").WithTags("Pipeline"); + + // Run full pipeline immediately (background job) + group.MapPost("/run", async (FullPipelineRequest request, ISchedulerService scheduler) => + { + await scheduler.ScheduleFullPipelineAsync(request.Niche, request.Platform); + return Results.Accepted(value: new { Message = "Pipeline scheduled", Niche = request.Niche, Platform = request.Platform }); + }); + + // Schedule recurring pipeline + group.MapPost("/schedule", async (SchedulePipelineRequest request, ISchedulerService scheduler) => + { + if (string.IsNullOrEmpty(request.CronExpression)) + return Results.BadRequest(new { Error = "CronExpression is required for scheduling" }); + + await scheduler.ScheduleRecurringGenerationAsync(request.Niche, request.CronExpression, request.Platform); + return Results.Ok(new { Message = "Recurring pipeline scheduled", Niche = request.Niche, Cron = request.CronExpression }); + }); + + // Cancel recurring job + group.MapDelete("/schedule/{jobId}", async (string jobId, ISchedulerService scheduler) => + { + await scheduler.CancelRecurringJobAsync(jobId); + return Results.Ok(new { Message = $"Job '{jobId}' cancelled" }); + }); + + // Run full pipeline synchronously (for testing) + group.MapPost("/run-sync", async (FullPipelineRequest request, FullPipelineJob job) => + { + await job.ExecuteAsync(request.Niche, request.Platform, request.VoiceId); + return Results.Ok(new { Message = "Pipeline completed", Niche = request.Niche }); + }); + } +} diff --git a/src/ClipForge.Api/Endpoints/ScriptEndpoints.cs b/src/ClipForge.Api/Endpoints/ScriptEndpoints.cs new file mode 100644 index 0000000000000000000000000000000000000000..3190f5c51a939eed5c5cfd8f64d8154a6e75f9cf --- /dev/null +++ b/src/ClipForge.Api/Endpoints/ScriptEndpoints.cs @@ -0,0 +1,42 @@ +using ClipForge.Contracts.Requests; +using ClipForge.Contracts.Responses; +using ClipForge.Core.Interfaces; +using ClipForge.Core.Interfaces.Services; + +namespace ClipForge.Api.Endpoints; + +public static class ScriptEndpoints +{ + public static void MapScriptEndpoints(this WebApplication app) + { + var group = app.MapGroup("/api/scripts").WithTags("Scripts"); + + group.MapPost("/generate", async (GenerateScriptRequest request, IScriptGenerationService service) => + { + var script = await service.GenerateScriptAsync(request.IdeaId); + return Results.Ok(MapToResponse(script)); + }); + + group.MapGet("/", async (IVideoScriptRepository repository) => + { + var scripts = await repository.GetAllAsync(); + return Results.Ok(scripts.Select(MapToResponse)); + }); + + group.MapGet("/{id:guid}", async (Guid id, IVideoScriptRepository repository) => + { + var script = await repository.GetByIdAsync(id); + return script is null ? Results.NotFound() : Results.Ok(MapToResponse(script)); + }); + + group.MapGet("/idea/{ideaId:guid}", async (Guid ideaId, IVideoScriptRepository repository) => + { + var script = await repository.GetByIdeaIdAsync(ideaId); + return script is null ? Results.NotFound() : Results.Ok(MapToResponse(script)); + }); + } + + private static VideoScriptResponse MapToResponse(ClipForge.Core.Entities.VideoScript script) => new( + script.Id, script.VideoIdeaId, script.ScriptText, script.Scenes, + script.EstimatedDurationSeconds, script.Tone, script.Language, script.CreatedAt); +} diff --git a/src/ClipForge.Api/Endpoints/VideoEndpoints.cs b/src/ClipForge.Api/Endpoints/VideoEndpoints.cs new file mode 100644 index 0000000000000000000000000000000000000000..7a223d0141a1fea08ffca740fa3bc1609e489d5c --- /dev/null +++ b/src/ClipForge.Api/Endpoints/VideoEndpoints.cs @@ -0,0 +1,60 @@ +using ClipForge.Contracts.Requests; +using ClipForge.Contracts.Responses; +using ClipForge.Core.Interfaces; +using ClipForge.Core.Interfaces.Services; +using Microsoft.AspNetCore.Hosting; + +namespace ClipForge.Api.Endpoints; + +public static class VideoEndpoints +{ + public static void MapVideoEndpoints(this WebApplication app) + { + var group = app.MapGroup("/api/videos").WithTags("Videos"); + + group.MapPost("/assemble", async (AssembleVideoRequest request, IVideoAssemblyService service) => + { + var video = await service.AssembleVideoAsync(request.ScriptId); + return Results.Ok(MapToResponse(video)); + }); + + group.MapGet("/", async (IVideoAssetRepository repository) => + { + var videos = await repository.GetAllAsync(); + return Results.Ok(videos.Select(MapToResponse)); + }); + + group.MapGet("/{id:guid}", async (Guid id, IVideoAssetRepository repository) => + { + var video = await repository.GetByIdAsync(id); + return video is null ? Results.NotFound() : Results.Ok(MapToResponse(video)); + }); + + group.MapGet("/status/{status}", async (string status, IVideoAssetRepository repository) => + { + var videos = await repository.GetByStatusAsync(status); + return Results.Ok(videos.Select(MapToResponse)); + }); + + group.MapGet("/{id:guid}/download", async (Guid id, IVideoAssetRepository repository, IWebHostEnvironment env) => + { + var video = await repository.GetByIdAsync(id); + if (video is null) return Results.NotFound(); + + // Resolve path relative to content root + var filePath = video.FilePath; + if (filePath.StartsWith("./")) + filePath = Path.Combine(env.ContentRootPath, filePath[2..]); + + filePath = Path.GetFullPath(filePath); + if (!File.Exists(filePath)) return Results.NotFound($"File not found: {filePath}"); + + return Results.File(filePath, "video/mp4", $"clipforge_{id}.mp4"); + }); + } + + private static VideoAssetResponse MapToResponse(ClipForge.Core.Entities.VideoAsset video) => new( + video.Id, video.VideoScriptId, video.FilePath, video.ThumbnailPath, + video.Width, video.Height, video.DurationSeconds, video.FileSizeBytes, + video.Format, video.Status, video.CreatedAt); +} diff --git a/src/ClipForge.Api/Endpoints/VoiceEndpoints.cs b/src/ClipForge.Api/Endpoints/VoiceEndpoints.cs new file mode 100644 index 0000000000000000000000000000000000000000..7fb1d4d08efe134396d4a8906aa605ec8752b3a7 --- /dev/null +++ b/src/ClipForge.Api/Endpoints/VoiceEndpoints.cs @@ -0,0 +1,28 @@ +using ClipForge.Contracts.Requests; +using ClipForge.Core.Interfaces.Services; + +namespace ClipForge.Api.Endpoints; + +public static class VoiceEndpoints +{ + public static void MapVoiceEndpoints(this WebApplication app) + { + var group = app.MapGroup("/api/voice").WithTags("Voice"); + + group.MapPost("/generate", async (GenerateVoiceRequest request, IVoiceGenerationService service) => + { + var voice = await service.GenerateVoiceAsync(request.ScriptId, request.VoiceId); + return Results.Ok(new + { + voice.Id, + voice.VideoScriptId, + voice.FilePath, + voice.VoiceProvider, + voice.VoiceId, + voice.DurationSeconds, + voice.FileSizeBytes, + voice.CreatedAt + }); + }); + } +} diff --git a/src/ClipForge.Api/Program.cs b/src/ClipForge.Api/Program.cs new file mode 100644 index 0000000000000000000000000000000000000000..b81a11ac6ca76ef1cf85f398d140735a39dc9918 --- /dev/null +++ b/src/ClipForge.Api/Program.cs @@ -0,0 +1,68 @@ +using ClipForge.Api.Endpoints; +using ClipForge.Infrastructure; +using ClipForge.Infrastructure.Data; +using ClipForge.Workers.Jobs; +using Hangfire; +using Hangfire.PostgreSql; +using Microsoft.EntityFrameworkCore; + +var builder = WebApplication.CreateBuilder(args); + +// Add Infrastructure (DI, DbContext, Services) +builder.Services.AddInfrastructure(builder.Configuration); + +// Workers +builder.Services.AddScoped(); + +// Hangfire +builder.Services.AddHangfire(config => + config.UsePostgreSqlStorage(options => + options.UseNpgsqlConnection(builder.Configuration.GetConnectionString("DefaultConnection")))); +builder.Services.AddHangfireServer(); + +var app = builder.Build(); + +// Apply migrations on startup +using (var scope = app.Services.CreateScope()) +{ + var db = scope.ServiceProvider.GetRequiredService(); + await db.Database.MigrateAsync(); +} + +// Hangfire Dashboard +app.UseHangfireDashboard("/hangfire"); + +// Serve static files (frontend) +app.UseDefaultFiles(); +app.UseStaticFiles(); + +// Map API endpoints +app.MapIdeaEndpoints(); +app.MapScriptEndpoints(); +app.MapVoiceEndpoints(); +app.MapVideoEndpoints(); +app.MapPipelineEndpoints(); + +app.MapGet("/api/status", () => Results.Ok(new +{ + Name = "ClipForge API", + Version = "1.0.0", + Status = "Running" +})); + +// Temporary cleanup endpoint +app.MapDelete("/api/admin/cleanup/{keepVideoId}", async (Guid keepVideoId, ClipForge.Infrastructure.Data.AppDbContext db) => +{ + var sql = $@" + DELETE FROM ""PublishJobs"" WHERE ""VideoAssetId"" != '{keepVideoId}'; + DELETE FROM ""CaptionAssets"" WHERE ""VideoAssetId"" != '{keepVideoId}'; + DELETE FROM ""VideoAssets"" WHERE ""Id"" != '{keepVideoId}'; + DELETE FROM ""VoiceAssets"" WHERE ""VideoScriptId"" NOT IN (SELECT ""VideoScriptId"" FROM ""VideoAssets"" WHERE ""Id"" = '{keepVideoId}'); + DELETE FROM ""VideoScripts"" WHERE ""Id"" NOT IN (SELECT ""VideoScriptId"" FROM ""VideoAssets"" WHERE ""Id"" = '{keepVideoId}'); + DELETE FROM ""VideoIdeas"" WHERE ""Id"" NOT IN (SELECT ""VideoIdeaId"" FROM ""VideoScripts"" WHERE ""Id"" IN (SELECT ""VideoScriptId"" FROM ""VideoAssets"" WHERE ""Id"" = '{keepVideoId}')); + "; + var rows = await db.Database.ExecuteSqlRawAsync(sql); + return Results.Ok(new { Message = "Cleanup done", RowsDeleted = rows }); +}); + +app.Run(); diff --git a/src/ClipForge.Api/Properties/launchSettings.json b/src/ClipForge.Api/Properties/launchSettings.json new file mode 100644 index 0000000000000000000000000000000000000000..897e073d58bc7165053cbf16264da0a9b3b69448 --- /dev/null +++ b/src/ClipForge.Api/Properties/launchSettings.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "http://0.0.0.0:5011", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": false, + "applicationUrl": "https://localhost:7024;http://0.0.0.0:5011", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/ClipForge.Api/appsettings.Production.json b/src/ClipForge.Api/appsettings.Production.json new file mode 100644 index 0000000000000000000000000000000000000000..564a7939ad49ea0d1bdb7ce1433e425b3ea715b4 --- /dev/null +++ b/src/ClipForge.Api/appsettings.Production.json @@ -0,0 +1,25 @@ +{ + "Logging": { "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning" } }, + "AllowedHosts": "*", + "ConnectionStrings": { + "DefaultConnection": "Host=ep-restless-surf-ap1x9yyn-pooler.c-7.us-east-1.aws.neon.tech;Database=neondb;Username=neondb_owner;Password=npg_pT3JVYi2MOAj;SSL Mode=Require;Trust Server Certificate=true" + }, + "OpenAi": { + "ApiKey": "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", + "Model": "google/gemini-2.0-flash-001", + "TtsModel": "", + "BaseUrl": "https://openrouter.ai/api/v1" + }, + "Pexels": { + "ApiKey": "Q5nTHwnhC5qKv1J3iEkbFUbp3it4RjHIUfuGZ75A5f53kSq7eHoZYSgB", + "BaseUrl": "https://api.pexels.com" + }, + "Storage": { + "BasePath": "/app/output", + "AudioFolder": "audio", + "VideoFolder": "videos", + "ThumbnailFolder": "thumbnails", + "SubtitleFolder": "subtitles", + "TempFolder": "temp" + } +} diff --git a/src/ClipForge.Api/appsettings.json b/src/ClipForge.Api/appsettings.json new file mode 100644 index 0000000000000000000000000000000000000000..564a7939ad49ea0d1bdb7ce1433e425b3ea715b4 --- /dev/null +++ b/src/ClipForge.Api/appsettings.json @@ -0,0 +1,25 @@ +{ + "Logging": { "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning" } }, + "AllowedHosts": "*", + "ConnectionStrings": { + "DefaultConnection": "Host=ep-restless-surf-ap1x9yyn-pooler.c-7.us-east-1.aws.neon.tech;Database=neondb;Username=neondb_owner;Password=npg_pT3JVYi2MOAj;SSL Mode=Require;Trust Server Certificate=true" + }, + "OpenAi": { + "ApiKey": "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", + "Model": "google/gemini-2.0-flash-001", + "TtsModel": "", + "BaseUrl": "https://openrouter.ai/api/v1" + }, + "Pexels": { + "ApiKey": "Q5nTHwnhC5qKv1J3iEkbFUbp3it4RjHIUfuGZ75A5f53kSq7eHoZYSgB", + "BaseUrl": "https://api.pexels.com" + }, + "Storage": { + "BasePath": "/app/output", + "AudioFolder": "audio", + "VideoFolder": "videos", + "ThumbnailFolder": "thumbnails", + "SubtitleFolder": "subtitles", + "TempFolder": "temp" + } +} diff --git a/src/ClipForge.Api/wwwroot/index.html b/src/ClipForge.Api/wwwroot/index.html new file mode 100644 index 0000000000000000000000000000000000000000..9e7440d594234586dc419738c8a9fc285bda30bd --- /dev/null +++ b/src/ClipForge.Api/wwwroot/index.html @@ -0,0 +1,216 @@ + + + + + + ClipForge - Gerador de Vídeos + + + + + 🎬 ClipForge + Gerador automático de vídeos virais com IA + + + + Tema do vídeo + + + + Plataforma + + TikTok + YouTube Shorts + Kwai + + + + Voz + + Francisca (feminina) + Antonio (masculina) + Thalita (jovem) + + + 🚀 Gerar Vídeo + + + + + 📁 Vídeos Gerados + Carregando... + + + + + + diff --git a/src/ClipForge.Contracts/ClipForge.Contracts.csproj b/src/ClipForge.Contracts/ClipForge.Contracts.csproj new file mode 100644 index 0000000000000000000000000000000000000000..125f4c93bc98c2ee5a8520de3a0017a6c86f5047 --- /dev/null +++ b/src/ClipForge.Contracts/ClipForge.Contracts.csproj @@ -0,0 +1,9 @@ + + + + net9.0 + enable + enable + + + diff --git a/src/ClipForge.Contracts/Requests/AssembleVideoRequest.cs b/src/ClipForge.Contracts/Requests/AssembleVideoRequest.cs new file mode 100644 index 0000000000000000000000000000000000000000..97b6a887dd68e9b9a7f6da06db2366c68e03a24d --- /dev/null +++ b/src/ClipForge.Contracts/Requests/AssembleVideoRequest.cs @@ -0,0 +1,5 @@ +namespace ClipForge.Contracts.Requests; + +public record AssembleVideoRequest( + Guid ScriptId +); diff --git a/src/ClipForge.Contracts/Requests/FullPipelineRequest.cs b/src/ClipForge.Contracts/Requests/FullPipelineRequest.cs new file mode 100644 index 0000000000000000000000000000000000000000..4bf20726ebda117bb051883d02e1e202270d186e --- /dev/null +++ b/src/ClipForge.Contracts/Requests/FullPipelineRequest.cs @@ -0,0 +1,9 @@ +namespace ClipForge.Contracts.Requests; + +public record FullPipelineRequest( + string Niche, + string Platform = "tiktok", + string Tone = "engaging", + string Language = "pt-BR", + string VoiceId = "alloy" +); diff --git a/src/ClipForge.Contracts/Requests/GenerateIdeaRequest.cs b/src/ClipForge.Contracts/Requests/GenerateIdeaRequest.cs new file mode 100644 index 0000000000000000000000000000000000000000..313b7f4ac6a2a573c5e33544c592509884ff3386 --- /dev/null +++ b/src/ClipForge.Contracts/Requests/GenerateIdeaRequest.cs @@ -0,0 +1,7 @@ +namespace ClipForge.Contracts.Requests; + +public record GenerateIdeaRequest( + string Niche, + string Platform = "tiktok", + int Count = 1 +); diff --git a/src/ClipForge.Contracts/Requests/GenerateScriptRequest.cs b/src/ClipForge.Contracts/Requests/GenerateScriptRequest.cs new file mode 100644 index 0000000000000000000000000000000000000000..3788dfda6a9083b38f7e1d996da0ccdc38145b8a --- /dev/null +++ b/src/ClipForge.Contracts/Requests/GenerateScriptRequest.cs @@ -0,0 +1,7 @@ +namespace ClipForge.Contracts.Requests; + +public record GenerateScriptRequest( + Guid IdeaId, + string Tone = "engaging", + string Language = "pt-BR" +); diff --git a/src/ClipForge.Contracts/Requests/GenerateVoiceRequest.cs b/src/ClipForge.Contracts/Requests/GenerateVoiceRequest.cs new file mode 100644 index 0000000000000000000000000000000000000000..4300d0c7cbac67fa521117d043a20c15c1068043 --- /dev/null +++ b/src/ClipForge.Contracts/Requests/GenerateVoiceRequest.cs @@ -0,0 +1,6 @@ +namespace ClipForge.Contracts.Requests; + +public record GenerateVoiceRequest( + Guid ScriptId, + string VoiceId = "alloy" +); diff --git a/src/ClipForge.Contracts/Requests/SchedulePipelineRequest.cs b/src/ClipForge.Contracts/Requests/SchedulePipelineRequest.cs new file mode 100644 index 0000000000000000000000000000000000000000..7f5f42c29346b3d604e82ccea4bd9eaa4c9d2b98 --- /dev/null +++ b/src/ClipForge.Contracts/Requests/SchedulePipelineRequest.cs @@ -0,0 +1,7 @@ +namespace ClipForge.Contracts.Requests; + +public record SchedulePipelineRequest( + string Niche, + string Platform = "tiktok", + string? CronExpression = null +); diff --git a/src/ClipForge.Contracts/Responses/PipelineStatusResponse.cs b/src/ClipForge.Contracts/Responses/PipelineStatusResponse.cs new file mode 100644 index 0000000000000000000000000000000000000000..af84e73954e2bfb3fb645a99b8ff89c3bf7c0bba --- /dev/null +++ b/src/ClipForge.Contracts/Responses/PipelineStatusResponse.cs @@ -0,0 +1,10 @@ +namespace ClipForge.Contracts.Responses; + +public record PipelineStatusResponse( + Guid IdeaId, + Guid? ScriptId, + Guid? VideoAssetId, + string CurrentStep, + string Status, + string? ErrorMessage +); diff --git a/src/ClipForge.Contracts/Responses/VideoAssetResponse.cs b/src/ClipForge.Contracts/Responses/VideoAssetResponse.cs new file mode 100644 index 0000000000000000000000000000000000000000..29d144d84409927ad36cca4bf6af1134095e268b --- /dev/null +++ b/src/ClipForge.Contracts/Responses/VideoAssetResponse.cs @@ -0,0 +1,15 @@ +namespace ClipForge.Contracts.Responses; + +public record VideoAssetResponse( + Guid Id, + Guid VideoScriptId, + string FilePath, + string ThumbnailPath, + int Width, + int Height, + double DurationSeconds, + long FileSizeBytes, + string Format, + string Status, + DateTime CreatedAt +); diff --git a/src/ClipForge.Contracts/Responses/VideoIdeaResponse.cs b/src/ClipForge.Contracts/Responses/VideoIdeaResponse.cs new file mode 100644 index 0000000000000000000000000000000000000000..1de4b3d77d863c7403f5d739c9211ad0807d52ae --- /dev/null +++ b/src/ClipForge.Contracts/Responses/VideoIdeaResponse.cs @@ -0,0 +1,14 @@ +namespace ClipForge.Contracts.Responses; + +public record VideoIdeaResponse( + Guid Id, + string Topic, + string Title, + string Hook, + string TargetAudience, + string Platform, + string Status, + string? Niche, + string? Tags, + DateTime CreatedAt +); diff --git a/src/ClipForge.Contracts/Responses/VideoScriptResponse.cs b/src/ClipForge.Contracts/Responses/VideoScriptResponse.cs new file mode 100644 index 0000000000000000000000000000000000000000..8970541a59d7461b34f358ea2764a67e8ee26f34 --- /dev/null +++ b/src/ClipForge.Contracts/Responses/VideoScriptResponse.cs @@ -0,0 +1,12 @@ +namespace ClipForge.Contracts.Responses; + +public record VideoScriptResponse( + Guid Id, + Guid VideoIdeaId, + string ScriptText, + string Scenes, + int EstimatedDurationSeconds, + string Tone, + string Language, + DateTime CreatedAt +); diff --git a/src/ClipForge.Core/ClipForge.Core.csproj b/src/ClipForge.Core/ClipForge.Core.csproj new file mode 100644 index 0000000000000000000000000000000000000000..125f4c93bc98c2ee5a8520de3a0017a6c86f5047 --- /dev/null +++ b/src/ClipForge.Core/ClipForge.Core.csproj @@ -0,0 +1,9 @@ + + + + net9.0 + enable + enable + + + diff --git a/src/ClipForge.Core/Entities/BaseEntity.cs b/src/ClipForge.Core/Entities/BaseEntity.cs new file mode 100644 index 0000000000000000000000000000000000000000..e4c02b341ec143169077e5023f0b26f77dc3abc3 --- /dev/null +++ b/src/ClipForge.Core/Entities/BaseEntity.cs @@ -0,0 +1,8 @@ +namespace ClipForge.Core.Entities; + +public abstract class BaseEntity +{ + public Guid Id { get; set; } = Guid.NewGuid(); + public DateTime CreatedAt { get; set; } = DateTime.UtcNow; + public DateTime? UpdatedAt { get; set; } +} diff --git a/src/ClipForge.Core/Entities/CaptionAsset.cs b/src/ClipForge.Core/Entities/CaptionAsset.cs new file mode 100644 index 0000000000000000000000000000000000000000..b0eae5dac184db01463612cf8418928929dbbea0 --- /dev/null +++ b/src/ClipForge.Core/Entities/CaptionAsset.cs @@ -0,0 +1,16 @@ +namespace ClipForge.Core.Entities; + +public class CaptionAsset : BaseEntity +{ + public Guid VideoAssetId { get; set; } + public string SrtFilePath { get; set; } = string.Empty; + public string CaptionStyle { get; set; } = "dynamic"; // dynamic, static, karaoke + public string FontFamily { get; set; } = "Montserrat"; + public int FontSize { get; set; } = 48; + public string FontColor { get; set; } = "#FFFFFF"; + public string StrokeColor { get; set; } = "#000000"; + public int StrokeWidth { get; set; } = 2; + + // Navigation + public VideoAsset? VideoAsset { get; set; } +} diff --git a/src/ClipForge.Core/Entities/PublishJob.cs b/src/ClipForge.Core/Entities/PublishJob.cs new file mode 100644 index 0000000000000000000000000000000000000000..84ea2e8ae634859de321a5bf2f1d3215faccfbe7 --- /dev/null +++ b/src/ClipForge.Core/Entities/PublishJob.cs @@ -0,0 +1,19 @@ +namespace ClipForge.Core.Entities; + +public class PublishJob : BaseEntity +{ + public Guid VideoAssetId { get; set; } + public Guid? SocialAccountId { get; set; } + public string Platform { get; set; } = "tiktok"; // tiktok, youtube_shorts, kwai + public string Status { get; set; } = "pending"; // pending, scheduled, publishing, published, failed + public DateTime? ScheduledAt { get; set; } + public DateTime? PublishedAt { get; set; } + public string? ExternalId { get; set; } + public string? ErrorMessage { get; set; } + public string? Caption { get; set; } + public string? Hashtags { get; set; } + + // Navigation + public VideoAsset? VideoAsset { get; set; } + public SocialAccount? SocialAccount { get; set; } +} diff --git a/src/ClipForge.Core/Entities/SocialAccount.cs b/src/ClipForge.Core/Entities/SocialAccount.cs new file mode 100644 index 0000000000000000000000000000000000000000..2c875d3ca4df7f08c2aee48873f7c006d2010ce7 --- /dev/null +++ b/src/ClipForge.Core/Entities/SocialAccount.cs @@ -0,0 +1,14 @@ +namespace ClipForge.Core.Entities; + +public class SocialAccount : BaseEntity +{ + public string Platform { get; set; } = "tiktok"; + public string AccountName { get; set; } = string.Empty; + public string? AccessToken { get; set; } + public string? RefreshToken { get; set; } + public DateTime? TokenExpiresAt { get; set; } + public bool IsActive { get; set; } = true; + + // Navigation + public List PublishJobs { get; set; } = []; +} diff --git a/src/ClipForge.Core/Entities/VideoAsset.cs b/src/ClipForge.Core/Entities/VideoAsset.cs new file mode 100644 index 0000000000000000000000000000000000000000..79ec72ccb08e62f910349e66b639bb17bb4e8def --- /dev/null +++ b/src/ClipForge.Core/Entities/VideoAsset.cs @@ -0,0 +1,19 @@ +namespace ClipForge.Core.Entities; + +public class VideoAsset : BaseEntity +{ + public Guid VideoScriptId { get; set; } + public string FilePath { get; set; } = string.Empty; + public string ThumbnailPath { get; set; } = string.Empty; + public int Width { get; set; } = 1080; + public int Height { get; set; } = 1920; + public double DurationSeconds { get; set; } + public long FileSizeBytes { get; set; } + public string Format { get; set; } = "mp4"; + public string Status { get; set; } = "processing"; // processing, completed, failed + + // Navigation + public VideoScript? VideoScript { get; set; } + public CaptionAsset? CaptionAsset { get; set; } + public List PublishJobs { get; set; } = []; +} diff --git a/src/ClipForge.Core/Entities/VideoIdea.cs b/src/ClipForge.Core/Entities/VideoIdea.cs new file mode 100644 index 0000000000000000000000000000000000000000..8fba9fcf4369d5258ce2b113a2218fd04782494f --- /dev/null +++ b/src/ClipForge.Core/Entities/VideoIdea.cs @@ -0,0 +1,16 @@ +namespace ClipForge.Core.Entities; + +public class VideoIdea : BaseEntity +{ + public string Topic { get; set; } = string.Empty; + public string Title { get; set; } = string.Empty; + public string Hook { get; set; } = string.Empty; + public string TargetAudience { get; set; } = string.Empty; + public string Platform { get; set; } = "tiktok"; // tiktok, youtube_shorts, kwai + public string Status { get; set; } = "pending"; // pending, scripted, completed, failed + public string? Niche { get; set; } + public string? Tags { get; set; } + + // Navigation + public VideoScript? Script { get; set; } +} diff --git a/src/ClipForge.Core/Entities/VideoScript.cs b/src/ClipForge.Core/Entities/VideoScript.cs new file mode 100644 index 0000000000000000000000000000000000000000..63d878780a6d650357b8de3156675962d0a822af --- /dev/null +++ b/src/ClipForge.Core/Entities/VideoScript.cs @@ -0,0 +1,16 @@ +namespace ClipForge.Core.Entities; + +public class VideoScript : BaseEntity +{ + public Guid VideoIdeaId { get; set; } + public string ScriptText { get; set; } = string.Empty; + public string Scenes { get; set; } = string.Empty; // JSON array of scene descriptions + public int EstimatedDurationSeconds { get; set; } + public string Tone { get; set; } = "engaging"; // engaging, funny, dramatic, informative + public string Language { get; set; } = "pt-BR"; + + // Navigation + public VideoIdea? VideoIdea { get; set; } + public VoiceAsset? VoiceAsset { get; set; } + public VideoAsset? VideoAsset { get; set; } +} diff --git a/src/ClipForge.Core/Entities/VoiceAsset.cs b/src/ClipForge.Core/Entities/VoiceAsset.cs new file mode 100644 index 0000000000000000000000000000000000000000..3b101b6048f04901e388cabf64c5c1dcccee8d8a --- /dev/null +++ b/src/ClipForge.Core/Entities/VoiceAsset.cs @@ -0,0 +1,14 @@ +namespace ClipForge.Core.Entities; + +public class VoiceAsset : BaseEntity +{ + public Guid VideoScriptId { get; set; } + public string FilePath { get; set; } = string.Empty; + public string VoiceProvider { get; set; } = "openai"; // openai, elevenlabs + public string VoiceId { get; set; } = "alloy"; + public double DurationSeconds { get; set; } + public long FileSizeBytes { get; set; } + + // Navigation + public VideoScript? VideoScript { get; set; } +} diff --git a/src/ClipForge.Core/Interfaces/IRepository.cs b/src/ClipForge.Core/Interfaces/IRepository.cs new file mode 100644 index 0000000000000000000000000000000000000000..30ef96cb590a9a597268115bd9a78ee2352c2f57 --- /dev/null +++ b/src/ClipForge.Core/Interfaces/IRepository.cs @@ -0,0 +1,12 @@ +using ClipForge.Core.Entities; + +namespace ClipForge.Core.Interfaces; + +public interface IRepository where T : BaseEntity +{ + Task GetByIdAsync(Guid id, CancellationToken ct = default); + Task> GetAllAsync(CancellationToken ct = default); + Task AddAsync(T entity, CancellationToken ct = default); + Task UpdateAsync(T entity, CancellationToken ct = default); + Task DeleteAsync(Guid id, CancellationToken ct = default); +} diff --git a/src/ClipForge.Core/Interfaces/IVideoAssetRepository.cs b/src/ClipForge.Core/Interfaces/IVideoAssetRepository.cs new file mode 100644 index 0000000000000000000000000000000000000000..f211ad55fb76647bdf0de57aff76761f9f1a7de8 --- /dev/null +++ b/src/ClipForge.Core/Interfaces/IVideoAssetRepository.cs @@ -0,0 +1,9 @@ +using ClipForge.Core.Entities; + +namespace ClipForge.Core.Interfaces; + +public interface IVideoAssetRepository : IRepository +{ + Task> GetByStatusAsync(string status, CancellationToken ct = default); + Task GetByScriptIdAsync(Guid scriptId, CancellationToken ct = default); +} diff --git a/src/ClipForge.Core/Interfaces/IVideoIdeaRepository.cs b/src/ClipForge.Core/Interfaces/IVideoIdeaRepository.cs new file mode 100644 index 0000000000000000000000000000000000000000..04a2454f1c48cdd21e448cb40e4172342e8c24fd --- /dev/null +++ b/src/ClipForge.Core/Interfaces/IVideoIdeaRepository.cs @@ -0,0 +1,9 @@ +using ClipForge.Core.Entities; + +namespace ClipForge.Core.Interfaces; + +public interface IVideoIdeaRepository : IRepository +{ + Task> GetByStatusAsync(string status, CancellationToken ct = default); + Task> GetByNicheAsync(string niche, CancellationToken ct = default); +} diff --git a/src/ClipForge.Core/Interfaces/IVideoScriptRepository.cs b/src/ClipForge.Core/Interfaces/IVideoScriptRepository.cs new file mode 100644 index 0000000000000000000000000000000000000000..37ddac910f123a0c75513c577c15b128880cf579 --- /dev/null +++ b/src/ClipForge.Core/Interfaces/IVideoScriptRepository.cs @@ -0,0 +1,8 @@ +using ClipForge.Core.Entities; + +namespace ClipForge.Core.Interfaces; + +public interface IVideoScriptRepository : IRepository +{ + Task GetByIdeaIdAsync(Guid ideaId, CancellationToken ct = default); +} diff --git a/src/ClipForge.Core/Interfaces/Services/IFfmpegService.cs b/src/ClipForge.Core/Interfaces/Services/IFfmpegService.cs new file mode 100644 index 0000000000000000000000000000000000000000..1f2fa28da5d9502ade2cbb3d1691fe41fb3afe4a --- /dev/null +++ b/src/ClipForge.Core/Interfaces/Services/IFfmpegService.cs @@ -0,0 +1,9 @@ +namespace ClipForge.Core.Interfaces.Services; + +public interface IFfmpegService +{ + Task AssembleVerticalVideoAsync(string audioPath, IReadOnlyList backgroundClips, string outputPath, CancellationToken ct = default); + Task AddSubtitlesToVideoAsync(string videoPath, string srtPath, string outputPath, CancellationToken ct = default); + Task GetMediaDurationAsync(string filePath, CancellationToken ct = default); + Task GenerateThumbnailAsync(string videoPath, string outputPath, double atSecond = 1.0, CancellationToken ct = default); +} diff --git a/src/ClipForge.Core/Interfaces/Services/IIdeaGenerationService.cs b/src/ClipForge.Core/Interfaces/Services/IIdeaGenerationService.cs new file mode 100644 index 0000000000000000000000000000000000000000..4d643ef22b0cae0150b99d46379d325d0100c987 --- /dev/null +++ b/src/ClipForge.Core/Interfaces/Services/IIdeaGenerationService.cs @@ -0,0 +1,9 @@ +using ClipForge.Core.Entities; + +namespace ClipForge.Core.Interfaces.Services; + +public interface IIdeaGenerationService +{ + Task GenerateIdeaAsync(string niche, string platform = "tiktok", CancellationToken ct = default); + Task> GenerateBatchIdeasAsync(string niche, int count = 5, string platform = "tiktok", CancellationToken ct = default); +} diff --git a/src/ClipForge.Core/Interfaces/Services/IOpenAiClient.cs b/src/ClipForge.Core/Interfaces/Services/IOpenAiClient.cs new file mode 100644 index 0000000000000000000000000000000000000000..9e0945f4ae9026d109073b57c7f81a83b4900fc1 --- /dev/null +++ b/src/ClipForge.Core/Interfaces/Services/IOpenAiClient.cs @@ -0,0 +1,7 @@ +namespace ClipForge.Core.Interfaces.Services; + +public interface IOpenAiClient +{ + Task GenerateChatCompletionAsync(string systemPrompt, string userPrompt, CancellationToken ct = default); + Task GenerateSpeechAsync(string text, string voice = "alloy", CancellationToken ct = default); +} diff --git a/src/ClipForge.Core/Interfaces/Services/ISchedulerService.cs b/src/ClipForge.Core/Interfaces/Services/ISchedulerService.cs new file mode 100644 index 0000000000000000000000000000000000000000..7c183dae68ec37d54d60b1265e8f9056894dbcce --- /dev/null +++ b/src/ClipForge.Core/Interfaces/Services/ISchedulerService.cs @@ -0,0 +1,8 @@ +namespace ClipForge.Core.Interfaces.Services; + +public interface ISchedulerService +{ + Task ScheduleFullPipelineAsync(string niche, string platform = "tiktok", CancellationToken ct = default); + Task ScheduleRecurringGenerationAsync(string niche, string cronExpression, string platform = "tiktok", CancellationToken ct = default); + Task CancelRecurringJobAsync(string jobId, CancellationToken ct = default); +} diff --git a/src/ClipForge.Core/Interfaces/Services/IScriptGenerationService.cs b/src/ClipForge.Core/Interfaces/Services/IScriptGenerationService.cs new file mode 100644 index 0000000000000000000000000000000000000000..d5097ad18f4a2981f5792af8ef4c000d5560f964 --- /dev/null +++ b/src/ClipForge.Core/Interfaces/Services/IScriptGenerationService.cs @@ -0,0 +1,9 @@ +using ClipForge.Core.Entities; + +namespace ClipForge.Core.Interfaces.Services; + +public interface IScriptGenerationService +{ + Task GenerateScriptAsync(Guid ideaId, CancellationToken ct = default); + Task GenerateScriptFromTopicAsync(string topic, string tone = "engaging", string language = "pt-BR", CancellationToken ct = default); +} diff --git a/src/ClipForge.Core/Interfaces/Services/IStockMediaService.cs b/src/ClipForge.Core/Interfaces/Services/IStockMediaService.cs new file mode 100644 index 0000000000000000000000000000000000000000..bcaad14683d94e830bce0099679c7504b9ac809a --- /dev/null +++ b/src/ClipForge.Core/Interfaces/Services/IStockMediaService.cs @@ -0,0 +1,7 @@ +namespace ClipForge.Core.Interfaces.Services; + +public interface IStockMediaService +{ + Task DownloadVideoAsync(string query, string outputDir, CancellationToken ct = default); + Task> DownloadMultipleVideosAsync(string query, int count, string outputDir, CancellationToken ct = default); +} diff --git a/src/ClipForge.Core/Interfaces/Services/ISubtitleService.cs b/src/ClipForge.Core/Interfaces/Services/ISubtitleService.cs new file mode 100644 index 0000000000000000000000000000000000000000..3b202d1df1a640d140bcea4b60cfaaa7b22aadbe --- /dev/null +++ b/src/ClipForge.Core/Interfaces/Services/ISubtitleService.cs @@ -0,0 +1,9 @@ +using ClipForge.Core.Entities; + +namespace ClipForge.Core.Interfaces.Services; + +public interface ISubtitleService +{ + Task GenerateSubtitlesAsync(Guid videoAssetId, CancellationToken ct = default); + Task GenerateSrtFromTextAsync(string text, double totalDuration, CancellationToken ct = default); +} diff --git a/src/ClipForge.Core/Interfaces/Services/IVideoAssemblyService.cs b/src/ClipForge.Core/Interfaces/Services/IVideoAssemblyService.cs new file mode 100644 index 0000000000000000000000000000000000000000..5682988edba94fb68e204390d71a21c805c2c687 --- /dev/null +++ b/src/ClipForge.Core/Interfaces/Services/IVideoAssemblyService.cs @@ -0,0 +1,8 @@ +using ClipForge.Core.Entities; + +namespace ClipForge.Core.Interfaces.Services; + +public interface IVideoAssemblyService +{ + Task AssembleVideoAsync(Guid scriptId, CancellationToken ct = default); +} diff --git a/src/ClipForge.Core/Interfaces/Services/IVoiceGenerationService.cs b/src/ClipForge.Core/Interfaces/Services/IVoiceGenerationService.cs new file mode 100644 index 0000000000000000000000000000000000000000..9cab68f457f5c0040aa749c220660c997255a4a6 --- /dev/null +++ b/src/ClipForge.Core/Interfaces/Services/IVoiceGenerationService.cs @@ -0,0 +1,8 @@ +using ClipForge.Core.Entities; + +namespace ClipForge.Core.Interfaces.Services; + +public interface IVoiceGenerationService +{ + Task GenerateVoiceAsync(Guid scriptId, string voiceId = "alloy", CancellationToken ct = default); +} diff --git a/src/ClipForge.Infrastructure/ClipForge.Infrastructure.csproj b/src/ClipForge.Infrastructure/ClipForge.Infrastructure.csproj new file mode 100644 index 0000000000000000000000000000000000000000..83a78337518ef09f030ee3d9e5040daecffe7eea --- /dev/null +++ b/src/ClipForge.Infrastructure/ClipForge.Infrastructure.csproj @@ -0,0 +1,25 @@ + + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + net9.0 + enable + enable + + + diff --git a/src/ClipForge.Infrastructure/Configuration/OpenAiSettings.cs b/src/ClipForge.Infrastructure/Configuration/OpenAiSettings.cs new file mode 100644 index 0000000000000000000000000000000000000000..b8608a02479166f3b324a98b63138963d1397a34 --- /dev/null +++ b/src/ClipForge.Infrastructure/Configuration/OpenAiSettings.cs @@ -0,0 +1,10 @@ +namespace ClipForge.Infrastructure.Configuration; + +public class OpenAiSettings +{ + public const string SectionName = "OpenAi"; + public string ApiKey { get; set; } = string.Empty; + public string Model { get; set; } = "llama-3.3-70b-versatile"; + public string TtsModel { get; set; } = "tts-1"; + public string BaseUrl { get; set; } = "https://api.groq.com/openai/v1"; +} diff --git a/src/ClipForge.Infrastructure/Configuration/PexelsSettings.cs b/src/ClipForge.Infrastructure/Configuration/PexelsSettings.cs new file mode 100644 index 0000000000000000000000000000000000000000..4e81c14da3e65d78f1f5379b6c45a28608a4fb9b --- /dev/null +++ b/src/ClipForge.Infrastructure/Configuration/PexelsSettings.cs @@ -0,0 +1,8 @@ +namespace ClipForge.Infrastructure.Configuration; + +public class PexelsSettings +{ + public const string SectionName = "Pexels"; + public string ApiKey { get; set; } = string.Empty; + public string BaseUrl { get; set; } = "https://api.pexels.com"; +} diff --git a/src/ClipForge.Infrastructure/Configuration/StorageSettings.cs b/src/ClipForge.Infrastructure/Configuration/StorageSettings.cs new file mode 100644 index 0000000000000000000000000000000000000000..19f9e7c0cf0e625cc303d09ea7b9f36e60b69ceb --- /dev/null +++ b/src/ClipForge.Infrastructure/Configuration/StorageSettings.cs @@ -0,0 +1,12 @@ +namespace ClipForge.Infrastructure.Configuration; + +public class StorageSettings +{ + public const string SectionName = "Storage"; + public string BasePath { get; set; } = "./output"; + public string AudioFolder { get; set; } = "audio"; + public string VideoFolder { get; set; } = "videos"; + public string ThumbnailFolder { get; set; } = "thumbnails"; + public string SubtitleFolder { get; set; } = "subtitles"; + public string TempFolder { get; set; } = "temp"; +} diff --git a/src/ClipForge.Infrastructure/Data/AppDbContext.cs b/src/ClipForge.Infrastructure/Data/AppDbContext.cs new file mode 100644 index 0000000000000000000000000000000000000000..090ea1405fe304002b3d11a429d214054d3b3335 --- /dev/null +++ b/src/ClipForge.Infrastructure/Data/AppDbContext.cs @@ -0,0 +1,107 @@ +using ClipForge.Core.Entities; +using Microsoft.EntityFrameworkCore; + +namespace ClipForge.Infrastructure.Data; + +public class AppDbContext : DbContext +{ + public AppDbContext(DbContextOptions options) : base(options) { } + + public DbSet VideoIdeas => Set(); + public DbSet VideoScripts => Set(); + public DbSet VoiceAssets => Set(); + public DbSet VideoAssets => Set(); + public DbSet CaptionAssets => Set(); + public DbSet PublishJobs => Set(); + public DbSet SocialAccounts => Set(); + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id); + entity.Property(e => e.Topic).HasMaxLength(500).IsRequired(); + entity.Property(e => e.Title).HasMaxLength(500).IsRequired(); + entity.Property(e => e.Hook).HasMaxLength(1000).IsRequired(); + entity.Property(e => e.TargetAudience).HasMaxLength(200); + entity.Property(e => e.Platform).HasMaxLength(50); + entity.Property(e => e.Status).HasMaxLength(50); + entity.Property(e => e.Niche).HasMaxLength(200); + entity.Property(e => e.Tags).HasMaxLength(1000); + entity.HasOne(e => e.Script).WithOne(s => s.VideoIdea).HasForeignKey(s => s.VideoIdeaId); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id); + entity.Property(e => e.ScriptText).IsRequired(); + entity.Property(e => e.Scenes).IsRequired(); + entity.Property(e => e.Tone).HasMaxLength(50); + entity.Property(e => e.Language).HasMaxLength(10); + entity.HasOne(e => e.VoiceAsset).WithOne(v => v.VideoScript).HasForeignKey(v => v.VideoScriptId); + entity.HasOne(e => e.VideoAsset).WithOne(v => v.VideoScript).HasForeignKey(v => v.VideoScriptId); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id); + entity.Property(e => e.FilePath).HasMaxLength(1000).IsRequired(); + entity.Property(e => e.VoiceProvider).HasMaxLength(50); + entity.Property(e => e.VoiceId).HasMaxLength(100); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id); + entity.Property(e => e.FilePath).HasMaxLength(1000).IsRequired(); + entity.Property(e => e.ThumbnailPath).HasMaxLength(1000); + entity.Property(e => e.Format).HasMaxLength(10); + entity.Property(e => e.Status).HasMaxLength(50); + entity.HasOne(e => e.CaptionAsset).WithOne(c => c.VideoAsset).HasForeignKey(c => c.VideoAssetId); + entity.HasMany(e => e.PublishJobs).WithOne(p => p.VideoAsset).HasForeignKey(p => p.VideoAssetId); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id); + entity.Property(e => e.SrtFilePath).HasMaxLength(1000).IsRequired(); + entity.Property(e => e.CaptionStyle).HasMaxLength(50); + entity.Property(e => e.FontFamily).HasMaxLength(100); + entity.Property(e => e.FontColor).HasMaxLength(20); + entity.Property(e => e.StrokeColor).HasMaxLength(20); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id); + entity.Property(e => e.Platform).HasMaxLength(50).IsRequired(); + entity.Property(e => e.Status).HasMaxLength(50); + entity.Property(e => e.ExternalId).HasMaxLength(500); + entity.Property(e => e.ErrorMessage).HasMaxLength(2000); + entity.Property(e => e.Caption).HasMaxLength(2000); + entity.Property(e => e.Hashtags).HasMaxLength(1000); + entity.HasOne(e => e.SocialAccount).WithMany(s => s.PublishJobs).HasForeignKey(e => e.SocialAccountId); + }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.Id); + entity.Property(e => e.Platform).HasMaxLength(50).IsRequired(); + entity.Property(e => e.AccountName).HasMaxLength(200).IsRequired(); + entity.Property(e => e.AccessToken).HasMaxLength(2000); + entity.Property(e => e.RefreshToken).HasMaxLength(2000); + }); + } + + public override Task SaveChangesAsync(CancellationToken cancellationToken = default) + { + foreach (var entry in ChangeTracker.Entries()) + { + if (entry.State == EntityState.Modified) + entry.Entity.UpdatedAt = DateTime.UtcNow; + } + return base.SaveChangesAsync(cancellationToken); + } +} diff --git a/src/ClipForge.Infrastructure/Data/Migrations/20260517232254_InitialCreate.Designer.cs b/src/ClipForge.Infrastructure/Data/Migrations/20260517232254_InitialCreate.Designer.cs new file mode 100644 index 0000000000000000000000000000000000000000..253e3785d2c37d3c001db6ee1b842298324e9e27 --- /dev/null +++ b/src/ClipForge.Infrastructure/Data/Migrations/20260517232254_InitialCreate.Designer.cs @@ -0,0 +1,467 @@ +// +using System; +using ClipForge.Infrastructure.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace ClipForge.Infrastructure.Data.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20260517232254_InitialCreate")] + partial class InitialCreate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("ClipForge.Core.Entities.CaptionAsset", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CaptionStyle") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("FontColor") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("FontFamily") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("FontSize") + .HasColumnType("integer"); + + b.Property("SrtFilePath") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("StrokeColor") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("StrokeWidth") + .HasColumnType("integer"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("VideoAssetId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("VideoAssetId") + .IsUnique(); + + b.ToTable("CaptionAssets"); + }); + + modelBuilder.Entity("ClipForge.Core.Entities.PublishJob", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Caption") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ErrorMessage") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("ExternalId") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("Hashtags") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("Platform") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("PublishedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ScheduledAt") + .HasColumnType("timestamp with time zone"); + + b.Property("SocialAccountId") + .HasColumnType("uuid"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("VideoAssetId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("SocialAccountId"); + + b.HasIndex("VideoAssetId"); + + b.ToTable("PublishJobs"); + }); + + modelBuilder.Entity("ClipForge.Core.Entities.SocialAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccessToken") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("AccountName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("Platform") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("RefreshToken") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("TokenExpiresAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("SocialAccounts"); + }); + + modelBuilder.Entity("ClipForge.Core.Entities.VideoAsset", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DurationSeconds") + .HasColumnType("double precision"); + + b.Property("FilePath") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("FileSizeBytes") + .HasColumnType("bigint"); + + b.Property("Format") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("Height") + .HasColumnType("integer"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ThumbnailPath") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("VideoScriptId") + .HasColumnType("uuid"); + + b.Property("Width") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("VideoScriptId") + .IsUnique(); + + b.ToTable("VideoAssets"); + }); + + modelBuilder.Entity("ClipForge.Core.Entities.VideoIdea", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("Hook") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("Niche") + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Platform") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("Tags") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("TargetAudience") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("Topic") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("VideoIdeas"); + }); + + modelBuilder.Entity("ClipForge.Core.Entities.VideoScript", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("EstimatedDurationSeconds") + .HasColumnType("integer"); + + b.Property("Language") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("Scenes") + .IsRequired() + .HasColumnType("text"); + + b.Property("ScriptText") + .IsRequired() + .HasColumnType("text"); + + b.Property("Tone") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("VideoIdeaId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("VideoIdeaId") + .IsUnique(); + + b.ToTable("VideoScripts"); + }); + + modelBuilder.Entity("ClipForge.Core.Entities.VoiceAsset", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DurationSeconds") + .HasColumnType("double precision"); + + b.Property("FilePath") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("FileSizeBytes") + .HasColumnType("bigint"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("VideoScriptId") + .HasColumnType("uuid"); + + b.Property("VoiceId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("VoiceProvider") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.HasKey("Id"); + + b.HasIndex("VideoScriptId") + .IsUnique(); + + b.ToTable("VoiceAssets"); + }); + + modelBuilder.Entity("ClipForge.Core.Entities.CaptionAsset", b => + { + b.HasOne("ClipForge.Core.Entities.VideoAsset", "VideoAsset") + .WithOne("CaptionAsset") + .HasForeignKey("ClipForge.Core.Entities.CaptionAsset", "VideoAssetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("VideoAsset"); + }); + + modelBuilder.Entity("ClipForge.Core.Entities.PublishJob", b => + { + b.HasOne("ClipForge.Core.Entities.SocialAccount", "SocialAccount") + .WithMany("PublishJobs") + .HasForeignKey("SocialAccountId"); + + b.HasOne("ClipForge.Core.Entities.VideoAsset", "VideoAsset") + .WithMany("PublishJobs") + .HasForeignKey("VideoAssetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("SocialAccount"); + + b.Navigation("VideoAsset"); + }); + + modelBuilder.Entity("ClipForge.Core.Entities.VideoAsset", b => + { + b.HasOne("ClipForge.Core.Entities.VideoScript", "VideoScript") + .WithOne("VideoAsset") + .HasForeignKey("ClipForge.Core.Entities.VideoAsset", "VideoScriptId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("VideoScript"); + }); + + modelBuilder.Entity("ClipForge.Core.Entities.VideoScript", b => + { + b.HasOne("ClipForge.Core.Entities.VideoIdea", "VideoIdea") + .WithOne("Script") + .HasForeignKey("ClipForge.Core.Entities.VideoScript", "VideoIdeaId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("VideoIdea"); + }); + + modelBuilder.Entity("ClipForge.Core.Entities.VoiceAsset", b => + { + b.HasOne("ClipForge.Core.Entities.VideoScript", "VideoScript") + .WithOne("VoiceAsset") + .HasForeignKey("ClipForge.Core.Entities.VoiceAsset", "VideoScriptId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("VideoScript"); + }); + + modelBuilder.Entity("ClipForge.Core.Entities.SocialAccount", b => + { + b.Navigation("PublishJobs"); + }); + + modelBuilder.Entity("ClipForge.Core.Entities.VideoAsset", b => + { + b.Navigation("CaptionAsset"); + + b.Navigation("PublishJobs"); + }); + + modelBuilder.Entity("ClipForge.Core.Entities.VideoIdea", b => + { + b.Navigation("Script"); + }); + + modelBuilder.Entity("ClipForge.Core.Entities.VideoScript", b => + { + b.Navigation("VideoAsset"); + + b.Navigation("VoiceAsset"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/ClipForge.Infrastructure/Data/Migrations/20260517232254_InitialCreate.cs b/src/ClipForge.Infrastructure/Data/Migrations/20260517232254_InitialCreate.cs new file mode 100644 index 0000000000000000000000000000000000000000..3e59592c726019740dc5cfbdd8510fc9933def02 --- /dev/null +++ b/src/ClipForge.Infrastructure/Data/Migrations/20260517232254_InitialCreate.cs @@ -0,0 +1,253 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace ClipForge.Infrastructure.Data.Migrations +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "SocialAccounts", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Platform = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + AccountName = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + AccessToken = table.Column(type: "character varying(2000)", maxLength: 2000, nullable: true), + RefreshToken = table.Column(type: "character varying(2000)", maxLength: 2000, nullable: true), + TokenExpiresAt = table.Column(type: "timestamp with time zone", nullable: true), + IsActive = table.Column(type: "boolean", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_SocialAccounts", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "VideoIdeas", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + Topic = table.Column(type: "character varying(500)", maxLength: 500, nullable: false), + Title = table.Column(type: "character varying(500)", maxLength: 500, nullable: false), + Hook = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: false), + TargetAudience = table.Column(type: "character varying(200)", maxLength: 200, nullable: false), + Platform = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + Status = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + Niche = table.Column(type: "character varying(200)", maxLength: 200, nullable: true), + Tags = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_VideoIdeas", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "VideoScripts", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + VideoIdeaId = table.Column(type: "uuid", nullable: false), + ScriptText = table.Column(type: "text", nullable: false), + Scenes = table.Column(type: "text", nullable: false), + EstimatedDurationSeconds = table.Column(type: "integer", nullable: false), + Tone = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + Language = table.Column(type: "character varying(10)", maxLength: 10, nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_VideoScripts", x => x.Id); + table.ForeignKey( + name: "FK_VideoScripts_VideoIdeas_VideoIdeaId", + column: x => x.VideoIdeaId, + principalTable: "VideoIdeas", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "VideoAssets", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + VideoScriptId = table.Column(type: "uuid", nullable: false), + FilePath = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: false), + ThumbnailPath = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: false), + Width = table.Column(type: "integer", nullable: false), + Height = table.Column(type: "integer", nullable: false), + DurationSeconds = table.Column(type: "double precision", nullable: false), + FileSizeBytes = table.Column(type: "bigint", nullable: false), + Format = table.Column(type: "character varying(10)", maxLength: 10, nullable: false), + Status = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_VideoAssets", x => x.Id); + table.ForeignKey( + name: "FK_VideoAssets_VideoScripts_VideoScriptId", + column: x => x.VideoScriptId, + principalTable: "VideoScripts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "VoiceAssets", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + VideoScriptId = table.Column(type: "uuid", nullable: false), + FilePath = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: false), + VoiceProvider = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + VoiceId = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), + DurationSeconds = table.Column(type: "double precision", nullable: false), + FileSizeBytes = table.Column(type: "bigint", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_VoiceAssets", x => x.Id); + table.ForeignKey( + name: "FK_VoiceAssets_VideoScripts_VideoScriptId", + column: x => x.VideoScriptId, + principalTable: "VideoScripts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "CaptionAssets", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + VideoAssetId = table.Column(type: "uuid", nullable: false), + SrtFilePath = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: false), + CaptionStyle = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + FontFamily = table.Column(type: "character varying(100)", maxLength: 100, nullable: false), + FontSize = table.Column(type: "integer", nullable: false), + FontColor = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + StrokeColor = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), + StrokeWidth = table.Column(type: "integer", nullable: false), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_CaptionAssets", x => x.Id); + table.ForeignKey( + name: "FK_CaptionAssets_VideoAssets_VideoAssetId", + column: x => x.VideoAssetId, + principalTable: "VideoAssets", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "PublishJobs", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + VideoAssetId = table.Column(type: "uuid", nullable: false), + SocialAccountId = table.Column(type: "uuid", nullable: true), + Platform = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + Status = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), + ScheduledAt = table.Column(type: "timestamp with time zone", nullable: true), + PublishedAt = table.Column(type: "timestamp with time zone", nullable: true), + ExternalId = table.Column(type: "character varying(500)", maxLength: 500, nullable: true), + ErrorMessage = table.Column(type: "character varying(2000)", maxLength: 2000, nullable: true), + Caption = table.Column(type: "character varying(2000)", maxLength: 2000, nullable: true), + Hashtags = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: true), + CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), + UpdatedAt = table.Column(type: "timestamp with time zone", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_PublishJobs", x => x.Id); + table.ForeignKey( + name: "FK_PublishJobs_SocialAccounts_SocialAccountId", + column: x => x.SocialAccountId, + principalTable: "SocialAccounts", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_PublishJobs_VideoAssets_VideoAssetId", + column: x => x.VideoAssetId, + principalTable: "VideoAssets", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_CaptionAssets_VideoAssetId", + table: "CaptionAssets", + column: "VideoAssetId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_PublishJobs_SocialAccountId", + table: "PublishJobs", + column: "SocialAccountId"); + + migrationBuilder.CreateIndex( + name: "IX_PublishJobs_VideoAssetId", + table: "PublishJobs", + column: "VideoAssetId"); + + migrationBuilder.CreateIndex( + name: "IX_VideoAssets_VideoScriptId", + table: "VideoAssets", + column: "VideoScriptId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_VideoScripts_VideoIdeaId", + table: "VideoScripts", + column: "VideoIdeaId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_VoiceAssets_VideoScriptId", + table: "VoiceAssets", + column: "VideoScriptId", + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "CaptionAssets"); + + migrationBuilder.DropTable( + name: "PublishJobs"); + + migrationBuilder.DropTable( + name: "VoiceAssets"); + + migrationBuilder.DropTable( + name: "SocialAccounts"); + + migrationBuilder.DropTable( + name: "VideoAssets"); + + migrationBuilder.DropTable( + name: "VideoScripts"); + + migrationBuilder.DropTable( + name: "VideoIdeas"); + } + } +} diff --git a/src/ClipForge.Infrastructure/Data/Migrations/AppDbContextModelSnapshot.cs b/src/ClipForge.Infrastructure/Data/Migrations/AppDbContextModelSnapshot.cs new file mode 100644 index 0000000000000000000000000000000000000000..651e70b7d0562e234110d7df804ab9f403940a1e --- /dev/null +++ b/src/ClipForge.Infrastructure/Data/Migrations/AppDbContextModelSnapshot.cs @@ -0,0 +1,464 @@ +// +using System; +using ClipForge.Infrastructure.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace ClipForge.Infrastructure.Data.Migrations +{ + [DbContext(typeof(AppDbContext))] + partial class AppDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("ClipForge.Core.Entities.CaptionAsset", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CaptionStyle") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("FontColor") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("FontFamily") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("FontSize") + .HasColumnType("integer"); + + b.Property("SrtFilePath") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("StrokeColor") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)"); + + b.Property("StrokeWidth") + .HasColumnType("integer"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("VideoAssetId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("VideoAssetId") + .IsUnique(); + + b.ToTable("CaptionAssets"); + }); + + modelBuilder.Entity("ClipForge.Core.Entities.PublishJob", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Caption") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ErrorMessage") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("ExternalId") + .HasMaxLength(500) + .HasColumnType("character varying(500)"); + + b.Property("Hashtags") + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("Platform") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("PublishedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("ScheduledAt") + .HasColumnType("timestamp with time zone"); + + b.Property("SocialAccountId") + .HasColumnType("uuid"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("VideoAssetId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("SocialAccountId"); + + b.HasIndex("VideoAssetId"); + + b.ToTable("PublishJobs"); + }); + + modelBuilder.Entity("ClipForge.Core.Entities.SocialAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AccessToken") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("AccountName") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("character varying(200)"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("IsActive") + .HasColumnType("boolean"); + + b.Property("Platform") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("RefreshToken") + .HasMaxLength(2000) + .HasColumnType("character varying(2000)"); + + b.Property("TokenExpiresAt") + .HasColumnType("timestamp with time zone"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.ToTable("SocialAccounts"); + }); + + modelBuilder.Entity("ClipForge.Core.Entities.VideoAsset", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("DurationSeconds") + .HasColumnType("double precision"); + + b.Property("FilePath") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("FileSizeBytes") + .HasColumnType("bigint"); + + b.Property("Format") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("character varying(10)"); + + b.Property("Height") + .HasColumnType("integer"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)"); + + b.Property("ThumbnailPath") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("character varying(1000)"); + + b.Property("UpdatedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("VideoScriptId") + .HasColumnType("uuid"); + + b.Property("Width") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("VideoScriptId") + .IsUnique(); + + b.ToTable("VideoAssets"); + }); + + modelBuilder.Entity("ClipForge.Core.Entities.VideoIdea", b => + { + b.Property
Gerador automático de vídeos virais com IA