clipwright/CLAUDE.md
juancarlos.cavero ce67cdcdf5 feat(seo): make the site readable by AI crawlers
The dashboard is a client-rendered SPA, so the HTML served for / contained an
empty <div id="root"> and nothing else. Googlebot renders JavaScript and saw the
real landing page; GPTBot, ClaudeBot and PerplexityBot do not, and measured the
homepage as zero characters of text. That is why the site ranks #1 in Google for
its own name and is absent from AI answers. Verified: curl with a GPTBot UA
returned 13,651 bytes of markup and 0 characters of body text.

vite-plugin-seo.js fixes it at build time, with no runtime cost and no change to
how the app mounts:

- Injects crawler-visible homepage content into #root. React replaces it on
  mount, so users get the app unchanged. Homepage now serves 7,524 characters
  of text instead of 0.
- Emits eight standalone static pages: four "X alternative" comparisons plus
  free-ai-clip-generator, open-source-video-clipper, how-openshorts-works and an
  /alternatives hub. Commercial-investigation prompts are answered almost
  entirely out of comparison content, and informational pages are cited far more
  than product pages.
- Generates sitemap.xml (was one hand-written URL with a stale lastmod) and
  llms.txt from the same page list so the three cannot drift.

Also corrects three things that were actively misinforming engines:

- canonical pointed at the apex, which 302s to www. It named a URL that only
  ever redirects. Now www everywhere, matching what is served.
- The schema declared one SoftwareApplication at price 0. That is true of the
  self-hosted edition and false of the hosted one, so the whole product read as
  free. Split into SoftwareApplication (MIT, $0) and Service (Cloud, real
  AggregateOffer of $12-59), and the FAQ answers now name both prices together.
- Opus Clip was described as "$15-228/month" and the Cloud tier as a "3-day free
  trial". Both are stale. Competitor pricing now lives in seo/data.js with the
  date it was checked rendered next to it on the page.

nginx: try_files gains $uri.html before $uri/, so the generated pages resolve at
their clean path with a 200. Resolving them as directories makes nginx 301 to a
trailing slash, which would point every canonical at a redirect.

Verified against the production nginx config in a container: all 12 routes 200,
no redirects, all 9 JSON-LD graphs parse, React mounts with a clean console.
2026-07-27 10:56:15 +02:00

6.1 KiB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

OpenShorts is an AI-powered vertical video generator that transforms long YouTube videos or local uploads into viral-ready short clips (9:16 format) for TikTok, Instagram Reels, and YouTube Shorts. Uses Google Gemini 2.0 Flash for viral moment detection and title generation.

Development Commands

Local Development (Docker)

docker compose up --build   # Build and run full stack

Frontend Only (Dashboard)

cd dashboard
npm install
npm run dev       # Dev server with HMR (port 5173)
npm run build     # Production build
npm run lint      # ESLint (strict, --max-warnings 0)

Backend Only

pip install -r requirements.txt
uvicorn app:app --host 0.0.0.0 --port 8000

Architecture

Core Processing Pipeline

  1. Ingest - YouTube download (yt-dlp) or local upload
  2. Transcription - faster-whisper with word-level timestamps
  3. Scene Detection - PySceneDetect for segment boundaries
  4. AI Analysis - Gemini identifies 3-15 viral moments (15-60 sec each)
  5. FFmpeg Extraction - Precise clip cutting
  6. AI Cropping - Vertical reframing with subject tracking
  7. Effects/Subtitles - Optional AI-generated FFmpeg filters
  8. Hook Overlay - Text overlays with styled fonts
  9. Voice Dubbing - Optional ElevenLabs AI translation (30+ languages)
  10. S3 Backup - Silent background upload
  11. Social Distribution - Upload-Post API (async upload)

Key Files

