Vanderson da Silva Quintino commited on
Commit
8fb6238
·
1 Parent(s): 601ebde

Initial deploy: ClipForge video generator

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .dockerignore +10 -0
  2. Dockerfile +24 -0
  3. src/ClipForge.Api/ClipForge.Api.csproj +25 -0
  4. src/ClipForge.Api/Endpoints/IdeaEndpoints.cs +54 -0
  5. src/ClipForge.Api/Endpoints/PipelineEndpoints.cs +45 -0
  6. src/ClipForge.Api/Endpoints/ScriptEndpoints.cs +42 -0
  7. src/ClipForge.Api/Endpoints/VideoEndpoints.cs +60 -0
  8. src/ClipForge.Api/Endpoints/VoiceEndpoints.cs +28 -0
  9. src/ClipForge.Api/Program.cs +68 -0
  10. src/ClipForge.Api/Properties/launchSettings.json +23 -0
  11. src/ClipForge.Api/appsettings.Production.json +25 -0
  12. src/ClipForge.Api/appsettings.json +25 -0
  13. src/ClipForge.Api/wwwroot/index.html +216 -0
  14. src/ClipForge.Contracts/ClipForge.Contracts.csproj +9 -0
  15. src/ClipForge.Contracts/Requests/AssembleVideoRequest.cs +5 -0
  16. src/ClipForge.Contracts/Requests/FullPipelineRequest.cs +9 -0
  17. src/ClipForge.Contracts/Requests/GenerateIdeaRequest.cs +7 -0
  18. src/ClipForge.Contracts/Requests/GenerateScriptRequest.cs +7 -0
  19. src/ClipForge.Contracts/Requests/GenerateVoiceRequest.cs +6 -0
  20. src/ClipForge.Contracts/Requests/SchedulePipelineRequest.cs +7 -0
  21. src/ClipForge.Contracts/Responses/PipelineStatusResponse.cs +10 -0
  22. src/ClipForge.Contracts/Responses/VideoAssetResponse.cs +15 -0
  23. src/ClipForge.Contracts/Responses/VideoIdeaResponse.cs +14 -0
  24. src/ClipForge.Contracts/Responses/VideoScriptResponse.cs +12 -0
  25. src/ClipForge.Core/ClipForge.Core.csproj +9 -0
  26. src/ClipForge.Core/Entities/BaseEntity.cs +8 -0
  27. src/ClipForge.Core/Entities/CaptionAsset.cs +16 -0
  28. src/ClipForge.Core/Entities/PublishJob.cs +19 -0
  29. src/ClipForge.Core/Entities/SocialAccount.cs +14 -0
  30. src/ClipForge.Core/Entities/VideoAsset.cs +19 -0
  31. src/ClipForge.Core/Entities/VideoIdea.cs +16 -0
  32. src/ClipForge.Core/Entities/VideoScript.cs +16 -0
  33. src/ClipForge.Core/Entities/VoiceAsset.cs +14 -0
  34. src/ClipForge.Core/Interfaces/IRepository.cs +12 -0
  35. src/ClipForge.Core/Interfaces/IVideoAssetRepository.cs +9 -0
  36. src/ClipForge.Core/Interfaces/IVideoIdeaRepository.cs +9 -0
  37. src/ClipForge.Core/Interfaces/IVideoScriptRepository.cs +8 -0
  38. src/ClipForge.Core/Interfaces/Services/IFfmpegService.cs +9 -0
  39. src/ClipForge.Core/Interfaces/Services/IIdeaGenerationService.cs +9 -0
  40. src/ClipForge.Core/Interfaces/Services/IOpenAiClient.cs +7 -0
  41. src/ClipForge.Core/Interfaces/Services/ISchedulerService.cs +8 -0
  42. src/ClipForge.Core/Interfaces/Services/IScriptGenerationService.cs +9 -0
  43. src/ClipForge.Core/Interfaces/Services/IStockMediaService.cs +7 -0
  44. src/ClipForge.Core/Interfaces/Services/ISubtitleService.cs +9 -0
  45. src/ClipForge.Core/Interfaces/Services/IVideoAssemblyService.cs +8 -0
  46. src/ClipForge.Core/Interfaces/Services/IVoiceGenerationService.cs +8 -0
  47. src/ClipForge.Infrastructure/ClipForge.Infrastructure.csproj +25 -0
  48. src/ClipForge.Infrastructure/Configuration/OpenAiSettings.cs +10 -0
  49. src/ClipForge.Infrastructure/Configuration/PexelsSettings.cs +8 -0
  50. src/ClipForge.Infrastructure/Configuration/StorageSettings.cs +12 -0
