Skip to content

Open source alternatives to paid SaaS apps: Notion, Slack, Auth0, Vercel and more. Curated list with licenses and GitHub stars.

Add FastAPI backend and Next.js client for AI YouTube Shorts Generator

Jaya Prasad Kavurud4a4553a9327
diff --git a/video_generation/AI-Youtube-Shorts-Generator/client/.gitignore b/video_generation/AI-Youtube-Shorts-Generator/client/.gitignore
new file mode 100644
index 0000000..fcba1c5
--- /dev/null
+++ b/video_generation/AI-Youtube-Shorts-Generator/client/.gitignore
@@ -0,0 +1,42 @@
+# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
+
+# dependencies
+/node_modules
+/.pnp
+.pnp.*
+.yarn/*
+!.yarn/patches
+!.yarn/plugins
+!.yarn/releases
+!.yarn/versions
+
+# testing
+/coverage
+
+# next.js
+/.next/
+/out/
+
+# production
+/build
+
+# misc
+.DS_Store
+*.pem
+
+# debug
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+.pnpm-debug.log*
+
+# env files (can opt-in for committing if needed)
+.env*
+
+# vercel
+.vercel
+
+# typescript
+*.tsbuildinfo
+next-env.d.ts
+package-lock.json
\ No newline at end of file
diff --git a/video_generation/AI-Youtube-Shorts-Generator/client/AGENTS.md b/video_generation/AI-Youtube-Shorts-Generator/client/AGENTS.md
new file mode 100644
index 0000000..8bd0e39
--- /dev/null
+++ b/video_generation/AI-Youtube-Shorts-Generator/client/AGENTS.md
@@ -0,0 +1,5 @@
+<!-- BEGIN:nextjs-agent-rules -->
+# This is NOT the Next.js you know
+
+This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` before writing any code. Heed deprecation notices.
+<!-- END:nextjs-agent-rules -->
diff --git a/video_generation/AI-Youtube-Shorts-Generator/client/CLAUDE.md b/video_generation/AI-Youtube-Shorts-Generator/client/CLAUDE.md
new file mode 100644
index 0000000..43c994c
--- /dev/null
+++ b/video_generation/AI-Youtube-Shorts-Generator/client/CLAUDE.md
@@ -0,0 +1 @@
diff --git a/video_generation/AI-Youtube-Shorts-Generator/client/README.md b/video_generation/AI-Youtube-Shorts-Generator/client/README.md
new file mode 100644
index 0000000..66bb426
--- /dev/null
+++ b/video_generation/AI-Youtube-Shorts-Generator/client/README.md
@@ -0,0 +1,36 @@
+This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
+
+## Getting Started
+
+First, run the development server:
+
+```bash
+npm run dev
+# or
+yarn dev
+# or
+pnpm dev
+# or
+bun dev
+```
+
+Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
+
+You can start editing the page by modifying `app/page.js`. The page auto-updates as you edit the file.
+
+This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
+
+## Learn More
+
+To learn more about Next.js, take a look at the following resources:
+
+- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
+- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
+
+You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
+
+## Deploy on Vercel
+
+The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
+
+Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
diff --git a/video_generation/AI-Youtube-Shorts-Generator/client/eslint.config.mjs b/video_generation/AI-Youtube-Shorts-Generator/client/eslint.config.mjs
new file mode 100644
index 0000000..f443835
--- /dev/null
+++ b/video_generation/AI-Youtube-Shorts-Generator/client/eslint.config.mjs
@@ -0,0 +1,16 @@
+import { defineConfig, globalIgnores } from "eslint/config";
+import nextVitals from "eslint-config-next/core-web-vitals";
+
+const eslintConfig = defineConfig([
+ ...nextVitals,
+ // Override default ignores of eslint-config-next.
+ globalIgnores([
+ // Default ignores of eslint-config-next:
+ ".next/**",
+ "out/**",
+ "build/**",
+ "next-env.d.ts",
+ ]),
+]);
+
+export default eslintConfig;
diff --git a/video_generation/AI-Youtube-Shorts-Generator/client/jsconfig.json b/video_generation/AI-Youtube-Shorts-Generator/client/jsconfig.json
new file mode 100644
index 0000000..b8d6842
--- /dev/null
+++ b/video_generation/AI-Youtube-Shorts-Generator/client/jsconfig.json
@@ -0,0 +1,7 @@
+{
+ "compilerOptions": {
+ "paths": {
+ "@/*": ["./src/*"]
+ }
+ }
+}
diff --git a/video_generation/AI-Youtube-Shorts-Generator/client/next.config.mjs b/video_generation/AI-Youtube-Shorts-Generator/client/next.config.mjs
new file mode 100644
index 0000000..b108e1a
--- /dev/null
+++ b/video_generation/AI-Youtube-Shorts-Generator/client/next.config.mjs
@@ -0,0 +1,6 @@
+/** @type {import('next').NextConfig} */
+const nextConfig = {
+ /* config options here */
+};
+
+export default nextConfig;
diff --git a/video_generation/AI-Youtube-Shorts-Generator/client/package.json b/video_generation/AI-Youtube-Shorts-Generator/client/package.json
new file mode 100644
index 0000000..95be303
--- /dev/null
+++ b/video_generation/AI-Youtube-Shorts-Generator/client/package.json
@@ -0,0 +1,22 @@
+{
+ "name": "client",
+ "version": "0.1.0",
+ "private": true,
+ "scripts": {
+ "dev": "next dev",
+ "build": "next build",
+ "start": "next start",
+ "lint": "eslint"
+ },
+ "dependencies": {
+ "next": "16.2.10",
+ "react": "19.2.4",
+ "react-dom": "19.2.4"
+ },
+ "devDependencies": {
+ "@tailwindcss/postcss": "^4",
+ "eslint": "^9",
+ "eslint-config-next": "16.2.10",
+ "tailwindcss": "^4"
+ }
+}
diff --git a/video_generation/AI-Youtube-Shorts-Generator/client/postcss.config.mjs b/video_generation/AI-Youtube-Shorts-Generator/client/postcss.config.mjs
new file mode 100644
index 0000000..61e3684
--- /dev/null
+++ b/video_generation/AI-Youtube-Shorts-Generator/client/postcss.config.mjs
@@ -0,0 +1,7 @@
+const config = {
+ plugins: {
+ "@tailwindcss/postcss": {},
+ },
+};
+
+export default config;
diff --git a/video_generation/AI-Youtube-Shorts-Generator/client/public/file.svg b/video_generation/AI-Youtube-Shorts-Generator/client/public/file.svg
new file mode 100644
index 0000000..004145c
--- /dev/null
+++ b/video_generation/AI-Youtube-Shorts-Generator/client/public/file.svg
@@ -0,0 +1 @@
+<svg fill="none" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 13.5V5.41a1 1 0 0 0-.3-.7L9.8.29A1 1 0 0 0 9.08 0H1.5v13.5A2.5 2.5 0 0 0 4 16h8a2.5 2.5 0 0 0 2.5-2.5m-1.5 0v-7H8v-5H3v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1M9.5 5V2.12L12.38 5zM5.13 5h-.62v1.25h2.12V5zm-.62 3h7.12v1.25H4.5zm.62 3h-.62v1.25h7.12V11z" clip-rule="evenodd" fill="#666" fill-rule="evenodd"/></svg>
\ No newline at end of file
diff --git a/video_generation/AI-Youtube-Shorts-Generator/client/public/globe.svg b/video_generation/AI-Youtube-Shorts-Generator/client/public/globe.svg
new file mode 100644
index 0000000..567f17b
--- /dev/null
+++ b/video_generation/AI-Youtube-Shorts-Generator/client/public/globe.svg
@@ -0,0 +1 @@
+<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g clip-path="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.27 14.1a6.5 6.5 0 0 0 3.67-3.45q-1.24.21-2.7.34-.31 1.83-.97 3.1M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.48-1.52a7 7 0 0 1-.96 0H7.5a4 4 0 0 1-.84-1.32q-.38-.89-.63-2.08a40 40 0 0 0 3.92 0q-.25 1.2-.63 2.08a4 4 0 0 1-.84 1.31zm2.94-4.76q1.66-.15 2.95-.43a7 7 0 0 0 0-2.58q-1.3-.27-2.95-.43a18 18 0 0 1 0 3.44m-1.27-3.54a17 17 0 0 1 0 3.64 39 39 0 0 1-4.3 0 17 17 0 0 1 0-3.64 39 39 0 0 1 4.3 0m1.1-1.17q1.45.13 2.69.34a6.5 6.5 0 0 0-3.67-3.44q.65 1.26.98 3.1M8.48 1.5l.01.02q.41.37.84 1.31.38.89.63 2.08a40 40 0 0 0-3.92 0q.25-1.2.63-2.08a4 4 0 0 1 .85-1.32 7 7 0 0 1 .96 0m-2.75.4a6.5 6.5 0 0 0-3.67 3.44 29 29 0 0 1 2.7-.34q.31-1.83.97-3.1M4.58 6.28q-1.66.16-2.95.43a7 7 0 0 0 0 2.58q1.3.27 2.95.43a18 18 0 0 1 0-3.44m.17 4.71q-1.45-.12-2.69-.34a6.5 6.5 0 0 0 3.67 3.44q-.65-1.27-.98-3.1" fill="#666"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></svg>
\ No newline at end of file
diff --git a/video_generation/AI-Youtube-Shorts-Generator/client/public/next.svg b/video_generation/AI-Youtube-Shorts-Generator/client/public/next.svg
new file mode 100644
index 0000000..5174b28
--- /dev/null
+++ b/video_generation/AI-Youtube-Shorts-Generator/client/public/next.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>
\ No newline at end of file
diff --git a/video_generation/AI-Youtube-Shorts-Generator/client/public/vercel.svg b/video_generation/AI-Youtube-Shorts-Generator/client/public/vercel.svg
new file mode 100644
index 0000000..7705396
--- /dev/null
+++ b/video_generation/AI-Youtube-Shorts-Generator/client/public/vercel.svg
@@ -0,0 +1 @@
+<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1155 1000"><path d="m577.3 0 577.4 1000H0z" fill="#fff"/></svg>
\ No newline at end of file
diff --git a/video_generation/AI-Youtube-Shorts-Generator/client/public/window.svg b/video_generation/AI-Youtube-Shorts-Generator/client/public/window.svg
new file mode 100644
index 0000000..b2b2a44
--- /dev/null
+++ b/video_generation/AI-Youtube-Shorts-Generator/client/public/window.svg
@@ -0,0 +1 @@
+<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 2.5h13v10a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1zM0 1h16v11.5a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 0 12.5zm3.75 4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5M7 4.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0m1.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5" fill="#666"/></svg>
\ No newline at end of file
diff --git a/video_generation/AI-Youtube-Shorts-Generator/client/src/app/favicon.ico b/video_generation/AI-Youtube-Shorts-Generator/client/src/app/favicon.ico
new file mode 100644
index 0000000..718d6fe
Binary files /dev/null and b/video_generation/AI-Youtube-Shorts-Generator/client/src/app/favicon.ico differ
diff --git a/video_generation/AI-Youtube-Shorts-Generator/client/src/app/globals.css b/video_generation/AI-Youtube-Shorts-Generator/client/src/app/globals.css
new file mode 100644
index 0000000..a2dc41e
--- /dev/null
+++ b/video_generation/AI-Youtube-Shorts-Generator/client/src/app/globals.css
@@ -0,0 +1,26 @@
+@import "tailwindcss";
+
+:root {
+ --background: #ffffff;
+ --foreground: #171717;
+}
+
+@theme inline {
+ --color-background: var(--background);
+ --color-foreground: var(--foreground);
+ --font-sans: var(--font-geist-sans);
+ --font-mono: var(--font-geist-mono);
+}
+
+@media (prefers-color-scheme: dark) {
+ :root {
+ --background: #0a0a0a;
+ --foreground: #ededed;
+ }
+}
+
+body {
+ background: var(--background);
+ color: var(--foreground);
+ font-family: Arial, Helvetica, sans-serif;
+}
diff --git a/video_generation/AI-Youtube-Shorts-Generator/client/src/app/layout.js b/video_generation/AI-Youtube-Shorts-Generator/client/src/app/layout.js
new file mode 100644
index 0000000..dbc1eca
--- /dev/null
+++ b/video_generation/AI-Youtube-Shorts-Generator/client/src/app/layout.js
@@ -0,0 +1,28 @@
+import { Geist, Geist_Mono } from "next/font/google";
+import "./globals.css";
+
+const geistSans = Geist({
+ variable: "--font-geist-sans",
+ subsets: ["latin"],
+});
+
+const geistMono = Geist_Mono({
+ variable: "--font-geist-mono",
+ subsets: ["latin"],
+});
+
+export const metadata = {
+ title: "Create Next App",
+ description: "Generated by create next app",
+};
+
+export default function RootLayout({ children }) {
+ return (
+ <html
+ lang="en"
+ className={`${geistSans.variable} ${geistMono.variable} h-full antialiased`}
+ >
+ <body className="min-h-full flex flex-col">{children}</body>
+ </html>
+ );
+}
diff --git a/video_generation/AI-Youtube-Shorts-Generator/client/src/app/page.js b/video_generation/AI-Youtube-Shorts-Generator/client/src/app/page.js
new file mode 100644
index 0000000..a9dd725
--- /dev/null
+++ b/video_generation/AI-Youtube-Shorts-Generator/client/src/app/page.js
@@ -0,0 +1,478 @@
+"use client";
+
+import { useState, useEffect, useRef } from "react";
+
+export default function Home() {
+ const [url, setUrl] = useState("");
+ const [mode, setMode] = useState("api"); // api or local
+ const [numClips, setNumClips] = useState(3);
+ const [aspectRatio, setAspectRatio] = useState("9:16");
+ const [jobId, setJobId] = useState(null);
+ const [jobStatus, setJobStatus] = useState("idle"); // idle, processing, completed, failed
+ const [logs, setLogs] = useState([]);
+ const [result, setResult] = useState(null);
+ const [errorMsg, setErrorMsg] = useState("");
+ const [selectedClipIndex, setSelectedClipIndex] = useState(0);
+
+ const logsEndRef = useRef(null);
+ const pollIntervalRef = useRef(null);
+
+ // Auto-scroll logs to bottom
+ useEffect(() => {
+ logsEndRef.current?.scrollIntoView({ behavior: "smooth" });
+ }, [logs]);
+
+ // Clean up polling on unmount
+ useEffect(() => {
+ return () => {
+ if (pollIntervalRef.current) clearInterval(pollIntervalRef.current);
+ };
+ }, []);
+
+ const startJob = async (e) => {
+ e.preventDefault();
+ if (!url.trim()) return;
+
+ setErrorMsg("");
+ setLogs(["Submitting job..."]);
+ setJobStatus("processing");
+ setResult(null);
+ setSelectedClipIndex(0);
+
+ try {
+ const response = await fetch("http://localhost:8000/api/generate", {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ },
+ body: JSON.stringify({
+ url: url.trim(),
+ mode,
+ num_clips: parseInt(numClips),
+ aspect_ratio: aspectRatio,
+ }),
+ });
+
+ if (!response.ok) {
+ throw new Error(`HTTP Error: ${response.status} - ${response.statusText}`);
+ }
+
+ const data = await response.json();
+ setJobId(data.job_id);
+ startPolling(data.job_id);
+ } catch (err) {
+ console.error(err);
+ setErrorMsg(err.message || "Failed to start generation job.");
+ setJobStatus("failed");
+ }
+ };
+
+ const startPolling = (id) => {
+ if (pollIntervalRef.current) clearInterval(pollIntervalRef.current);
+
+ pollIntervalRef.current = setInterval(async () => {
+ try {
+ const response = await fetch(`http://localhost:8000/api/jobs/${id}`);
+ if (!response.ok) {
+ throw new Error("Failed to fetch job status");
+ }
+
+ const job = await response.json();
+ setLogs(job.logs || []);
+
+ if (job.status === "completed") {
+ setJobStatus("completed");
+ setResult(job.result);
+ clearInterval(pollIntervalRef.current);
+ } else if (job.status === "failed") {
+ setJobStatus("failed");
+ setErrorMsg(job.error || "The AI processing pipeline failed.");
+ clearInterval(pollIntervalRef.current);
+ }
+ } catch (err) {
+ console.error("Polling error:", err);
+ }
+ }, 2000); // Poll every 2 seconds
+ };
+
+ const cancelJob = () => {
+ if (pollIntervalRef.current) {
+ clearInterval(pollIntervalRef.current);
+ }
+ setJobStatus("idle");
+ setJobId(null);
+ setLogs([]);
+ };
+
+ const getProgressStage = () => {
+ // Basic heuristic helper based on keywords in logs to display progress checkboxes
+ const joinedLogs = logs.join("\n").toLowerCase();
+ const stages = {
+ download: joinedLogs.includes("downloading") || joinedLogs.includes("finished downloading") || joinedLogs.includes("yt-dlp") || joinedLogs.includes("whisper") || joinedLogs.includes("clipping") || joinedLogs.includes("highlights"),
+ transcribe: joinedLogs.includes("transcrib") || joinedLogs.includes("finished transcrib") || joinedLogs.includes("highlights") || joinedLogs.includes("clipping"),
+ analyze: joinedLogs.includes("highlight") || joinedLogs.includes("gpt") || joinedLogs.includes("gemini") || joinedLogs.includes("clipping"),
+ render: joinedLogs.includes("crop") || joinedLogs.includes("clipp") || joinedLogs.includes("render") || joinedLogs.includes("finish")
+ };
+ return stages;
+ };
+
+ const stages = getProgressStage();
+ const currentClip = result?.shorts?.[selectedClipIndex];
+
+ return (
+ <div className="min-h-screen bg-zinc-950 text-zinc-50 flex flex-col font-sans relative overflow-x-hidden">
+ {/* Glow Effects */}
+ <div className="absolute top-0 right-1/4 w-96 h-96 bg-purple-500/10 rounded-full filter blur-[80px] pointer-events-none" />
+ <div className="absolute bottom-0 left-1/4 w-96 h-96 bg-indigo-500/10 rounded-full filter blur-[80px] pointer-events-none" />
+
+ {/* Header */}
+ <header className="border-b border-zinc-800/80 bg-zinc-900/40 backdrop-blur-md py-4 px-6 md:px-12 flex justify-between items-center z-10">
+ <div className="flex items-center gap-3">
+ <svg className="w-6 h-6 text-purple-500 animate-pulse" fill="currentColor" viewBox="0 0 24 24">
+ <path d="M23 12l-2.44-2.79.34-3.69-3.61-.82-1.89-3.2L12 2.96 8.94 1.5 7.05 4.7 3.44 5.52l.34 3.69L1.35 12l2.43 2.79-.34 3.69 3.61.82 1.89 3.2L12 21.04l3.06 1.46 1.89-3.2 3.61-.82-.34-3.69L23 12zm-12.91 4.72l-3.8-3.81 1.48-1.48 2.32 2.33 5.85-5.87 1.48 1.48-7.33 7.35z"/>
+ </svg>
+ <h1 className="text-xl font-bold tracking-tight bg-gradient-to-r from-purple-400 to-indigo-300 bg-clip-text text-transparent">
+ ShortsGenerator <span className="text-zinc-500 font-light font-sans text-sm">AI Video Clipper</span>
+ </h1>
+ </div>
+ <div>
+ <span className="text-xs px-2.5 py-1 rounded-full bg-zinc-800 border border-zinc-700 text-zinc-400 font-medium">
+ FastAPI + Next.js
+ </span>
+ </div>
+ </header>
+
+ {/* Main Container */}
+ <main className="flex-1 max-w-7xl w-full mx-auto p-4 md:p-8 flex flex-col z-10 gap-6 overflow-hidden">
+
+ {/* State: Idle / Form Input */}
+ {jobStatus === "idle" && (
+ <section className="max-w-2xl w-full mx-auto bg-zinc-900/60 border border-zinc-800/80 rounded-2xl p-6 md:p-8 backdrop-blur-md shadow-2xl">
+ <div className="text-center mb-6">
+ <h2 className="text-2xl font-bold text-zinc-150 tracking-tight">Create Viral Shorts Instantly</h2>
+ <p className="text-sm text-zinc-400 mt-2">
+ Drop in any YouTube video link or local path. AI will transcribe, detect the best clips, score their virality, and render them vertically.
+ </p>
+ </div>
+
+ <form onSubmit={startJob} className="space-y-6">
+ {/* URL Input */}
+ <div className="space-y-2">
+ <label className="text-sm font-semibold text-zinc-300">YouTube URL or Path</label>
+ <input
+ type="text"
+ required
+ placeholder="https://www.youtube.com/watch?v=..."
+ value={url}
+ onChange={(e) => setUrl(e.target.value)}
+ className="w-full bg-zinc-950/80 border border-zinc-800 focus:border-purple-500 focus:ring-1 focus:ring-purple-500 rounded-xl py-3 px-4 text-sm text-zinc-100 placeholder-zinc-600 outline-none transition-all"
+ />
+ </div>
+
+ {/* Advanced Settings Row */}
+ <div className="grid grid-cols-1 md:grid-cols-3 gap-4">
+ {/* Mode Selector */}
+ <div className="space-y-2">
+ <label className="text-xs font-semibold text-zinc-400 uppercase tracking-wider">Processing Mode</label>
+ <select
+ value={mode}
+ onChange={(e) => setMode(e.target.value)}
+ className="w-full bg-zinc-950/80 border border-zinc-800 focus:border-purple-500 focus:ring-1 focus:ring-purple-500 rounded-xl py-2.5 px-3 text-sm text-zinc-200 outline-none transition-all"
+ >
+ <option value="api">Cloud API (MuAPI)</option>
+ <option value="local">Local (Offline)</option>
+ </select>
+ </div>
+
+ {/* Aspect Ratio */}
+ <div className="space-y-2">
+ <label className="text-xs font-semibold text-zinc-400 uppercase tracking-wider">Aspect Ratio</label>
+ <select
+ value={aspectRatio}
+ onChange={(e) => setAspectRatio(e.target.value)}
+ className="w-full bg-zinc-950/80 border border-zinc-800 focus:border-purple-500 focus:ring-1 focus:ring-purple-500 rounded-xl py-2.5 px-3 text-sm text-zinc-200 outline-none transition-all"
+ >
+ <option value="9:16">9:16 (Vertical)</option>
+ <option value="1:1">1:1 (Square)</option>
+ <option value="16:9">16:9 (Landscape)</option>
+ </select>
+ </div>
+
+ {/* Clips Count */}
+ <div className="space-y-2">
+ <label className="text-xs font-semibold text-zinc-400 uppercase tracking-wider">Render Clips</label>
+ <input
+ type="number"
+ min="1"
+ max="10"
+ value={numClips}
+ onChange={(e) => setNumClips(e.target.value)}
+ className="w-full bg-zinc-950/80 border border-zinc-800 focus:border-purple-500 focus:ring-1 focus:ring-purple-500 rounded-xl py-2 px-3 text-sm text-zinc-200 outline-none transition-all"
+ />
+ </div>
+ </div>
+
+ {/* Errors */}
+ {errorMsg && (
+ <div className="p-3 bg-red-950/40 border border-red-800/80 rounded-xl text-xs text-red-300 text-center">
+ {errorMsg}
+ </div>
+ )}
+
+ {/* Submit Button */}
+ <button
+ type="submit"
+ className="w-full bg-gradient-to-r from-purple-600 to-indigo-600 hover:from-purple-500 hover:to-indigo-500 text-zinc-50 py-3.5 px-4 rounded-xl text-sm font-bold shadow-lg shadow-purple-500/10 cursor-pointer transition-all active:scale-[0.99]"
+ >
+ Generate Shorts
+ </button>
+ </form>
+ </section>
+ )}
+
+ {/* State: Processing & Logging */}
+ {jobStatus === "processing" && (
+ <section className="max-w-4xl w-full mx-auto grid grid-cols-1 md:grid-cols-3 gap-6">
+
+ {/* Progress stages Checklist (Left column) */}
+ <div className="bg-zinc-900/60 border border-zinc-800/80 rounded-2xl p-6 flex flex-col justify-between backdrop-blur-md">
+ <div className="space-y-6">
+ <div>
+ <h2 className="text-base font-bold text-zinc-200">Processing Progress</h2>
+ <p className="text-xs text-zinc-400 mt-1">Estimating 1-3 minutes depending on clip length</p>
+ </div>
+
+ <div className="space-y-4">
+ {/* Stage 1: Download */}
+ <div className="flex items-center gap-3">
+ <div className={`w-5 h-5 rounded-full flex items-center justify-center border text-[10px] ${
+ stages.download ? "bg-purple-500 border-purple-400 text-white" : "border-zinc-700 text-zinc-500"
+ }`}>
+ {stages.download ? "✓" : "1"}
+ </div>
+ <span className={`text-sm ${stages.download ? "text-zinc-200 font-semibold" : "text-zinc-500"}`}>
+ Downloading Video Source
+ </span>
+ </div>
+
+ {/* Stage 2: Transcribe */}
+ <div className="flex items-center gap-3">
+ <div className={`w-5 h-5 rounded-full flex items-center justify-center border text-[10px] ${
+ stages.transcribe ? "bg-purple-500 border-purple-400 text-white" : "border-zinc-700 text-zinc-500"
+ }`}>
+ {stages.transcribe ? "✓" : "2"}
+ </div>
+ <span className={`text-sm ${stages.transcribe ? "text-zinc-200 font-semibold" : "text-zinc-500"}`}>
+ Transcribing Audio (Whisper)
+ </span>
+ </div>
+
+ {/* Stage 3: Analyze */}
+ <div className="flex items-center gap-3">
+ <div className={`w-5 h-5 rounded-full flex items-center justify-center border text-[10px] ${
+ stages.analyze ? "bg-purple-500 border-purple-400 text-white" : "border-zinc-700 text-zinc-500"
+ }`}>
+ {stages.analyze ? "✓" : "3"}
+ </div>
+ <span className={`text-sm ${stages.analyze ? "text-zinc-200 font-semibold" : "text-zinc-500"}`}>
+ LLM Highlight Scoring
+ </span>
+ </div>
+
+ {/* Stage 4: Render */}
+ <div className="flex items-center gap-3">
+ <div className={`w-5 h-5 rounded-full flex items-center justify-center border text-[10px] ${
+ stages.render ? "bg-purple-500 border-purple-400 text-white" : "border-zinc-700 text-zinc-500"
+ }`}>
+ {stages.render ? "✓" : "4"}
+ </div>
+ <span className={`text-sm ${stages.render ? "text-zinc-200 font-semibold" : "text-zinc-500"}`}>
+ Rendering Vertical Shorts
+ </span>
+ </div>
+ </div>
+ </div>
+
+ {/* Cancel Button */}
+ <button
+ onClick={cancelJob}
+ className="mt-6 py-2 px-4 bg-zinc-800 hover:bg-zinc-700 text-zinc-300 text-xs font-semibold rounded-lg cursor-pointer transition-all"
+ >
+ Cancel and Go Back
+ </button>
+ </div>
+
+ {/* Real-time Subprocess Logs Box (Right Columns) */}
+ <div className="md:col-span-2 bg-zinc-950 border border-zinc-800 rounded-2xl flex flex-col overflow-hidden h-[50vh] shadow-2xl">
+ <div className="px-5 py-3 border-b border-zinc-900 bg-zinc-900/50 flex justify-between items-center">
+ <div className="flex items-center gap-2">
+ <div className="w-2 h-2 bg-purple-500 rounded-full animate-ping" />
+ <span className="text-xs font-bold text-zinc-300 uppercase tracking-widest">Pipeline Console Output</span>
+ </div>
+ <span className="text-[10px] text-zinc-500">ID: {jobId}</span>
+ </div>
+
+ <div className="flex-1 p-5 overflow-y-auto font-mono text-[11px] text-zinc-400 space-y-1">
+ {logs.map((log, idx) => (
+ <div key={idx} className="whitespace-pre-wrap leading-relaxed">
+ <span className="text-zinc-600 mr-2">[{idx+1}]</span>
+ {log}
+ </div>
+ ))}
+ <div ref={logsEndRef} />
+ </div>
+ </div>
+
+ </section>
+ )}
+
+ {/* State: Job Failed */}
+ {jobStatus === "failed" && (
+ <section className="max-w-2xl w-full mx-auto bg-zinc-900/60 border border-zinc-800 rounded-2xl p-6 text-center backdrop-blur-md">
+ <div className="w-12 h-12 rounded-full bg-red-500/20 border border-red-500/50 text-red-400 flex items-center justify-center mx-auto mb-4">
+ <svg className="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
+ </svg>
+ </div>
+ <h2 className="text-lg font-bold text-zinc-200">Clipping Job Failed</h2>
+ <p className="text-sm text-zinc-400 mt-2 max-w-md mx-auto">{errorMsg}</p>
+
+ <div className="mt-6 flex justify-center gap-4">
+ <button
+ onClick={() => setJobStatus("idle")}
+ className="py-2.5 px-5 bg-gradient-to-r from-purple-600 to-indigo-600 hover:from-purple-500 hover:to-indigo-500 text-zinc-50 rounded-xl text-xs font-bold transition-all cursor-pointer"
+ >
+ Try Again
+ </button>
+ <button
+ onClick={() => setJobStatus("processing")}
+ className="py-2.5 px-5 bg-zinc-800 hover:bg-zinc-700 text-zinc-300 rounded-xl text-xs font-bold transition-all cursor-pointer"
+ >
+ View Failure Logs
+ </button>
+ </div>
+ </section>
+ )}
+
+ {/* State: Completed (Show Shorts Result Layout) */}
+ {jobStatus === "completed" && result && (
+ <section className="flex flex-col lg:flex-row gap-6 md:gap-8 overflow-hidden flex-1">
+
+ {/* Left Box: Video Player Panel */}
+ <div className="flex-1 lg:max-w-md bg-zinc-900/60 border border-zinc-800 rounded-2xl p-6 flex flex-col items-center justify-center backdrop-blur-md shadow-2xl">
+ {currentClip ? (
+ <div className="relative w-full max-w-[280px] aspect-[9/16] rounded-xl overflow-hidden bg-black shadow-2xl border border-zinc-800">
+ <video
+ key={currentClip.clip_url}
+ controls
+ className="w-full h-full object-cover"
+ src={currentClip.clip_url}
+ />
+ <div className="absolute top-3 right-3 py-1 px-2.5 bg-black/60 rounded-full text-xs font-bold border border-zinc-700/50 flex items-center gap-1 backdrop-blur-sm">
+ <span className="text-amber-400">★</span> Score: {currentClip.score}
+ </div>
+ </div>
+ ) : (
+ <div className="text-center text-zinc-500 py-20">No clip loaded</div>
+ )}
+ </div>
+
+ {/* Right Box: Clip Details & Selector */}
+ <div className="flex-1 flex flex-col gap-6">
+
+ {/* Highlight Details */}
+ {currentClip && (
+ <div className="bg-zinc-900/60 border border-zinc-800 rounded-2xl p-6 md:p-8 flex-1 flex flex-col justify-between backdrop-blur-md shadow-xl">
+ <div className="space-y-6">
+ {/* Title & Score */}
+ <div className="flex justify-between items-start gap-4">
+ <div>
+ <span className="text-[10px] text-purple-400 uppercase tracking-widest font-bold">Clip #{selectedClipIndex + 1}</span>
+ <h2 className="text-xl font-bold text-zinc-100 tracking-tight mt-1">{currentClip.title}</h2>
+ <p className="text-xs text-zinc-500 mt-1">
+ Timestamp: {currentClip.start_time?.toFixed(1)}s → {currentClip.end_time?.toFixed(1)}s
+ </p>
+ </div>
+
+ {/* Radial Score Indicator */}
+ <div className="relative w-16 h-16 flex items-center justify-center rounded-full bg-zinc-950 border border-zinc-800">
+ <span className="text-sm font-bold bg-gradient-to-r from-purple-400 to-indigo-300 bg-clip-text text-transparent">
+ {currentClip.score}%
+ </span>
+ </div>
+ </div>
+
+ {/* Hook sentence */}
+ <div className="space-y-2">
+ <h4 className="text-xs uppercase tracking-widest font-bold text-zinc-400">Opening Hook Sentence</h4>
+ <p className="text-sm border-l-2 border-purple-500 pl-4 py-1 italic bg-purple-500/5 rounded-r-lg text-zinc-300">
+ "{currentClip.hook_sentence}"
+ </p>
+ </div>
+
+ {/* Reason */}
+ <div className="space-y-2">
+ <h4 className="text-xs uppercase tracking-widest font-bold text-zinc-400">Virality Logic Reason</h4>
+ <p className="text-sm text-zinc-300 leading-relaxed">
+ {currentClip.virality_reason}
+ </p>
+ </div>
+ </div>
+
+ {/* Call to actions */}
+ <div className="mt-8 flex gap-4">
+ <a
+ href={currentClip.clip_url}
+ download={`short_${selectedClipIndex + 1}.mp4`}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="flex-1 py-3 px-4 bg-gradient-to-r from-purple-600 to-indigo-600 hover:from-purple-500 hover:to-indigo-500 text-zinc-50 font-bold rounded-xl text-center text-sm cursor-pointer shadow-lg shadow-purple-500/10 transition-all"
+ >
+ Download Short MP4
+ </a>
+
+ <button
+ onClick={() => setJobStatus("idle")}
+ className="py-3 px-4 border border-zinc-800 hover:bg-zinc-900 text-zinc-300 rounded-xl text-sm font-semibold transition-all cursor-pointer"
+ >
+ Clip Another Video
+ </button>
+ </div>
+ </div>
+ )}
+
+ {/* Selector Carousel (Bottom row of right box) */}
+ <div className="bg-zinc-900/60 border border-zinc-800 rounded-2xl p-5 backdrop-blur-md">
+ <h3 className="text-xs uppercase tracking-widest font-bold text-zinc-400 mb-3">All Candidate Clips ({result?.shorts?.length})</h3>
+ <div className="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-3">
+ {result?.shorts?.map((clip, index) => (
+ <button
+ key={index}
+ onClick={() => setSelectedClipIndex(index)}
+ className={`p-3 text-left rounded-xl border transition-all cursor-pointer ${
+ selectedClipIndex === index
+ ? "bg-purple-600/10 border-purple-500 text-purple-200"
+ : "bg-zinc-950/40 border-zinc-800 hover:border-zinc-700 text-zinc-400 hover:text-zinc-200"
+ }`}
+ >
+ <div className="text-[10px] font-bold uppercase tracking-wider">Clip #{index + 1}</div>
+ <div className="text-xs font-semibold truncate mt-1">{clip.title || `Clip ${index + 1}`}</div>
+ <div className="text-[10px] opacity-60 mt-1">Score: {clip.score}</div>
+ </button>
+ ))}
+ </div>
+ </div>
+
+ </div>
+ </section>
+ )}
+
+ </main>
+
+ {/* Footer */}
+ <footer className="py-4 text-center text-xs text-zinc-700 border-t border-zinc-900/80 bg-zinc-950/40 mt-8">
+ Open-source YouTube Shorts generator. Uses Next.js, FastAPI, MuAPI, Whisper, and LLMs.
+ </footer>
+ </div>
+ );
+}
diff --git a/video_generation/AI-Youtube-Shorts-Generator/requirements.txt b/video_generation/AI-Youtube-Shorts-Generator/requirements.txt
index 5160da3..7372dbd 100644
--- a/video_generation/AI-Youtube-Shorts-Generator/requirements.txt
+++ b/video_generation/AI-Youtube-Shorts-Generator/requirements.txt
@@ -1,2 +1,5 @@
requests>=2.31
python-dotenv>=1.0
+fastapi==0.111.0
+uvicorn==0.30.1
+
diff --git a/video_generation/AI-Youtube-Shorts-Generator/server/main.py b/video_generation/AI-Youtube-Shorts-Generator/server/main.py
new file mode 100644
index 0000000..e3ec4f6
--- /dev/null
+++ b/video_generation/AI-Youtube-Shorts-Generator/server/main.py
@@ -0,0 +1,148 @@
+import asyncio
+import os
+import sys
+import uuid
+import json
+import subprocess
+from fastapi import FastAPI, BackgroundTasks, HTTPException
+from fastapi.middleware.cors import CORSMiddleware
+from fastapi.staticfiles import StaticFiles
+from pydantic import BaseModel
+
+app = FastAPI()
+
+# Enable CORS for Next.js frontend (localhost:3000)
+app.add_middleware(
+ CORSMiddleware,
+ allow_origins=["*"],
+ allow_credentials=True,
+ allow_methods=["*"],
+ allow_headers=["*"],
+)
+
+# Ensure the output directory exists
+OUTPUT_DIR = "output"
+os.makedirs(OUTPUT_DIR, exist_ok=True)
+
+# Mount the output directory to serve completed MP4s as static assets
+app.mount("/output", StaticFiles(directory=OUTPUT_DIR), name="output")
+
+# In-memory job registry
+jobs = {}
+
+class GenerateRequest(BaseModel):
+ url: str
+ mode: str = "api" # api or local
+ num_clips: int = 3
+ aspect_ratio: str = "9:16"
+
+async def run_shorts_pipeline(job_id: str, request: GenerateRequest):
+ jobs[job_id]["status"] = "processing"
+
+ # We will output results to a specific JSON file in the output directory
+ output_json_path = os.path.join(OUTPUT_DIR, f"job_{job_id}.json")
+
+ # Command to execute main.py in a separate process
+ cmd = [
+ sys.executable,
+ "main.py",
+ request.url,
+ "--mode", request.mode,
+ "--num-clips", str(request.num_clips),
+ "--aspect-ratio", request.aspect_ratio,
+ "--output-json", output_json_path
+ ]
+
+ jobs[job_id]["logs"].append(f"Running command: {' '.join(cmd)}")
+
+ try:
+ # Start the subprocess
+ process = await asyncio.create_subprocess_exec(
+ *cmd,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE
+ )
+
+ # Helper to read stdout/stderr concurrently
+ async def read_stream(stream, log_prefix=""):
+ while True:
+ line = await stream.readline()
+ if not line:
+ break
+ decoded_line = line.decode('utf-8', errors='replace').strip()
+ if decoded_line:
+ jobs[job_id]["logs"].append(decoded_line)
+ print(f"[{job_id}] {decoded_line}")
+
+ # Read stdout and stderr concurrently
+ await asyncio.gather(
+ read_stream(process.stdout),
+ read_stream(process.stderr)
+ )
+
+ # Wait for the process to complete
+ returncode = await process.wait()
+
+ if returncode == 0:
+ # Read output JSON
+ if os.path.exists(output_json_path):
+ with open(output_json_path, "r", encoding="utf-8") as f:
+ result_data = json.load(f)
+
+ # In local mode, let's map file paths of shorts to web URLs
+ # For example, if it generated "output\short_01.mp4", we convert it to "/output/short_01.mp4"
+ if request.mode == "local" and "shorts" in result_data:
+ for short in result_data["shorts"]:
+ # Convert local absolute/relative path to hosted /output/ relative URL path
+ clip_path = short.get("clip_url", "")
+ if clip_path and not clip_path.startswith("http"):
+ # Get filename
+ filename = os.path.basename(clip_path)
+ short["clip_url"] = f"http://localhost:8000/output/{filename}"
+
+ jobs[job_id]["result"] = result_data
+ jobs[job_id]["status"] = "completed"
+ jobs[job_id]["logs"].append("Pipeline finished successfully!")
+ else:
+ jobs[job_id]["status"] = "failed"
+ jobs[job_id]["error"] = "Output JSON file was not generated."
+ jobs[job_id]["logs"].append("Error: Output JSON file was not generated.")
+ else:
+ jobs[job_id]["status"] = "failed"
+ jobs[job_id]["error"] = f"Subprocess exited with code {returncode}"
+ jobs[job_id]["logs"].append(f"Error: Subprocess exited with code {returncode}")
+
+ except Exception as e:
+ jobs[job_id]["status"] = "failed"
+ jobs[job_id]["error"] = str(e)
+ jobs[job_id]["logs"].append(f"Exception: {str(e)}")
+
[email protected]("/api/generate")
+async def generate_shorts_endpoint(request: GenerateRequest, background_tasks: BackgroundTasks):
+ job_id = str(uuid.uuid4().hex[:8])
+ jobs[job_id] = {
+ "id": job_id,
+ "status": "pending",
+ "logs": ["Job submitted. Preparing to run AI pipeline..."],
+ "result": None,
+ "error": None
+ }
+
+ # Run the process in the background
+ background_tasks.add_task(run_shorts_pipeline, job_id, request)
+
+ return {"job_id": job_id, "status": "pending"}
+
[email protected]("/api/jobs/{job_id}")
+async def get_job_status(job_id: str):
+ if job_id not in jobs:
+ raise HTTPException(status_code=404, detail="Job not found")
+ return jobs[job_id]
+
[email protected]("/api/jobs")
+async def list_jobs():
+ return list(jobs.values())
+
+if __name__ == "__main__":
+ import uvicorn
+ uvicorn.run(app, host="0.0.0.0", port=8000)