File Purpose
main.py Core video processing: transcription, scene detection, clip extraction, vertical reframing
app.py FastAPI server with async job queue and REST endpoints
editor.py Gemini AI integration for dynamic video effects (FFmpeg filter generation)
hooks.py Hook text overlay generation with font rendering
s3_uploader.py AWS S3 upload with caching
subtitles.py SRT generation, FFmpeg subtitle burning, and dubbed video transcription
translate.py ElevenLabs dubbing API for AI voice translation
dashboard/src/App.jsx Main React component with state management
dashboard/src/components/TranslateModal.jsx Voice dubbing UI with language selection
dashboard/vite-plugin-seo.js Build-time SEO surface: injects crawler-visible homepage content, emits static pages, sitemap.xml and llms.txt
dashboard/seo/data.js Single source of truth for pricing, pipeline and competitor facts used by every generated page

SEO / AI-crawler surface

The dashboard is a client-rendered SPA with hash routing, so the HTML served for / used to contain an empty <div id="root">. Googlebot renders JavaScript and saw the real page; GPTBot, ClaudeBot and PerplexityBot do not and measured the homepage as zero characters of text. vite-plugin-seo.js fixes that at build time:

  • Injects the content of seo/landing-fallback.js into #root. React's createRoot().render() replaces it on mount, so users get the app and non-executing clients get the copy. Keep it in sync with Landing.jsx.
  • Emits the standalone pages under /alternatives, /free-ai-clip-generator, /open-source-video-clipper and /how-openshorts-works as flat .html files. nginx resolves the clean URL through try_files $uri $uri.html; serving them as directories instead makes nginx 301 to a trailing slash and every canonical would then point at a redirect.
  • Generates sitemap.xml and llms.txt from the same page list, so they cannot drift. Do not add a static public/sitemap.xml back.

When editing pricing anywhere, edit seo/data.js too. Nothing on the site should say "OpenShorts is free" without naming the Cloud price in the same breath: both are true of different editions and quoting only the first one is what makes AI answers describe the paid product as free.

Dual-Mode Video Reframing

  • TRACK Mode (single subject): MediaPipe face detection + YOLOv8 fallback with "Heavy Tripod" stabilization
  • GENERAL Mode (groups/landscapes): Blurred background layout preserving full width

Key Classes

  • SmoothedCameraman - Stabilized camera movement with safe zone logic (prevents jitter)
  • SpeakerTracker - Prevents rapid speaker switching, handles temporary occlusions

API Endpoints

Method Route Purpose
POST /api/process Submit video for processing
GET /api/status/{job_id} Poll job status and logs
POST /api/edit Apply AI video effects
POST /api/subtitle Generate and apply subtitles (auto-transcribes dubbed videos)
POST /api/hook Add text hook overlays
POST /api/translate AI voice dubbing via ElevenLabs
GET /api/translate/languages List supported dubbing languages
POST /api/social/post Post to social media (async upload)

Concurrency Model

Async job queue with semaphore-based concurrency control. Configure via MAX_CONCURRENT_JOBS env var (default: 5). Jobs auto-cleanup after 1 hour.

Environment Variables

Server-side (.env):

  • AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION, AWS_S3_BUCKET - For S3 backup
  • MAX_CONCURRENT_JOBS - Concurrent processing limit (default: 5)
  • VITE_API_URL - Production API URL override

Client-side (localStorage, encrypted):

  • GEMINI_API_KEY - Google Gemini API key (required)
  • ELEVENLABS_API_KEY - ElevenLabs API key for voice dubbing (optional)
  • UPLOAD_POST_API_KEY - Upload-Post API key for social posting (optional)

API keys are stored encrypted in the browser and sent via headers only when needed. Never stored server-side.

Tech Stack

  • Backend: Python 3.11, FastAPI, google-genai, faster-whisper, ultralytics (YOLOv8), mediapipe, opencv-python, yt-dlp, FFmpeg, httpx
  • Frontend: React 18, Vite 4, Tailwind CSS 3.4
  • External APIs: Google Gemini, ElevenLabs Dubbing, Upload-Post
  • Infrastructure: Docker + Docker Compose, AWS S3