.dockerignore ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ **/.git
2
+ **/.vs
3
+ **/bin
4
+ **/obj
5
+ **/output
6
+ **/.env
7
+ **/node_modules
8
+ *.md
9
+ .dockerignore
10
+ docker-compose*.yml
Dockerfile ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
2
+ WORKDIR /app
3
+ EXPOSE 7860
4
+
5
+ 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/*
6
+
7
+ FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
8
+ WORKDIR /src
9
+ COPY src/ClipForge.Api/ClipForge.Api.csproj ClipForge.Api/
10
+ COPY src/ClipForge.Core/ClipForge.Core.csproj ClipForge.Core/
11
+ COPY src/ClipForge.Infrastructure/ClipForge.Infrastructure.csproj ClipForge.Infrastructure/
12
+ COPY src/ClipForge.Workers/ClipForge.Workers.csproj ClipForge.Workers/
13
+ COPY src/ClipForge.Contracts/ClipForge.Contracts.csproj ClipForge.Contracts/
14
+ RUN dotnet restore ClipForge.Api/ClipForge.Api.csproj
15
+ COPY src/ .
16
+ RUN dotnet publish ClipForge.Api/ClipForge.Api.csproj -c Release -o /app/publish /p:UseAppHost=false
17
+
18
+ FROM base AS final
19
+ WORKDIR /app
20
+ COPY --from=publish /app/publish .
21
+ RUN mkdir -p /app/output/audio /app/output/videos /app/output/thumbnails /app/output/subtitles /app/output/temp
22
+ ENV ASPNETCORE_URLS=http://+:7860
23
+ ENV ASPNETCORE_ENVIRONMENT=Production
24
+ ENTRYPOINT ["dotnet", "ClipForge.Api.dll"]
src/ClipForge.Api/ClipForge.Api.csproj ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <Project Sdk="Microsoft.NET.Sdk.Web">
2
+
3
+ <ItemGroup>
4
+ <ProjectReference Include="..\ClipForge.Core\ClipForge.Core.csproj" />
5
+ <ProjectReference Include="..\ClipForge.Infrastructure\ClipForge.Infrastructure.csproj" />
6
+ <ProjectReference Include="..\ClipForge.Workers\ClipForge.Workers.csproj" />
7
+ <ProjectReference Include="..\ClipForge.Contracts\ClipForge.Contracts.csproj" />
8
+ </ItemGroup>
9
+
10
+ <ItemGroup>
11
+ <PackageReference Include="Hangfire.AspNetCore" Version="1.8.17" />
12
+ <PackageReference Include="Hangfire.PostgreSql" Version="1.20.10" />
13
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.1">
14
+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
15
+ <PrivateAssets>all</PrivateAssets>
16
+ </PackageReference>
17
+ </ItemGroup>
18
+
19
+ <PropertyGroup>
20
+ <TargetFramework>net9.0</TargetFramework>
21
+ <Nullable>enable</Nullable>
22
+ <ImplicitUsings>enable</ImplicitUsings>
23
+ </PropertyGroup>
24
+
25
+ </Project>
src/ClipForge.Api/Endpoints/IdeaEndpoints.cs ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ using ClipForge.Contracts.Requests;
2
+ using ClipForge.Contracts.Responses;
3
+ using ClipForge.Core.Interfaces;
4
+ using ClipForge.Core.Interfaces.Services;
5
+
6
+ namespace ClipForge.Api.Endpoints;
7
+
8
+ public static class IdeaEndpoints
9
+ {
10
+ public static void MapIdeaEndpoints(this WebApplication app)
11
+ {
12
+ var group = app.MapGroup("/api/ideas").WithTags("Ideas");
13
+
14
+ group.MapPost("/generate", async (GenerateIdeaRequest request, IIdeaGenerationService service) =>
15
+ {
16
+ if (request.Count > 1)
17
+ {
18
+ var ideas = await service.GenerateBatchIdeasAsync(request.Niche, request.Count, request.Platform);
19
+ return Results.Ok(ideas.Select(MapToResponse));
20
+ }
21
+
22
+ var idea = await service.GenerateIdeaAsync(request.Niche, request.Platform);
23
+ return Results.Ok(MapToResponse(idea));
24
+ });
25
+
26
+ group.MapGet("/", async (IVideoIdeaRepository repository) =>
27
+ {
28
+ var ideas = await repository.GetAllAsync();
29
+ return Results.Ok(ideas.Select(MapToResponse));
30
+ });
31
+
32
+ group.MapGet("/{id:guid}", async (Guid id, IVideoIdeaRepository repository) =>
33
+ {
34
+ var idea = await repository.GetByIdAsync(id);
35
+ return idea is null ? Results.NotFound() : Results.Ok(MapToResponse(idea));
36
+ });
37
+
38
+ group.MapGet("/status/{status}", async (string status, IVideoIdeaRepository repository) =>
39
+ {
40
+ var ideas = await repository.GetByStatusAsync(status);
41
+ return Results.Ok(ideas.Select(MapToResponse));
42
+ });
43
+
44
+ group.MapGet("/niche/{niche}", async (string niche, IVideoIdeaRepository repository) =>
45
+ {
46
+ var ideas = await repository.GetByNicheAsync(niche);
47
+ return Results.Ok(ideas.Select(MapToResponse));
48
+ });
49
+ }
50
+
51
+ private static VideoIdeaResponse MapToResponse(ClipForge.Core.Entities.VideoIdea idea) => new(
52
+ idea.Id, idea.Topic, idea.Title, idea.Hook, idea.TargetAudience,
53
+ idea.Platform, idea.Status, idea.Niche, idea.Tags, idea.CreatedAt);
54
+ }
src/ClipForge.Api/Endpoints/PipelineEndpoints.cs ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ using ClipForge.Contracts.Requests;
2
+ using ClipForge.Core.Interfaces.Services;
3
+ using ClipForge.Workers.Jobs;
4
+ using Hangfire;
5
+
6
+ namespace ClipForge.Api.Endpoints;
7
+
8
+ public static class PipelineEndpoints
9
+ {
10
+ public static void MapPipelineEndpoints(this WebApplication app)
11
+ {
12
+ var group = app.MapGroup("/api/pipeline").WithTags("Pipeline");
13
+
14
+ // Run full pipeline immediately (background job)
15
+ group.MapPost("/run", async (FullPipelineRequest request, ISchedulerService scheduler) =>
16
+ {
17
+ await scheduler.ScheduleFullPipelineAsync(request.Niche, request.Platform);
18
+ return Results.Accepted(value: new { Message = "Pipeline scheduled", Niche = request.Niche, Platform = request.Platform });
19
+ });
20
+
21
+ // Schedule recurring pipeline
22
+ group.MapPost("/schedule", async (SchedulePipelineRequest request, ISchedulerService scheduler) =>
23
+ {
24
+ if (string.IsNullOrEmpty(request.CronExpression))
25
+ return Results.BadRequest(new { Error = "CronExpression is required for scheduling" });
26
+
27
+ await scheduler.ScheduleRecurringGenerationAsync(request.Niche, request.CronExpression, request.Platform);
28
+ return Results.Ok(new { Message = "Recurring pipeline scheduled", Niche = request.Niche, Cron = request.CronExpression });
29
+ });
30
+
31
+ // Cancel recurring job
32
+ group.MapDelete("/schedule/{jobId}", async (string jobId, ISchedulerService scheduler) =>
33
+ {
34
+ await scheduler.CancelRecurringJobAsync(jobId);
35
+ return Results.Ok(new { Message = $"Job '{jobId}' cancelled" });
36
+ });
37
+
38
+ // Run full pipeline synchronously (for testing)
39
+ group.MapPost("/run-sync", async (FullPipelineRequest request, FullPipelineJob job) =>
40
+ {
41
+ await job.ExecuteAsync(request.Niche, request.Platform, request.VoiceId);
42
+ return Results.Ok(new { Message = "Pipeline completed", Niche = request.Niche });
43
+ });
44
+ }
45
+ }
src/ClipForge.Api/Endpoints/ScriptEndpoints.cs ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ using ClipForge.Contracts.Requests;
2
+ using ClipForge.Contracts.Responses;
3
+ using ClipForge.Core.Interfaces;
4
+ using ClipForge.Core.Interfaces.Services;
5
+
6
+ namespace ClipForge.Api.Endpoints;
7
+
8
+ public static class ScriptEndpoints
9
+ {
10
+ public static void MapScriptEndpoints(this WebApplication app)
11
+ {
12
+ var group = app.MapGroup("/api/scripts").WithTags("Scripts");
13
+
14
+ group.MapPost("/generate", async (GenerateScriptRequest request, IScriptGenerationService service) =>
15
+ {
16
+ var script = await service.GenerateScriptAsync(request.IdeaId);
17
+ return Results.Ok(MapToResponse(script));
18
+ });
19
+
20
+ group.MapGet("/", async (IVideoScriptRepository repository) =>
21
+ {
22
+ var scripts = await repository.GetAllAsync();
23
+ return Results.Ok(scripts.Select(MapToResponse));
24
+ });
25
+
26
+ group.MapGet("/{id:guid}", async (Guid id, IVideoScriptRepository repository) =>
27
+ {
28
+ var script = await repository.GetByIdAsync(id);
29
+ return script is null ? Results.NotFound() : Results.Ok(MapToResponse(script));
30
+ });
31
+
32
+ group.MapGet("/idea/{ideaId:guid}", async (Guid ideaId, IVideoScriptRepository repository) =>
33
+ {
34
+ var script = await repository.GetByIdeaIdAsync(ideaId);
35
+ return script is null ? Results.NotFound() : Results.Ok(MapToResponse(script));
36
+ });
37
+ }
38
+
39
+ private static VideoScriptResponse MapToResponse(ClipForge.Core.Entities.VideoScript script) => new(
40
+ script.Id, script.VideoIdeaId, script.ScriptText, script.Scenes,
41
+ script.EstimatedDurationSeconds, script.Tone, script.Language, script.CreatedAt);
42
+ }
src/ClipForge.Api/Endpoints/VideoEndpoints.cs ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ using ClipForge.Contracts.Requests;
2
+ using ClipForge.Contracts.Responses;
3
+ using ClipForge.Core.Interfaces;
4
+ using ClipForge.Core.Interfaces.Services;
5
+ using Microsoft.AspNetCore.Hosting;
6
+
7
+ namespace ClipForge.Api.Endpoints;
8
+
9
+ public static class VideoEndpoints
10
+ {
11
+ public static void MapVideoEndpoints(this WebApplication app)
12
+ {
13
+ var group = app.MapGroup("/api/videos").WithTags("Videos");
14
+
15
+ group.MapPost("/assemble", async (AssembleVideoRequest request, IVideoAssemblyService service) =>
16
+ {
17
+ var video = await service.AssembleVideoAsync(request.ScriptId);
18
+ return Results.Ok(MapToResponse(video));
19
+ });
20
+
21
+ group.MapGet("/", async (IVideoAssetRepository repository) =>
22
+ {
23
+ var videos = await repository.GetAllAsync();
24
+ return Results.Ok(videos.Select(MapToResponse));
25
+ });
26
+
27
+ group.MapGet("/{id:guid}", async (Guid id, IVideoAssetRepository repository) =>
28
+ {
29
+ var video = await repository.GetByIdAsync(id);
30
+ return video is null ? Results.NotFound() : Results.Ok(MapToResponse(video));
31
+ });
32
+
33
+ group.MapGet("/status/{status}", async (string status, IVideoAssetRepository repository) =>
34
+ {
35
+ var videos = await repository.GetByStatusAsync(status);
36
+ return Results.Ok(videos.Select(MapToResponse));
37
+ });
38
+
39
+ group.MapGet("/{id:guid}/download", async (Guid id, IVideoAssetRepository repository, IWebHostEnvironment env) =>
40
+ {
41
+ var video = await repository.GetByIdAsync(id);
42
+ if (video is null) return Results.NotFound();
43
+
44
+ // Resolve path relative to content root
45
+ var filePath = video.FilePath;
46
+ if (filePath.StartsWith("./"))
47
+ filePath = Path.Combine(env.ContentRootPath, filePath[2..]);
48
+
49
+ filePath = Path.GetFullPath(filePath);
50
+ if (!File.Exists(filePath)) return Results.NotFound($"File not found: {filePath}");
51
+
52
+ return Results.File(filePath, "video/mp4", $"clipforge_{id}.mp4");
53
+ });
54
+ }
55
+
56
+ private static VideoAssetResponse MapToResponse(ClipForge.Core.Entities.VideoAsset video) => new(
57
+ video.Id, video.VideoScriptId, video.FilePath, video.ThumbnailPath,
58
+ video.Width, video.Height, video.DurationSeconds, video.FileSizeBytes,
59
+ video.Format, video.Status, video.CreatedAt);
60
+ }
src/ClipForge.Api/Endpoints/VoiceEndpoints.cs ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ using ClipForge.Contracts.Requests;
2
+ using ClipForge.Core.Interfaces.Services;
3
+
4
+ namespace ClipForge.Api.Endpoints;
5
+
6
+ public static class VoiceEndpoints
7
+ {
8
+ public static void MapVoiceEndpoints(this WebApplication app)
9
+ {
10
+ var group = app.MapGroup("/api/voice").WithTags("Voice");
11
+
12
+ group.MapPost("/generate", async (GenerateVoiceRequest request, IVoiceGenerationService service) =>
13
+ {
14
+ var voice = await service.GenerateVoiceAsync(request.ScriptId, request.VoiceId);
15
+ return Results.Ok(new
16
+ {
17
+ voice.Id,
18
+ voice.VideoScriptId,
19
+ voice.FilePath,
20
+ voice.VoiceProvider,
21
+ voice.VoiceId,
22
+ voice.DurationSeconds,
23
+ voice.FileSizeBytes,
24
+ voice.CreatedAt
25
+ });
26
+ });
27
+ }
28
+ }
src/ClipForge.Api/Program.cs ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ using ClipForge.Api.Endpoints;
2
+ using ClipForge.Infrastructure;
3
+ using ClipForge.Infrastructure.Data;
4
+ using ClipForge.Workers.Jobs;
5
+ using Hangfire;
6
+ using Hangfire.PostgreSql;
7
+ using Microsoft.EntityFrameworkCore;
8
+
9
+ var builder = WebApplication.CreateBuilder(args);
10
+
11
+ // Add Infrastructure (DI, DbContext, Services)
12
+ builder.Services.AddInfrastructure(builder.Configuration);
13
+
14
+ // Workers
15
+ builder.Services.AddScoped<FullPipelineJob>();
16
+
17
+ // Hangfire
18
+ builder.Services.AddHangfire(config =>
19
+ config.UsePostgreSqlStorage(options =>
20
+ options.UseNpgsqlConnection(builder.Configuration.GetConnectionString("DefaultConnection"))));
21
+ builder.Services.AddHangfireServer();
22
+
23
+ var app = builder.Build();
24
+
25
+ // Apply migrations on startup
26
+ using (var scope = app.Services.CreateScope())
27
+ {
28
+ var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
29
+ await db.Database.MigrateAsync();
30
+ }
31
+
32
+ // Hangfire Dashboard
33
+ app.UseHangfireDashboard("/hangfire");
34
+
35
+ // Serve static files (frontend)
36
+ app.UseDefaultFiles();
37
+ app.UseStaticFiles();
38
+
39
+ // Map API endpoints
40
+ app.MapIdeaEndpoints();
41
+ app.MapScriptEndpoints();
42
+ app.MapVoiceEndpoints();
43
+ app.MapVideoEndpoints();
44
+ app.MapPipelineEndpoints();
45
+
46
+ app.MapGet("/api/status", () => Results.Ok(new
47
+ {
48
+ Name = "ClipForge API",
49
+ Version = "1.0.0",
50
+ Status = "Running"
51
+ }));
52
+
53
+ // Temporary cleanup endpoint
54
+ app.MapDelete("/api/admin/cleanup/{keepVideoId}", async (Guid keepVideoId, ClipForge.Infrastructure.Data.AppDbContext db) =>
55
+ {
56
+ var sql = $@"
57
+ DELETE FROM ""PublishJobs"" WHERE ""VideoAssetId"" != '{keepVideoId}';
58
+ DELETE FROM ""CaptionAssets"" WHERE ""VideoAssetId"" != '{keepVideoId}';
59
+ DELETE FROM ""VideoAssets"" WHERE ""Id"" != '{keepVideoId}';
60
+ DELETE FROM ""VoiceAssets"" WHERE ""VideoScriptId"" NOT IN (SELECT ""VideoScriptId"" FROM ""VideoAssets"" WHERE ""Id"" = '{keepVideoId}');
61
+ DELETE FROM ""VideoScripts"" WHERE ""Id"" NOT IN (SELECT ""VideoScriptId"" FROM ""VideoAssets"" WHERE ""Id"" = '{keepVideoId}');
62
+ DELETE FROM ""VideoIdeas"" WHERE ""Id"" NOT IN (SELECT ""VideoIdeaId"" FROM ""VideoScripts"" WHERE ""Id"" IN (SELECT ""VideoScriptId"" FROM ""VideoAssets"" WHERE ""Id"" = '{keepVideoId}'));
63
+ ";
64
+ var rows = await db.Database.ExecuteSqlRawAsync(sql);
65
+ return Results.Ok(new { Message = "Cleanup done", RowsDeleted = rows });
66
+ });
67
+
68
+ app.Run();
src/ClipForge.Api/Properties/launchSettings.json ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "$schema": "https://json.schemastore.org/launchsettings.json",
3
+ "profiles": {
4
+ "http": {
5
+ "commandName": "Project",
6
+ "dotnetRunMessages": true,
7
+ "launchBrowser": false,
8
+ "applicationUrl": "http://0.0.0.0:5011",
9
+ "environmentVariables": {
10
+ "ASPNETCORE_ENVIRONMENT": "Development"
11
+ }
12
+ },
13
+ "https": {
14
+ "commandName": "Project",
15
+ "dotnetRunMessages": true,
16
+ "launchBrowser": false,
17
+ "applicationUrl": "https://localhost:7024;http://0.0.0.0:5011",
18
+ "environmentVariables": {
19
+ "ASPNETCORE_ENVIRONMENT": "Development"
20
+ }
21
+ }
22
+ }
23
+ }
src/ClipForge.Api/appsettings.Production.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "Logging": { "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning" } },
3
+ "AllowedHosts": "*",
4
+ "ConnectionStrings": {
5
+ "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"
6
+ },
7
+ "OpenAi": {
8
+ "ApiKey": "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",
9
+ "Model": "google/gemini-2.0-flash-001",
10
+ "TtsModel": "",
11
+ "BaseUrl": "https://openrouter.ai/api/v1"
12
+ },
13
+ "Pexels": {
14
+ "ApiKey": "Q5nTHwnhC5qKv1J3iEkbFUbp3it4RjHIUfuGZ75A5f53kSq7eHoZYSgB",
15
+ "BaseUrl": "https://api.pexels.com"
16
+ },
17
+ "Storage": {
18
+ "BasePath": "/app/output",
19
+ "AudioFolder": "audio",
20
+ "VideoFolder": "videos",
21
+ "ThumbnailFolder": "thumbnails",
22
+ "SubtitleFolder": "subtitles",
23
+ "TempFolder": "temp"
24
+ }
25
+ }
src/ClipForge.Api/appsettings.json ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "Logging": { "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning" } },
3
+ "AllowedHosts": "*",
4
+ "ConnectionStrings": {
5
+ "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"
6
+ },
7
+ "OpenAi": {
8
+ "ApiKey": "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",
9
+ "Model": "google/gemini-2.0-flash-001",
10
+ "TtsModel": "",
11
+ "BaseUrl": "https://openrouter.ai/api/v1"
12
+ },
13
+ "Pexels": {
14
+ "ApiKey": "Q5nTHwnhC5qKv1J3iEkbFUbp3it4RjHIUfuGZ75A5f53kSq7eHoZYSgB",
15
+ "BaseUrl": "https://api.pexels.com"
16
+ },
17
+ "Storage": {
18
+ "BasePath": "/app/output",
19
+ "AudioFolder": "audio",
20
+ "VideoFolder": "videos",
21
+ "ThumbnailFolder": "thumbnails",
22
+ "SubtitleFolder": "subtitles",
23
+ "TempFolder": "temp"
24
+ }
25
+ }
src/ClipForge.Api/wwwroot/index.html ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="pt-BR">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>ClipForge - Gerador de Vídeos</title>
7
+ <style>
8
+ * { margin: 0; padding: 0; box-sizing: border-box; }
9
+ body {
10
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
11
+ background: #0f0f0f;
12
+ color: #fff;
13
+ min-height: 100vh;
14
+ padding: 20px;
15
+ }
16
+ .container { max-width: 600px; margin: 0 auto; }
17
+ h1 {
18
+ text-align: center;
19
+ font-size: 2rem;
20
+ margin-bottom: 8px;
21
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
22
+ -webkit-background-clip: text;
23
+ -webkit-text-fill-color: transparent;
24
+ }
25
+ .subtitle { text-align: center; color: #888; margin-bottom: 30px; font-size: 0.9rem; }
26
+ .card {
27
+ background: #1a1a2e;
28
+ border-radius: 16px;
29
+ padding: 24px;
30
+ margin-bottom: 20px;
31
+ border: 1px solid #2a2a4a;
32
+ }
33
+ .form-group { margin-bottom: 16px; }
34
+ label { display: block; margin-bottom: 6px; color: #aaa; font-size: 0.85rem; }
35
+ input, select {
36
+ width: 100%;
37
+ padding: 14px 16px;
38
+ border-radius: 10px;
39
+ border: 1px solid #333;
40
+ background: #0f0f1a;
41
+ color: #fff;
42
+ font-size: 1rem;
43
+ }
44
+ input:focus, select:focus { outline: none; border-color: #667eea; }
45
+ .btn {
46
+ width: 100%;
47
+ padding: 16px;
48
+ border: none;
49
+ border-radius: 12px;
50
+ font-size: 1.1rem;
51
+ font-weight: 600;
52
+ cursor: pointer;
53
+ transition: all 0.3s;
54
+ }
55
+ .btn-primary {
56
+ background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
57
+ color: #fff;
58
+ }
59
+ .btn-primary:hover { transform: scale(1.02); opacity: 0.9; }
60
+ .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
61
+ .status {
62
+ text-align: center;
63
+ padding: 16px;
64
+ border-radius: 10px;
65
+ margin-top: 16px;
66
+ display: none;
67
+ }
68
+ .status.loading { display: block; background: #1a1a3e; color: #667eea; }
69
+ .status.success { display: block; background: #1a3e1a; color: #4ade80; }
70
+ .status.error { display: block; background: #3e1a1a; color: #f87171; }
71
+ .spinner {
72
+ display: inline-block;
73
+ width: 20px; height: 20px;
74
+ border: 3px solid #667eea;
75
+ border-top-color: transparent;
76
+ border-radius: 50%;
77
+ animation: spin 1s linear infinite;
78
+ margin-right: 8px;
79
+ vertical-align: middle;
80
+ }
81
+ @keyframes spin { to { transform: rotate(360deg); } }
82
+ .videos-section { margin-top: 30px; }
83
+ .videos-section h2 { font-size: 1.3rem; margin-bottom: 16px; color: #ccc; }
84
+ .video-item {
85
+ background: #1a1a2e;
86
+ border-radius: 12px;
87
+ padding: 16px;
88
+ margin-bottom: 12px;
89
+ border: 1px solid #2a2a4a;
90
+ display: flex;
91
+ justify-content: space-between;
92
+ align-items: center;
93
+ gap: 12px;
94
+ }
95
+ .video-info { flex: 1; }
96
+ .video-info .title { font-weight: 600; font-size: 0.95rem; margin-bottom: 4px; }
97
+ .video-info .meta { color: #888; font-size: 0.8rem; }
98
+ .btn-download {
99
+ padding: 10px 16px;
100
+ border-radius: 8px;
101
+ background: #667eea;
102
+ color: #fff;
103
+ text-decoration: none;
104
+ font-size: 0.85rem;
105
+ font-weight: 600;
106
+ white-space: nowrap;
107
+ }
108
+ .btn-download:hover { opacity: 0.8; }
109
+ .empty { text-align: center; color: #555; padding: 20px; }
110
+ </style>
111
+ </head>
112
+ <body>
113
+ <div class="container">
114
+ <h1>🎬 ClipForge</h1>
115
+ <p class="subtitle">Gerador automático de vídeos virais com IA</p>
116
+
117
+ <div class="card">
118
+ <div class="form-group">
119
+ <label>Tema do vídeo</label>
120
+ <input type="text" id="niche" placeholder="Ex: curiosidades do filme do Michael Jackson 2025" />
121
+ </div>
122
+ <div class="form-group">
123
+ <label>Plataforma</label>
124
+ <select id="platform">
125
+ <option value="tiktok">TikTok</option>
126
+ <option value="youtube_shorts">YouTube Shorts</option>
127
+ <option value="kwai">Kwai</option>
128
+ </select>
129
+ </div>
130
+ <div class="form-group">
131
+ <label>Voz</label>
132
+ <select id="voice">
133
+ <option value="francisca">Francisca (feminina)</option>
134
+ <option value="antonio">Antonio (masculina)</option>
135
+ <option value="thalita">Thalita (jovem)</option>
136
+ </select>
137
+ </div>
138
+ <button class="btn btn-primary" id="generateBtn" onclick="generate()">🚀 Gerar Vídeo</button>
139
+ <div class="status" id="status"></div>
140
+ </div>
141
+
142
+ <div class="videos-section">
143
+ <h2>📁 Vídeos Gerados</h2>
144
+ <div id="videosList"><div class="empty">Carregando...</div></div>
145
+ </div>
146
+ </div>
147
+
148
+ <script>
149
+ const API = window.location.origin;
150
+
151
+ async function generate() {
152
+ const niche = document.getElementById('niche').value.trim();
153
+ if (!niche) { alert('Digite um tema!'); return; }
154
+
155
+ const platform = document.getElementById('platform').value;
156
+ const voice = document.getElementById('voice').value;
157
+ const btn = document.getElementById('generateBtn');
158
+ const status = document.getElementById('status');
159
+
160
+ btn.disabled = true;
161
+ status.className = 'status loading';
162
+ status.innerHTML = '<span class="spinner"></span> Gerando vídeo... isso pode levar alguns minutos';
163
+
164
+ try {
165
+ const res = await fetch(`${API}/api/pipeline/run-sync`, {
166
+ method: 'POST',
167
+ headers: { 'Content-Type': 'application/json' },
168
+ body: JSON.stringify({ niche, platform, tone: 'engaging', language: 'pt-BR', voiceId: voice })
169
+ });
170
+
171
+ if (res.ok) {
172
+ status.className = 'status success';
173
+ status.textContent = '✅ Vídeo gerado com sucesso!';
174
+ loadVideos();
175
+ } else {
176
+ const err = await res.text();
177
+ status.className = 'status error';
178
+ status.textContent = '❌ Erro: ' + err.substring(0, 100);
179
+ }
180
+ } catch (e) {
181
+ status.className = 'status error';
182
+ status.textContent = '❌ Erro de conexão: ' + e.message;
183
+ }
184
+
185
+ btn.disabled = false;
186
+ }
187
+
188
+ async function loadVideos() {
189
+ try {
190
+ const res = await fetch(`${API}/api/videos`);
191
+ const videos = await res.json();
192
+ const list = document.getElementById('videosList');
193
+
194
+ if (videos.length === 0) {
195
+ list.innerHTML = '<div class="empty">Nenhum vídeo gerado ainda</div>';
196
+ return;
197
+ }
198
+
199
+ list.innerHTML = videos.map(v => `
200
+ <div class="video-item">
201
+ <div class="video-info">
202
+ <div class="title">🎬 Vídeo ${v.id.substring(0, 8)}</div>
203
+ <div class="meta">${Math.round(v.durationSeconds)}s • ${(v.fileSizeBytes / 1024 / 1024).toFixed(1)} MB • ${new Date(v.createdAt).toLocaleString('pt-BR')}</div>
204
+ </div>
205
+ <a class="btn-download" href="${API}/api/videos/${v.id}/download" download>⬇ Baixar</a>
206
+ </div>
207
+ `).join('');
208
+ } catch (e) {
209
+ document.getElementById('videosList').innerHTML = '<div class="empty">Erro ao carregar vídeos</div>';
210
+ }
211
+ }
212
+
213
+ loadVideos();
214
+ </script>
215
+ </body>
216
+ </html>
src/ClipForge.Contracts/ClipForge.Contracts.csproj ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ <Project Sdk="Microsoft.NET.Sdk">
2
+
3
+ <PropertyGroup>
4
+ <TargetFramework>net9.0</TargetFramework>
5
+ <ImplicitUsings>enable</ImplicitUsings>
6
+ <Nullable>enable</Nullable>
7
+ </PropertyGroup>
8
+
9
+ </Project>
src/ClipForge.Contracts/Requests/AssembleVideoRequest.cs ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ namespace ClipForge.Contracts.Requests;
2
+
3
+ public record AssembleVideoRequest(
4
+ Guid ScriptId
5
+ );
src/ClipForge.Contracts/Requests/FullPipelineRequest.cs ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ namespace ClipForge.Contracts.Requests;
2
+
3
+ public record FullPipelineRequest(
4
+ string Niche,
5
+ string Platform = "tiktok",
6
+ string Tone = "engaging",
7
+ string Language = "pt-BR",
8
+ string VoiceId = "alloy"
9
+ );
src/ClipForge.Contracts/Requests/GenerateIdeaRequest.cs ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ namespace ClipForge.Contracts.Requests;
2
+
3
+ public record GenerateIdeaRequest(
4
+ string Niche,
5
+ string Platform = "tiktok",
6
+ int Count = 1
7
+ );
src/ClipForge.Contracts/Requests/GenerateScriptRequest.cs ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ namespace ClipForge.Contracts.Requests;
2
+
3
+ public record GenerateScriptRequest(
4
+ Guid IdeaId,
5
+ string Tone = "engaging",
6
+ string Language = "pt-BR"
7
+ );
src/ClipForge.Contracts/Requests/GenerateVoiceRequest.cs ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ namespace ClipForge.Contracts.Requests;
2
+
3
+ public record GenerateVoiceRequest(
4
+ Guid ScriptId,
5
+ string VoiceId = "alloy"
6
+ );
src/ClipForge.Contracts/Requests/SchedulePipelineRequest.cs ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ namespace ClipForge.Contracts.Requests;
2
+
3
+ public record SchedulePipelineRequest(
4
+ string Niche,
5
+ string Platform = "tiktok",
6
+ string? CronExpression = null
7
+ );
src/ClipForge.Contracts/Responses/PipelineStatusResponse.cs ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ namespace ClipForge.Contracts.Responses;
2
+
3
+ public record PipelineStatusResponse(
4
+ Guid IdeaId,
5
+ Guid? ScriptId,
6
+ Guid? VideoAssetId,
7
+ string CurrentStep,
8
+ string Status,
9
+ string? ErrorMessage
10
+ );
src/ClipForge.Contracts/Responses/VideoAssetResponse.cs ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ namespace ClipForge.Contracts.Responses;
2
+
3
+ public record VideoAssetResponse(
4
+ Guid Id,
5
+ Guid VideoScriptId,
6
+ string FilePath,
7
+ string ThumbnailPath,
8
+ int Width,
9
+ int Height,
10
+ double DurationSeconds,
11
+ long FileSizeBytes,
12
+ string Format,
13
+ string Status,
14
+ DateTime CreatedAt
15
+ );
src/ClipForge.Contracts/Responses/VideoIdeaResponse.cs ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ namespace ClipForge.Contracts.Responses;
2
+
3
+ public record VideoIdeaResponse(
4
+ Guid Id,
5
+ string Topic,
6
+ string Title,
7
+ string Hook,
8
+ string TargetAudience,
9
+ string Platform,
10
+ string Status,
11
+ string? Niche,
12
+ string? Tags,
13
+ DateTime CreatedAt
14
+ );
src/ClipForge.Contracts/Responses/VideoScriptResponse.cs ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ namespace ClipForge.Contracts.Responses;
2
+
3
+ public record VideoScriptResponse(
4
+ Guid Id,
5
+ Guid VideoIdeaId,
6
+ string ScriptText,
7
+ string Scenes,
8
+ int EstimatedDurationSeconds,
9
+ string Tone,
10
+ string Language,
11
+ DateTime CreatedAt
12
+ );
src/ClipForge.Core/ClipForge.Core.csproj ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ <Project Sdk="Microsoft.NET.Sdk">
2
+
3
+ <PropertyGroup>
4
+ <TargetFramework>net9.0</TargetFramework>
5
+ <ImplicitUsings>enable</ImplicitUsings>
6
+ <Nullable>enable</Nullable>
7
+ </PropertyGroup>
8
+
9
+ </Project>
src/ClipForge.Core/Entities/BaseEntity.cs ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ namespace ClipForge.Core.Entities;
2
+
3
+ public abstract class BaseEntity
4
+ {
5
+ public Guid Id { get; set; } = Guid.NewGuid();
6
+ public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
7
+ public DateTime? UpdatedAt { get; set; }
8
+ }
src/ClipForge.Core/Entities/CaptionAsset.cs ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ namespace ClipForge.Core.Entities;
2
+
3
+ public class CaptionAsset : BaseEntity
4
+ {
5
+ public Guid VideoAssetId { get; set; }
6
+ public string SrtFilePath { get; set; } = string.Empty;
7
+ public string CaptionStyle { get; set; } = "dynamic"; // dynamic, static, karaoke
8
+ public string FontFamily { get; set; } = "Montserrat";
9
+ public int FontSize { get; set; } = 48;
10
+ public string FontColor { get; set; } = "#FFFFFF";
11
+ public string StrokeColor { get; set; } = "#000000";
12
+ public int StrokeWidth { get; set; } = 2;
13
+
14
+ // Navigation
15
+ public VideoAsset? VideoAsset { get; set; }
16
+ }
src/ClipForge.Core/Entities/PublishJob.cs ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ namespace ClipForge.Core.Entities;
2
+
3
+ public class PublishJob : BaseEntity
4
+ {
5
+ public Guid VideoAssetId { get; set; }
6
+ public Guid? SocialAccountId { get; set; }
7
+ public string Platform { get; set; } = "tiktok"; // tiktok, youtube_shorts, kwai
8
+ public string Status { get; set; } = "pending"; // pending, scheduled, publishing, published, failed
9
+ public DateTime? ScheduledAt { get; set; }
10
+ public DateTime? PublishedAt { get; set; }
11
+ public string? ExternalId { get; set; }
12
+ public string? ErrorMessage { get; set; }
13
+ public string? Caption { get; set; }
14
+ public string? Hashtags { get; set; }
15
+
16
+ // Navigation
17
+ public VideoAsset? VideoAsset { get; set; }
18
+ public SocialAccount? SocialAccount { get; set; }
19
+ }
src/ClipForge.Core/Entities/SocialAccount.cs ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ namespace ClipForge.Core.Entities;
2
+
3
+ public class SocialAccount : BaseEntity
4
+ {
5
+ public string Platform { get; set; } = "tiktok";
6
+ public string AccountName { get; set; } = string.Empty;
7
+ public string? AccessToken { get; set; }
8
+ public string? RefreshToken { get; set; }
9
+ public DateTime? TokenExpiresAt { get; set; }
10
+ public bool IsActive { get; set; } = true;
11
+
12
+ // Navigation
13
+ public List<PublishJob> PublishJobs { get; set; } = [];
14
+ }
src/ClipForge.Core/Entities/VideoAsset.cs ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ namespace ClipForge.Core.Entities;
2
+
3
+ public class VideoAsset : BaseEntity
4
+ {
5
+ public Guid VideoScriptId { get; set; }
6
+ public string FilePath { get; set; } = string.Empty;
7
+ public string ThumbnailPath { get; set; } = string.Empty;
8
+ public int Width { get; set; } = 1080;
9
+ public int Height { get; set; } = 1920;
10
+ public double DurationSeconds { get; set; }
11
+ public long FileSizeBytes { get; set; }
12
+ public string Format { get; set; } = "mp4";
13
+ public string Status { get; set; } = "processing"; // processing, completed, failed
14
+
15
+ // Navigation
16
+ public VideoScript? VideoScript { get; set; }
17
+ public CaptionAsset? CaptionAsset { get; set; }
18
+ public List<PublishJob> PublishJobs { get; set; } = [];
19
+ }
src/ClipForge.Core/Entities/VideoIdea.cs ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ namespace ClipForge.Core.Entities;
2
+
3
+ public class VideoIdea : BaseEntity
4
+ {
5
+ public string Topic { get; set; } = string.Empty;
6
+ public string Title { get; set; } = string.Empty;
7
+ public string Hook { get; set; } = string.Empty;
8
+ public string TargetAudience { get; set; } = string.Empty;
9
+ public string Platform { get; set; } = "tiktok"; // tiktok, youtube_shorts, kwai
10
+ public string Status { get; set; } = "pending"; // pending, scripted, completed, failed
11
+ public string? Niche { get; set; }
12
+ public string? Tags { get; set; }
13
+
14
+ // Navigation
15
+ public VideoScript? Script { get; set; }
16
+ }
src/ClipForge.Core/Entities/VideoScript.cs ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ namespace ClipForge.Core.Entities;
2
+
3
+ public class VideoScript : BaseEntity
4
+ {
5
+ public Guid VideoIdeaId { get; set; }
6
+ public string ScriptText { get; set; } = string.Empty;
7
+ public string Scenes { get; set; } = string.Empty; // JSON array of scene descriptions
8
+ public int EstimatedDurationSeconds { get; set; }
9
+ public string Tone { get; set; } = "engaging"; // engaging, funny, dramatic, informative
10
+ public string Language { get; set; } = "pt-BR";
11
+
12
+ // Navigation
13
+ public VideoIdea? VideoIdea { get; set; }
14
+ public VoiceAsset? VoiceAsset { get; set; }
15
+ public VideoAsset? VideoAsset { get; set; }
16
+ }
src/ClipForge.Core/Entities/VoiceAsset.cs ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ namespace ClipForge.Core.Entities;
2
+
3
+ public class VoiceAsset : BaseEntity
4
+ {
5
+ public Guid VideoScriptId { get; set; }
6
+ public string FilePath { get; set; } = string.Empty;
7
+ public string VoiceProvider { get; set; } = "openai"; // openai, elevenlabs
8
+ public string VoiceId { get; set; } = "alloy";
9
+ public double DurationSeconds { get; set; }
10
+ public long FileSizeBytes { get; set; }
11
+
12
+ // Navigation
13
+ public VideoScript? VideoScript { get; set; }
14
+ }
src/ClipForge.Core/Interfaces/IRepository.cs ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ using ClipForge.Core.Entities;
2
+
3
+ namespace ClipForge.Core.Interfaces;
4
+
5
+ public interface IRepository<T> where T : BaseEntity
6
+ {
7
+ Task<T?> GetByIdAsync(Guid id, CancellationToken ct = default);
8
+ Task<IReadOnlyList<T>> GetAllAsync(CancellationToken ct = default);
9
+ Task<T> AddAsync(T entity, CancellationToken ct = default);
10
+ Task UpdateAsync(T entity, CancellationToken ct = default);
11
+ Task DeleteAsync(Guid id, CancellationToken ct = default);
12
+ }
src/ClipForge.Core/Interfaces/IVideoAssetRepository.cs ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ using ClipForge.Core.Entities;
2
+
3
+ namespace ClipForge.Core.Interfaces;
4
+
5
+ public interface IVideoAssetRepository : IRepository<VideoAsset>
6
+ {
7
+ Task<IReadOnlyList<VideoAsset>> GetByStatusAsync(string status, CancellationToken ct = default);
8
+ Task<VideoAsset?> GetByScriptIdAsync(Guid scriptId, CancellationToken ct = default);
9
+ }
src/ClipForge.Core/Interfaces/IVideoIdeaRepository.cs ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ using ClipForge.Core.Entities;
2
+
3
+ namespace ClipForge.Core.Interfaces;
4
+
5
+ public interface IVideoIdeaRepository : IRepository<VideoIdea>
6
+ {
7
+ Task<IReadOnlyList<VideoIdea>> GetByStatusAsync(string status, CancellationToken ct = default);
8
+ Task<IReadOnlyList<VideoIdea>> GetByNicheAsync(string niche, CancellationToken ct = default);
9
+ }
src/ClipForge.Core/Interfaces/IVideoScriptRepository.cs ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ using ClipForge.Core.Entities;
2
+
3
+ namespace ClipForge.Core.Interfaces;
4
+
5
+ public interface IVideoScriptRepository : IRepository<VideoScript>
6
+ {
7
+ Task<VideoScript?> GetByIdeaIdAsync(Guid ideaId, CancellationToken ct = default);
8
+ }
src/ClipForge.Core/Interfaces/Services/IFfmpegService.cs ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ namespace ClipForge.Core.Interfaces.Services;
2
+
3
+ public interface IFfmpegService
4
+ {
5
+ Task<string> AssembleVerticalVideoAsync(string audioPath, IReadOnlyList<string> backgroundClips, string outputPath, CancellationToken ct = default);
6
+ Task<string> AddSubtitlesToVideoAsync(string videoPath, string srtPath, string outputPath, CancellationToken ct = default);
7
+ Task<double> GetMediaDurationAsync(string filePath, CancellationToken ct = default);
8
+ Task<string> GenerateThumbnailAsync(string videoPath, string outputPath, double atSecond = 1.0, CancellationToken ct = default);
9
+ }
src/ClipForge.Core/Interfaces/Services/IIdeaGenerationService.cs ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ using ClipForge.Core.Entities;
2
+
3
+ namespace ClipForge.Core.Interfaces.Services;
4
+
5
+ public interface IIdeaGenerationService
6
+ {
7
+ Task<VideoIdea> GenerateIdeaAsync(string niche, string platform = "tiktok", CancellationToken ct = default);
8
+ Task<IReadOnlyList<VideoIdea>> GenerateBatchIdeasAsync(string niche, int count = 5, string platform = "tiktok", CancellationToken ct = default);
9
+ }
src/ClipForge.Core/Interfaces/Services/IOpenAiClient.cs ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ namespace ClipForge.Core.Interfaces.Services;
2
+
3
+ public interface IOpenAiClient
4
+ {
5
+ Task<string> GenerateChatCompletionAsync(string systemPrompt, string userPrompt, CancellationToken ct = default);
6
+ Task<byte[]> GenerateSpeechAsync(string text, string voice = "alloy", CancellationToken ct = default);
7
+ }
src/ClipForge.Core/Interfaces/Services/ISchedulerService.cs ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ namespace ClipForge.Core.Interfaces.Services;
2
+
3
+ public interface ISchedulerService
4
+ {
5
+ Task ScheduleFullPipelineAsync(string niche, string platform = "tiktok", CancellationToken ct = default);
6
+ Task ScheduleRecurringGenerationAsync(string niche, string cronExpression, string platform = "tiktok", CancellationToken ct = default);
7
+ Task CancelRecurringJobAsync(string jobId, CancellationToken ct = default);
8
+ }
src/ClipForge.Core/Interfaces/Services/IScriptGenerationService.cs ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ using ClipForge.Core.Entities;
2
+
3
+ namespace ClipForge.Core.Interfaces.Services;
4
+
5
+ public interface IScriptGenerationService
6
+ {
7
+ Task<VideoScript> GenerateScriptAsync(Guid ideaId, CancellationToken ct = default);
8
+ Task<VideoScript> GenerateScriptFromTopicAsync(string topic, string tone = "engaging", string language = "pt-BR", CancellationToken ct = default);
9
+ }
src/ClipForge.Core/Interfaces/Services/IStockMediaService.cs ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ namespace ClipForge.Core.Interfaces.Services;
2
+
3
+ public interface IStockMediaService
4
+ {
5
+ Task<string> DownloadVideoAsync(string query, string outputDir, CancellationToken ct = default);
6
+ Task<IReadOnlyList<string>> DownloadMultipleVideosAsync(string query, int count, string outputDir, CancellationToken ct = default);
7
+ }
src/ClipForge.Core/Interfaces/Services/ISubtitleService.cs ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ using ClipForge.Core.Entities;
2
+
3
+ namespace ClipForge.Core.Interfaces.Services;
4
+
5
+ public interface ISubtitleService
6
+ {
7
+ Task<CaptionAsset> GenerateSubtitlesAsync(Guid videoAssetId, CancellationToken ct = default);
8
+ Task<string> GenerateSrtFromTextAsync(string text, double totalDuration, CancellationToken ct = default);
9
+ }
src/ClipForge.Core/Interfaces/Services/IVideoAssemblyService.cs ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ using ClipForge.Core.Entities;
2
+
3
+ namespace ClipForge.Core.Interfaces.Services;
4
+
5
+ public interface IVideoAssemblyService
6
+ {
7
+ Task<VideoAsset> AssembleVideoAsync(Guid scriptId, CancellationToken ct = default);
8
+ }
src/ClipForge.Core/Interfaces/Services/IVoiceGenerationService.cs ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ using ClipForge.Core.Entities;
2
+
3
+ namespace ClipForge.Core.Interfaces.Services;
4
+
5
+ public interface IVoiceGenerationService
6
+ {
7
+ Task<VoiceAsset> GenerateVoiceAsync(Guid scriptId, string voiceId = "alloy", CancellationToken ct = default);
8
+ }
src/ClipForge.Infrastructure/ClipForge.Infrastructure.csproj ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <Project Sdk="Microsoft.NET.Sdk">
2
+
3
+ <ItemGroup>
4
+ <ProjectReference Include="..\ClipForge.Core\ClipForge.Core.csproj" />
5
+ <ProjectReference Include="..\ClipForge.Contracts\ClipForge.Contracts.csproj" />
6
+ </ItemGroup>
7
+
8
+ <ItemGroup>
9
+ <PackageReference Include="Hangfire.Core" Version="1.8.17" />
10
+ <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.1">
11
+ <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
12
+ <PrivateAssets>all</PrivateAssets>
13
+ </PackageReference>
14
+ <PackageReference Include="Microsoft.Extensions.Http" Version="9.0.1" />
15
+ <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="9.0.1" />
16
+ <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
17
+ </ItemGroup>
18
+
19
+ <PropertyGroup>
20
+ <TargetFramework>net9.0</TargetFramework>
21
+ <ImplicitUsings>enable</ImplicitUsings>
22
+ <Nullable>enable</Nullable>
23
+ </PropertyGroup>
24
+
25
+ </Project>
src/ClipForge.Infrastructure/Configuration/OpenAiSettings.cs ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ namespace ClipForge.Infrastructure.Configuration;
2
+
3
+ public class OpenAiSettings
4
+ {
5
+ public const string SectionName = "OpenAi";
6
+ public string ApiKey { get; set; } = string.Empty;
7
+ public string Model { get; set; } = "llama-3.3-70b-versatile";
8
+ public string TtsModel { get; set; } = "tts-1";
9
+ public string BaseUrl { get; set; } = "https://api.groq.com/openai/v1";
10
+ }
src/ClipForge.Infrastructure/Configuration/PexelsSettings.cs ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ namespace ClipForge.Infrastructure.Configuration;
2
+
3
+ public class PexelsSettings
4
+ {
5
+ public const string SectionName = "Pexels";
6
+ public string ApiKey { get; set; } = string.Empty;
7
+ public string BaseUrl { get; set; } = "https://api.pexels.com";
8
+ }
src/ClipForge.Infrastructure/Configuration/StorageSettings.cs ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ namespace ClipForge.Infrastructure.Configuration;
2
+
3
+ public class StorageSettings
4
+ {
5
+ public const string SectionName = "Storage";
6
+ public string BasePath { get; set; } = "./output";
7
+ public string AudioFolder { get; set; } = "audio";
8
+ public string VideoFolder { get; set; } = "videos";
9
+ public string ThumbnailFolder { get; set; } = "thumbnails";
10
+ public string SubtitleFolder { get; set; } = "subtitles";
11
+ public string TempFolder { get; set; } = "temp";
12
+ }