d-ragon commited on
Commit
851e5ba
·
verified ·
1 Parent(s): 2e3c296

Upload 547 files

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 +36 -17
  2. .env.example +454 -0
  3. .gitattributes +47 -0
  4. .gitignore +22 -25
  5. AGENTS.md +65 -0
  6. CHANGELOG.md +171 -0
  7. CLAUDE.md +454 -0
  8. CONTRIBUTING.md +43 -0
  9. DEPLOY_NOTES.md +42 -0
  10. Dockerfile +88 -24
  11. LICENSE +661 -0
  12. Makefile +24 -0
  13. QUICKSTART.md +250 -0
  14. README.md +143 -1
  15. assets/banner.jpg +0 -0
  16. assets/blender/announcement/README.md +30 -0
  17. assets/blender/announcement/liquid-chrome.py +256 -0
  18. assets/blender/announcement/prism-wall.py +256 -0
  19. assets/blender/announcement/renders/liquid-chrome.mp4 +3 -0
  20. assets/blender/announcement/renders/liquid-chrome.webm +3 -0
  21. assets/blender/announcement/renders/liquid-chrome.webp +0 -0
  22. assets/blender/announcement/renders/silk-cascade.mp4 +3 -0
  23. assets/blender/announcement/renders/silk-cascade.webm +3 -0
  24. assets/blender/announcement/renders/silk-cascade.webp +0 -0
  25. assets/blender/announcement/silk-cascade.py +376 -0
  26. backend/.dockerignore +39 -0
  27. backend/.env.example +97 -0
  28. backend/.pytest_cache/.gitignore +2 -0
  29. backend/.pytest_cache/CACHEDIR.TAG +4 -0
  30. backend/.pytest_cache/README.md +8 -0
  31. backend/.pytest_cache/v/cache/lastfailed +3 -0
  32. backend/.pytest_cache/v/cache/nodeids +76 -0
  33. backend/.python-version +1 -0
  34. backend/Dockerfile +59 -0
  35. backend/README.md +130 -0
  36. backend/REFACTORING_GUIDE.md +330 -0
  37. backend/bin/start.sh +17 -0
  38. backend/fonts/Anton-Regular.ttf +3 -0
  39. backend/fonts/ArchivoBlack-Regular.ttf +0 -0
  40. backend/fonts/Bangers-Regular.ttf +0 -0
  41. backend/fonts/BarlowCondensed-Bold.ttf +3 -0
  42. backend/fonts/BebasNeue-Regular.ttf +0 -0
  43. backend/fonts/DMSans.ttf +3 -0
  44. backend/fonts/Inter.ttf +3 -0
  45. backend/fonts/LeagueSpartan.ttf +0 -0
  46. backend/fonts/Montserrat-Variable-wght.ttf +3 -0
  47. backend/fonts/NunitoSans.ttf +3 -0
  48. backend/fonts/OpenSans.ttf +3 -0
  49. backend/fonts/Oswald-Variable-wght.ttf +3 -0
  50. backend/fonts/Poppins-ExtraBold.ttf +3 -0
.dockerignore CHANGED
@@ -1,19 +1,38 @@
1
- node_modules
2
- client/node_modules
3
- npm-debug.log*
4
- yarn-debug.log*
5
- yarn-error.log*
6
- pnpm-debug.log*
7
-
8
- dist
9
- client/dist
10
- server/public
11
 
12
  .git
13
- .gitignore
14
- .dockerignore
15
- .DS_Store
16
- Thumbs.db
17
- .idea
18
- .vscode
19
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Root context is shared by the frontend image and the Hugging Face Space.
2
+ # Backend source and deploy/ must remain available to the Space Dockerfile.
 
 
 
 
 
 
 
 
3
 
4
  .git
5
+ .github
6
+ .cursor
7
+ mcp
8
+ docs
9
+ observability
10
+ scripts
11
+ assets
12
+ **/node_modules
13
+ **/.next
14
+ **/coverage
15
+ **/.venv
16
+ **/__pycache__
17
+ **/*.pyc
18
+ **/.pytest_cache
19
+ **/.env
20
+ **/.env.*
21
+ !**/.env.example
22
+ **/.DS_Store
23
+ **/dist
24
+ **/*.tsbuildinfo
25
+ **/playwright-report
26
+ **/test-results
27
+ **/.ruff_cache
28
+ **/.coverage
29
+ **/htmlcov
30
+ backend/logs
31
+ backend/temp
32
+ backend/uploads
33
+ backend/clips
34
+ runtime
35
+ backend/demo_clips
36
+ backend/tests
37
+ frontend/e2e
38
+ frontend/src/generated
.env.example ADDED
@@ -0,0 +1,454 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SupoClip Environment Configuration
2
+ # Copy this file and fill in your API keys
3
+
4
+ # ==============================================
5
+ # AI Provider API Keys (Required for video processing)
6
+ # ==============================================
7
+
8
+ # Transcription provider: assemblyai (default), whisper, or youtube_captions
9
+ # - assemblyai: cloud API (requires ASSEMBLY_AI_API_KEY), best accuracy, speaker diarization
10
+ # - whisper: local transcription (no API key), good accuracy, word-level timestamps
11
+ # - youtube_captions: extract from YouTube captions (YouTube-sourced videos only)
12
+ TRANSCRIPTION_PROVIDER=assemblyai
13
+ # Avoid CUDA/NVIDIA dependency downloads on CPU-only Docker hosts (including Macs).
14
+ # Existing deployments without this setting retain their current Torch variant.
15
+ BACKEND_CPU_ONLY=true
16
+ # Image platform for the backend and worker. linux/amd64 is the default,
17
+ # including on Apple Silicon, where Docker emulates it. On an arm64 host, set
18
+ # linux/arm64 and keep BACKEND_CPU_ONLY=true (CUDA wheels are amd64-only),
19
+ # then rebuild: docker compose up -d --build backend worker
20
+ BACKEND_PLATFORM=linux/amd64
21
+
22
+ # AssemblyAI - Only needed when TRANSCRIPTION_PROVIDER=assemblyai
23
+ # Word-level timing, speaker diarization (best quality, cloud API)
24
+ ASSEMBLY_AI_API_KEY=
25
+ # Optional model override for all processing modes (fast, balanced, quality).
26
+ # Set universal-2 for lower cost with word timings and speaker labels retained.
27
+ # Empty preserves each processing mode's model selection.
28
+ ASSEMBLY_AI_SPEECH_MODEL=
29
+ # Total status-polling budget after transcript submission, in seconds.
30
+ ASSEMBLY_AI_HTTP_TIMEOUT_SECONDS=900
31
+ # Bound individual upload/submit HTTP requests; transient uploads retry up to 3 times.
32
+ ASSEMBLY_AI_REQUEST_TIMEOUT_SECONDS=60
33
+
34
+ # Spoken language of uploads. Leave empty (or "auto") to detect it per video.
35
+ # Set an AssemblyAI language code (e.g. es, de, pt, en_us) to force it; this
36
+ # also picks the matching audio track in multi-track files. Applies to Whisper too.
37
+ TRANSCRIPTION_LANGUAGE=
38
+
39
+ # Max accepted size (bytes) for an uploaded video. Default 4 GB (4000000000),
40
+ # enough for a full-length 1080p upload at a normal bitrate. Larger files make
41
+ # transcription, storage, and rendering slow and fragile.
42
+ # The web app reads the same value from the billing summary. Set
43
+ # NEXT_PUBLIC_MAX_VIDEO_UPLOAD_BYTES to this number as well so the pre-upload
44
+ # check matches before that summary loads.
45
+ MAX_VIDEO_UPLOAD_BYTES=4000000000
46
+
47
+ # Choose one AI provider for transcript analysis:
48
+ # OpenAI (recommended: gpt-5.2)
49
+ OPENAI_API_KEY=
50
+
51
+ # OpenRouter: Sonnet 5.5 primary, GPT-6 Luna fallback
52
+ OPENROUTER_API_KEY=
53
+ OPENROUTER_FALLBACK_MODEL=openai/gpt-6-luna
54
+
55
+ # NVIDIA API Catalog (hosted trial / research and development)
56
+ # Select LLM=nvidia:minimaxai/minimax-m3.1-flash to use MiniMax.
57
+ NVIDIA_API_KEY=
58
+
59
+ # Google AI (recommended: gemini-3-flash)
60
+ GOOGLE_API_KEY=
61
+
62
+ # Anthropic (claude-3-5-sonnet, claude-4-sonnet)
63
+ ANTHROPIC_API_KEY=
64
+
65
+ # Ollama (local/self-hosted or Ollama Cloud)
66
+ # Optional. Defaults to http://localhost:11434/v1 for local backend runs,
67
+ # or http://host.docker.internal:11434/v1 inside Docker.
68
+ OLLAMA_BASE_URL=
69
+ # Optional for Ollama Cloud
70
+ OLLAMA_API_KEY=
71
+
72
+ # Pexels - For AI B-Roll (free stock video footage)
73
+ # Get your free API key at: https://www.pexels.com/api/
74
+ PEXELS_API_KEY=
75
+
76
+ # Optional paid fallback for YouTube downloads
77
+ APIFY_API_TOKEN=
78
+
79
+ # YouTube download provider
80
+ # `yt_dlp` is the free default and works without APIFY_API_TOKEN.
81
+ # `apify` uses the Apify actor first, then falls back to yt-dlp.
82
+ # `rapidapi` tries API Router, then Apify, then yt-dlp.
83
+ # When YOUTUBE_PROXY_URL is configured, the order is proxy, API Router, Apify, yt-dlp.
84
+ YOUTUBE_DOWNLOAD_PROVIDER=yt_dlp
85
+
86
+ # Residential proxy for yt-dlp. Empty keeps the existing provider chain.
87
+ # `{session}` is replaced with a per-job sticky id (one exit IP per job).
88
+ # `{country}` is optional and must be a two-letter code when set below.
89
+ # Example: http://user-country-{country}-session-{session}:pass@gw.example:823
90
+ YOUTUBE_PROXY_URL=
91
+ TWITCH_DOWNLOAD_PROVIDERS=proxy,direct,apify_twitch
92
+ KICK_DOWNLOAD_PROVIDERS=proxy,direct_retry,apify_kick_hls,apify_kick_mp4
93
+ APIFY_STREAM_PROVIDERS=true
94
+ APIFY_TWITCH_ACTOR=abotapi/twitch-scraper
95
+ APIFY_KICK_HLS_ACTOR=hipersoft/kick-downloader
96
+ APIFY_KICK_MP4_ACTOR=parsebird/kick-video-downloader
97
+ APIFY_STREAM_TIMEOUT_SECONDS=300
98
+ # Upper bound used by the last-resort full Kick download (minimum sent is 100 MB).
99
+ APIFY_KICK_MAX_VIDEO_SIZE_MB=2000
100
+ YOUTUBE_PROXY_COUNTRY=
101
+ YOUTUBE_PROXY_TIMEOUT_SECONDS=300
102
+ # bgutil PO-token sidecar. Empty skips it. In compose: http://bgutil:4416
103
+ YOUTUBE_POT_PROVIDER_URL=
104
+ # Per-job cap for audio + section bytes (and a full-file fallback). Default 2 GB.
105
+ YOUTUBE_DOWNLOAD_MAX_BYTES=2000000000
106
+ # Seconds of padding around each selected clip before ranges are merged.
107
+ YOUTUBE_SECTION_PADDING_SECONDS=10
108
+ # Video downloads never exceed 1080p. A lower value is honored.
109
+ YOUTUBE_MAX_HEIGHT=1080
110
+ # Keep audio and section files so edits do not download the source again.
111
+ YOUTUBE_SOURCE_CACHE=on
112
+ YOUTUBE_SOURCE_CACHE_TTL_SECONDS=604800
113
+ # RapidAPI download service (optional). Hosts stay in private configuration.
114
+ RAPIDAPI_YOUTUBE_API_KEY=
115
+ RAPIDAPI_YOUTUBE_HOST=
116
+ RAPIDAPI_YOUTUBE_RELAY_HOST=
117
+ RAPIDAPI_YOUTUBE_TIMEOUT_SECONDS=300
118
+
119
+ # YouTube metadata provider
120
+ # `yt_dlp` keeps the current behavior.
121
+ # `youtube_data_api` uses the official YouTube Data API first, then falls back to yt-dlp.
122
+ YOUTUBE_METADATA_PROVIDER=yt_dlp
123
+ # How long task creation waits for YouTube length metadata, in seconds.
124
+ # Default 30. Invalid values use 30; values above 180 are capped.
125
+ # Raise this (for example to 60) when valid links time out under amd64 emulation.
126
+ YOUTUBE_PREFLIGHT_TIMEOUT_SECONDS=30
127
+
128
+ # Preferred key for the YouTube Data API metadata path.
129
+ # If omitted, metadata requests fall back to GOOGLE_API_KEY when available.
130
+ YOUTUBE_DATA_API_KEY=
131
+
132
+ # ==============================================
133
+ # AI Model Configuration
134
+ # ==============================================
135
+
136
+ # Format: "provider:model-name"
137
+ # IMPORTANT: Hosted providers require the matching API key above.
138
+ # Ollama can run locally without an API key.
139
+ # Examples:
140
+ # - openai:gpt-5.2 (requires OPENAI_API_KEY) - latest, best reasoning
141
+ # - google-gla:gemini-3-flash-preview (requires GOOGLE_API_KEY) - fast, cost-effective
142
+ # - anthropic:claude-4-sonnet (requires ANTHROPIC_API_KEY)
143
+ # - openrouter:anthropic/claude-sonnet-5.5 (requires OPENROUTER_API_KEY)
144
+ # - nvidia:minimaxai/minimax-m3.1-flash (requires NVIDIA_API_KEY)
145
+ # - ollama:gpt-oss:20b (uses local Ollama by default, optional OLLAMA_BASE_URL)
146
+ LLM=openrouter:anthropic/claude-sonnet-5.5
147
+
148
+ # Optional editor-only model; defaults to Claude Sonnet. Local example:
149
+ # AI_EDIT_MODEL=ollama:qwen3.8:27b
150
+ # Hosted AI editing: Pro includes 10 requests/month, Creator includes 100.
151
+ # Self-hosted AI editing has no subscription allowance.
152
+
153
+ # Optional model for the cross-window rerank of clip candidates on long
154
+ # videos (same provider:model format). Empty = use LLM.
155
+ RERANK_LLM=
156
+
157
+ # Whisper model size: tiny, base, small, medium, large, large-v3
158
+ # Used when TRANSCRIPTION_PROVIDER=whisper. Larger = more accurate but slower.
159
+ WHISPER_MODEL_SIZE=medium
160
+
161
+ # Mark stale queued tasks as error after this many seconds
162
+ QUEUED_TASK_TIMEOUT_SECONDS=180
163
+
164
+ # Default target resolution requested from the Apify YouTube downloader when enabled
165
+ APIFY_YOUTUBE_DEFAULT_QUALITY=1080
166
+ # Maximum Apify actor run time before SupoClip gives up and falls back, in seconds
167
+ APIFY_RUN_TIMEOUT_SECONDS=3600
168
+
169
+ # Processing defaults
170
+ DEFAULT_PROCESSING_MODE=fast
171
+ # Hard cap on clips per task (all modes); fast mode can cap lower
172
+ MAX_CLIPS=10
173
+ FAST_MODE_MAX_CLIPS=10
174
+ FAST_MODE_TRANSCRIPT_MODEL=universal-3-5-pro
175
+ # Cut to the active speaker on multi-person wide shots (uses speaker labels)
176
+ SPEAKER_FRAMING=true
177
+ # Replay a later line before each clip. Off by default: the line plays twice
178
+ # and the real opening has to work on its own. Set true to opt into cold opens.
179
+ HOOK_FIRST_TEASER=false
180
+
181
+ # ==============================================
182
+ # Authentication
183
+ # ==============================================
184
+
185
+ # Better Auth secret (change this in production!)
186
+ # Generate a secure random string for production
187
+ BETTER_AUTH_SECRET=supoclip_dev_secret_change_in_production
188
+
189
+ # Set to true/1/yes to disable new user sign-ups.
190
+ DISABLE_SIGN_UP=false
191
+
192
+ # Set to true to disable all routes except the landing page.
193
+ NEXT_PUBLIC_LANDING_ONLY_MODE=false
194
+
195
+ # ==============================================
196
+ # Analytics (optional)
197
+ # ==============================================
198
+
199
+ # DataFast public website ID (example: dfid_xxxxxx)
200
+ NEXT_PUBLIC_DATAFAST_WEBSITE_ID=
201
+
202
+ # DataFast tracked domain without protocol (example: supoclip.com)
203
+ NEXT_PUBLIC_DATAFAST_DOMAIN=
204
+
205
+ # Set to true only when you want to test DataFast on localhost
206
+ NEXT_PUBLIC_DATAFAST_ALLOW_LOCALHOST=false
207
+
208
+ # Tilly analytics (optional, runs alongside DataFast). Website id from Tilly's site settings.
209
+ NEXT_PUBLIC_TILLY_WEBSITE_ID=
210
+
211
+ # ==============================================
212
+ # Error tracking and logs (optional, see docs/observability.md)
213
+ # ==============================================
214
+
215
+ # PostHog project token (phc_...). Empty disables error reporting from the
216
+ # backend and worker.
217
+ POSTHOG_PROJECT_TOKEN=
218
+ POSTHOG_HOST=https://eu.i.posthog.com
219
+
220
+ # Web analytics, session replay and error tracking. Baked in at build time;
221
+ # empty disables PostHog in the browser.
222
+ NEXT_PUBLIC_POSTHOG_KEY=
223
+ NEXT_PUBLIC_POSTHOG_HOST=https://eu.i.posthog.com
224
+ # Upload web source maps at build time (personal API key with error tracking
225
+ # write + organization read scopes, and the numeric project id).
226
+ POSTHOG_PERSONAL_API_KEY=
227
+ POSTHOG_PROJECT_ID=
228
+
229
+ # Ship container logs to Axiom: set COMPOSE_PROFILES=axiom and an ingest token.
230
+ # COMPOSE_PROFILES=axiom
231
+ AXIOM_TOKEN=
232
+ AXIOM_DATASET=supoclip-prod
233
+
234
+ # Amazon SES credentials for transactional emails; required to verify email and create API keys
235
+ AWS_REGION=us-east-1
236
+ AWS_ACCESS_KEY_ID=
237
+ AWS_SECRET_ACCESS_KEY=
238
+ SES_FROM_EMAIL="SupoClip <onboarding@example.com>"
239
+ # Docker host port. Existing deployments without this setting keep port 3001.
240
+ # Keep your existing port if a production reverse proxy depends on it.
241
+ FRONTEND_PORT=3107
242
+ NEXT_PUBLIC_APP_URL=http://localhost:3107
243
+ BETTER_AUTH_URL=http://localhost:3107
244
+ # Optional comma-separated browser origins for another hostname/custom port.
245
+ # Explicit HTTP(S) origins only; no wildcard or automatic request-host trust.
246
+ BETTER_AUTH_TRUSTED_ORIGINS=
247
+
248
+ # ==============================================
249
+ # Monetization (optional, disabled by default)
250
+ # ==============================================
251
+
252
+ # Open-source/self-host mode. Monetization is only enabled when SELF_HOST=false
253
+ SELF_HOST=true
254
+ BACKEND_AUTH_SECRET=change_me_backend_auth_secret
255
+ APP_SETTINGS_ENCRYPTION_KEY=change_me_settings_encryption_secret
256
+ ALLOW_UNSIGNED_BACKEND_AUTH=false
257
+ AUTH_SIGNATURE_TTL_SECONDS=300
258
+ # Include the frontend origin because browser video uploads go directly to the backend.
259
+ CORS_ORIGINS=http://localhost:3107,http://sp.localhost:3107,http://supoclip.localhost:3107
260
+
261
+
262
+ # Paid plan monthly allowance, in minutes of source video (0 = unlimited).
263
+ # Pro clips are delivered at 720p, Creator ("scale") clips at 1080p.
264
+ PRO_PLAN_MINUTE_LIMIT=600
265
+ SCALE_PLAN_MINUTE_LIMIT=1500
266
+
267
+ # Source-video duration limits, in seconds. Scale's longer allowance applies
268
+ # only to YouTube links from active or trialing Scale subscriptions.
269
+ MAX_VIDEO_DURATION=5400
270
+ PRO_YOUTUBE_MAX_VIDEO_DURATION=5400
271
+ SCALE_YOUTUBE_MAX_VIDEO_DURATION=10800
272
+
273
+ # Stripe settings (required only when SELF_HOST=false)
274
+ STRIPE_SECRET_KEY=
275
+ STRIPE_WEBHOOK_SECRET=
276
+ # Legacy fallback for the Pro price ID. Prefer STRIPE_PRO_PRICE_ID for new setups.
277
+ STRIPE_PRICE_ID=
278
+ STRIPE_PRO_PRICE_ID=
279
+ STRIPE_SCALE_PRICE_ID=
280
+ # Yearly prices (optional; the yearly option fails checkout until they are set)
281
+ STRIPE_PRO_ANNUAL_PRICE_ID=
282
+ STRIPE_SCALE_ANNUAL_PRICE_ID=
283
+ # Earlier prices existing subscribers still pay (comma-separated). They keep
284
+ # mapping to their plan; subscribers on an earlier Pro price keep 1080p.
285
+ STRIPE_PRO_LEGACY_PRICE_IDS=
286
+ STRIPE_SCALE_LEGACY_PRICE_IDS=
287
+ # Creator program: coupon that approved creators' promotion codes are attached to
288
+ # (20% off for the first 3 months).
289
+ STRIPE_CREATOR_COUPON_ID=creator-20-3mo
290
+ NEXT_PUBLIC_PRO_PRICE_MONTHLY=9.99
291
+ NEXT_PUBLIC_SCALE_PRICE_MONTHLY=24.99
292
+ NEXT_PUBLIC_PRO_PRICE_ANNUAL=99.90
293
+ NEXT_PUBLIC_SCALE_PRICE_ANNUAL=249.90
294
+ NEXT_PUBLIC_PRO_PLAN_MINUTE_LIMIT=600
295
+ NEXT_PUBLIC_SCALE_PLAN_MINUTE_LIMIT=1500
296
+ # Scheduled posting on the pricing pages: soon (default, "Coming soon" tag), live, or off
297
+ NEXT_PUBLIC_SOCIAL_PUBLISHING=soon
298
+
299
+ # Optional fallback links when Stripe sessions are not configured
300
+ STRIPE_CHECKOUT_URL=
301
+ STRIPE_CUSTOMER_PORTAL_URL=
302
+
303
+ # RevenueCat Apple IAP webhook settings (handled by the frontend Next.js route)
304
+ REVENUECAT_WEBHOOK_AUTH_HEADER=
305
+ # Optional comma-separated product ID overrides/additions. Defaults are:
306
+ # com.samihindi.supoclip.pro.monthly and com.samihindi.supoclip.scale.monthly
307
+ REVENUECAT_PRO_PRODUCT_IDS=
308
+ REVENUECAT_SCALE_PRODUCT_IDS=
309
+
310
+ # ==============================================
311
+ # Feedback (optional — posts to Discord)
312
+ # ==============================================
313
+
314
+ # Discord webhook URLs (each posts to a separate channel)
315
+ DISCORD_FEEDBACK_WEBHOOK_URL=
316
+ DISCORD_SALES_WEBHOOK_URL=
317
+
318
+ # ==============================================
319
+ # Social Publishing (optional)
320
+ # ==============================================
321
+ # Register one OAuth app per platform; users then connect their own accounts
322
+ # in Settings -> Social Accounts. All three platform APIs are free; each one
323
+ # gates public posting behind an app review (see docs/configuration.md).
324
+ #
325
+ # Redirect URI to register for every platform:
326
+ # ${NEXT_PUBLIC_APP_URL}/api/social/callback/<provider> (youtube | tiktok | instagram)
327
+
328
+ # Google Cloud -> OAuth client (Web application), YouTube Data API v3 enabled
329
+ YOUTUBE_OAUTH_CLIENT_ID=
330
+ YOUTUBE_OAUTH_CLIENT_SECRET=
331
+
332
+ # TikTok for Developers -> app with Login Kit + Content Posting API
333
+ TIKTOK_CLIENT_KEY=
334
+ TIKTOK_CLIENT_SECRET=
335
+ # Leave false until TikTok audits the app (unaudited: private posts from private accounts only).
336
+ TIKTOK_APP_AUDITED=false
337
+
338
+ # Meta for Developers -> app with "Instagram API with Instagram Login"
339
+ INSTAGRAM_APP_ID=
340
+ INSTAGRAM_APP_SECRET=
341
+
342
+ # Where OAuth callbacks and Instagram's public video fetch land. Both default
343
+ # to NEXT_PUBLIC_APP_URL; override only if the frontend is reachable elsewhere.
344
+ SOCIAL_OAUTH_REDIRECT_BASE_URL=
345
+ SOCIAL_PUBLIC_MEDIA_BASE_URL=
346
+
347
+ # Performance loop: how often to pull metrics, for how long after publishing,
348
+ # and how many measured posts are needed before clip selection is personalized.
349
+ SOCIAL_METRICS_REFRESH_HOURS=6
350
+ SOCIAL_METRICS_MAX_POST_AGE_DAYS=60
351
+ SOCIAL_PERFORMANCE_MIN_POSTS=3
352
+
353
+ # Rollout: "off" (default; Social and Analytics stay hidden), "admins"
354
+ # (admins plus the allowlist only) or "all".
355
+ SOCIAL_PUBLISHING_ACCESS=off
356
+ # Platforms available to users admitted by the rollout above. Empty disables all.
357
+ # For a YouTube-only admin trial: ACCESS=admins, PROVIDERS=youtube, no allowlist.
358
+ SOCIAL_PUBLISHING_PROVIDERS=youtube,tiktok,instagram
359
+ # Comma-separated emails that get access when SOCIAL_PUBLISHING_ACCESS=admins.
360
+ SOCIAL_PUBLISHING_ALLOWED_EMAILS=
361
+
362
+ # ==============================================
363
+ # Workflows (series, topic, recap, trailer)
364
+ # ==============================================
365
+
366
+ # Who can pick a workflow other than Highlights or add creator instructions:
367
+ # "admins" (default; admins plus the allowlist below), "all" or "off".
368
+ # Self-hosters usually want "all". Set it on the API and the worker.
369
+ WORKFLOWS_ACCESS=admins
370
+ # Comma-separated emails that get access when WORKFLOWS_ACCESS=admins (verified accounts only).
371
+ WORKFLOWS_ALLOWED_EMAILS=
372
+ # Comma-separated workflows open to everyone while access is admins, e.g. trailer,topic.
373
+ WORKFLOWS_PUBLIC=
374
+ # Most clips a topic run returns.
375
+ # WORKFLOW_TOPIC_MAX_CLIPS=15
376
+ # Wall-clock limit for planning one workflow, in seconds (max 6 hours).
377
+ # WORKFLOW_PLAN_TIMEOUT_SECONDS=1800
378
+ # Transcript size, in words, up to which the whole video is outlined in one
379
+ # model call; longer videos are outlined in windows. Empty uses the model default.
380
+ # WORKFLOW_FULL_CONTEXT_MAX_WORDS=
381
+
382
+ # ==============================================
383
+ # Database Configuration
384
+ # ==============================================
385
+
386
+ # PostgreSQL credentials (matches docker-compose.yml)
387
+ POSTGRES_DB=supoclip
388
+ POSTGRES_USER=supoclip
389
+ POSTGRES_PASSWORD=supoclip_password
390
+
391
+ # Redis password for Docker/local development.
392
+ # Leave blank to run Redis without AUTH, or set a value to require authentication.
393
+ REDIS_PASSWORD=
394
+
395
+ # ==============================================
396
+ # Docker Performance
397
+ # ==============================================
398
+
399
+ # Enable BuildKit for faster Docker builds
400
+ COMPOSE_DOCKER_CLI_BUILD=1
401
+ DOCKER_BUILDKIT=1
402
+
403
+ # Durable media: local for self-hosting, s3 for private object storage.
404
+ # IAM roles/default AWS credentials work when dedicated media keys are blank.
405
+ MEDIA_STORAGE=local
406
+ MEDIA_S3_BUCKET=
407
+ MEDIA_S3_PREFIX=media
408
+ MEDIA_S3_REGION=eu-central-1
409
+ MEDIA_S3_ENDPOINT=
410
+ MEDIA_S3_ACCESS_KEY_ID=
411
+ MEDIA_S3_SECRET_ACCESS_KEY=
412
+ MEDIA_S3_SESSION_TOKEN=
413
+ # Optional independent S3-compatible mirror (for example Cloudflare R2).
414
+ # Enable failover only after existing media has been copied and verified.
415
+ MEDIA_FALLBACK_BUCKET=
416
+ MEDIA_FALLBACK_ENDPOINT=
417
+ MEDIA_FALLBACK_REGION=auto
418
+ MEDIA_FALLBACK_ACCESS_KEY_ID=
419
+ MEDIA_FALLBACK_SECRET_ACCESS_KEY=
420
+ MEDIA_FAILOVER_ENABLED=false
421
+ MEDIA_URL_TTL_SECONDS=900
422
+ MEDIA_CACHE_TTL_SECONDS=86400
423
+ MEDIA_ORPHAN_GRACE_SECONDS=86400
424
+ MEDIA_UPLOAD_CONCURRENCY=3
425
+ MEDIA_UPLOAD_DAILY_LIMIT=20
426
+
427
+ # Explicit deployment configuration; no paid worker is selected by default.
428
+ APIFY_YOUTUBE_DOWNLOADER_ACTOR=
429
+ # Legacy input contracts: start_urls, progressive, kv_videos.
430
+ APIFY_YOUTUBE_INPUT_ADAPTER=start_urls
431
+
432
+ # Private provider pool: actor, pinned build, adapter, optional max_charge_usd
433
+ # and run_timeout_seconds. Adapters: kv_file, url_objects, signed_url,
434
+ # kv_media, private_s3. No paid worker is selected by default.
435
+ APIFY_YOUTUBE_PROVIDERS=[]
436
+ # Ordered actor IDs, comma separated; at most three providers including primary.
437
+ APIFY_YOUTUBE_FALLBACK_ACTORS=
438
+ # Legacy single fallback, used only when the ordered list is empty.
439
+ APIFY_YOUTUBE_FALLBACK_ACTOR=
440
+ # Shared per-download Apify spending allowance across all providers (USD, max 6).
441
+ APIFY_DOWNLOAD_MAX_CHARGE_USD=6
442
+ APIFY_FALLBACK_MAX_CHARGE_USD=6
443
+ # Fallback actors beyond the primary stay off (they can cost up to $6 per run).
444
+ # Set true only when those actors are an intentional, budgeted backup.
445
+ APIFY_EXPENSIVE_FALLBACKS=false
446
+
447
+ # Optional private delivery: versioning required; scope credentials to one bucket.
448
+ APIFY_STORAGE_BUCKET=
449
+ APIFY_STORAGE_REGION=
450
+ APIFY_STORAGE_WRITER_ACCESS_KEY_ID=
451
+ APIFY_STORAGE_WRITER_SECRET_ACCESS_KEY=
452
+ APIFY_STORAGE_READER_ACCESS_KEY_ID=
453
+ APIFY_STORAGE_READER_SECRET_ACCESS_KEY=
454
+ APIFY_STORAGE_KEY_TEMPLATE=
.gitattributes CHANGED
@@ -33,3 +33,50 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ assets/blender/announcement/renders/liquid-chrome.mp4 filter=lfs diff=lfs merge=lfs -text
37
+ assets/blender/announcement/renders/liquid-chrome.webm filter=lfs diff=lfs merge=lfs -text
38
+ assets/blender/announcement/renders/silk-cascade.mp4 filter=lfs diff=lfs merge=lfs -text
39
+ assets/blender/announcement/renders/silk-cascade.webm filter=lfs diff=lfs merge=lfs -text
40
+ backend/fonts/Anton-Regular.ttf filter=lfs diff=lfs merge=lfs -text
41
+ backend/fonts/BarlowCondensed-Bold.ttf filter=lfs diff=lfs merge=lfs -text
42
+ backend/fonts/DMSans.ttf filter=lfs diff=lfs merge=lfs -text
43
+ backend/fonts/Inter.ttf filter=lfs diff=lfs merge=lfs -text
44
+ backend/fonts/Montserrat-Variable-wght.ttf filter=lfs diff=lfs merge=lfs -text
45
+ backend/fonts/NunitoSans.ttf filter=lfs diff=lfs merge=lfs -text
46
+ backend/fonts/OpenSans.ttf filter=lfs diff=lfs merge=lfs -text
47
+ backend/fonts/Oswald-Variable-wght.ttf filter=lfs diff=lfs merge=lfs -text
48
+ backend/fonts/Poppins-ExtraBold.ttf filter=lfs diff=lfs merge=lfs -text
49
+ backend/fonts/Raleway-Variable-wght.ttf filter=lfs diff=lfs merge=lfs -text
50
+ backend/fonts/Roboto.ttf filter=lfs diff=lfs merge=lfs -text
51
+ backend/fonts/Rubik.ttf filter=lfs diff=lfs merge=lfs -text
52
+ backend/fonts/Sora.ttf filter=lfs diff=lfs merge=lfs -text
53
+ backend/fonts/TikTokSans-Bold.ttf filter=lfs diff=lfs merge=lfs -text
54
+ backend/fonts/TikTokSans-Regular.ttf filter=lfs diff=lfs merge=lfs -text
55
+ backend/fonts/WorkSans.ttf filter=lfs diff=lfs merge=lfs -text
56
+ backend/transitions/circle_transition.mp4 filter=lfs diff=lfs merge=lfs -text
57
+ docs/images/billing/cancel-banner-dialog.png filter=lfs diff=lfs merge=lfs -text
58
+ docs/images/billing/cancel-banner-home.png filter=lfs diff=lfs merge=lfs -text
59
+ docs/images/editor/studio-desktop.png filter=lfs diff=lfs merge=lfs -text
60
+ docs/images/editor/studio-mobile.png filter=lfs diff=lfs merge=lfs -text
61
+ docs/images/seo/demo-desktop.png filter=lfs diff=lfs merge=lfs -text
62
+ docs/images/seo/self-hosting-desktop.png filter=lfs diff=lfs merge=lfs -text
63
+ docs/images/tiktok-publishing-article.png filter=lfs diff=lfs merge=lfs -text
64
+ docs/screenshots/ai-allowance-pro.png filter=lfs diff=lfs merge=lfs -text
65
+ docs/screenshots/announcements/announcements-landing.png filter=lfs diff=lfs merge=lfs -text
66
+ docs/screenshots/download-recovery-desktop.png filter=lfs diff=lfs merge=lfs -text
67
+ docs/screenshots/download-recovery-mobile.png filter=lfs diff=lfs merge=lfs -text
68
+ docs/screenshots/faq-desktop.png filter=lfs diff=lfs merge=lfs -text
69
+ docs/screenshots/generation-status-desktop.png filter=lfs diff=lfs merge=lfs -text
70
+ docs/screenshots/library-video-groups-desktop.png filter=lfs diff=lfs merge=lfs -text
71
+ docs/screenshots/library-video-groups-mobile.png filter=lfs diff=lfs merge=lfs -text
72
+ docs/screenshots/pricing-usage-examples.jpg filter=lfs diff=lfs merge=lfs -text
73
+ docs/screenshots/self-host-landing.png filter=lfs diff=lfs merge=lfs -text
74
+ docs/screenshots/self-host-upgrade.png filter=lfs diff=lfs merge=lfs -text
75
+ docs/screenshots/shiori-llc-privacy.png filter=lfs diff=lfs merge=lfs -text
76
+ docs/screenshots/shiori-llc-terms.png filter=lfs diff=lfs merge=lfs -text
77
+ docs/screenshots/submit-layout-desktop.png filter=lfs diff=lfs merge=lfs -text
78
+ docs/screenshots/theme-toggle-create-dark.png filter=lfs diff=lfs merge=lfs -text
79
+ docs/screenshots/theme-toggle-library-dark-bulk-bar.png filter=lfs diff=lfs merge=lfs -text
80
+ docs/screenshots/theme-toggle-library-dark.png filter=lfs diff=lfs merge=lfs -text
81
+ docs/screenshots/theme-toggle-library-light.png filter=lfs diff=lfs merge=lfs -text
82
+ docs/screenshots/theme-toggle-sign-in-saved-dark.png filter=lfs diff=lfs merge=lfs -text
.gitignore CHANGED
@@ -1,30 +1,27 @@
1
- node_modules/
2
- client/node_modules/
3
-
4
- # Build outputs
5
- dist/
6
- client/dist/
7
- server/public/
8
-
9
- # Vite and other caches
10
- .vite/
11
- client/.vite/
12
- .cache/
 
13
 
14
- # Logs
15
- npm-debug.log*
16
- yarn-debug.log*
17
- yarn-error.log*
18
- pnpm-debug.log*
19
 
20
- # Env files
21
- .env
22
  .env.*
23
  !.env.example
 
 
24
 
25
- # OS / editor junk
26
- .DS_Store
27
- Thumbs.db
28
- .idea/
29
- .vscode/
30
-
 
1
+ .env.local
2
+ .DS_Store
3
+ __pycache__
4
+ *.egg-info
5
+ .coverage
6
+ .next/
7
+ logs/
8
+ temp/
9
+ .env
10
+ *.m4a
11
+ frontend/e2e/.seed.json
12
+ frontend/playwright-report/
13
+ frontend/test-results/
14
 
15
+ # local demo / scratch artifacts (not for the repo)
16
+ backend/demo_clips/
17
+ backend/demo_clips_*.log
18
+ backend/run_demo.py
 
19
 
20
+ # Private deployment settings and provider research
 
21
  .env.*
22
  !.env.example
23
+ output/provider-guide*/
24
+ docs/youtube-provider-registry*.json
25
 
26
+ # Local agent checkouts
27
+ .claude/worktrees/
 
 
 
 
AGENTS.md ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Repository Guidelines
2
+
3
+ ## Project Structure & Module Organization
4
+ This repository contains the web app, processing backend, and MCP client:
5
+ - `backend/`: FastAPI + async worker code (`src/api`, `src/services`, `src/repositories`, `src/workers`).
6
+ - `frontend/`: main Next.js app (`src/app`, `src/components`, `src/lib`, `prisma/`).
7
+ - `mcp/`: Python MCP server that connects to the REST API.
8
+ - `backend/src/media/`: transcription, captions, timeline, reframing, and ffmpeg helpers.
9
+
10
+ Infra and bootstrap files live at the root: `docker-compose.yml`, `init.sql`, `.env.example`, and `start.sh`.
11
+
12
+ ## Build, Test, and Development Commands
13
+ Use Docker for full-stack development:
14
+ - `docker-compose up -d --build`: start frontend, backend, worker, Postgres, and Redis.
15
+ - `docker-compose logs -f`: stream service logs.
16
+ - `docker-compose down`: stop everything.
17
+
18
+ Local app commands:
19
+ - `cd frontend && pnpm run dev`: run Next.js in dev mode.
20
+ - `cd frontend && pnpm run build && pnpm run start`: production build + serve.
21
+ - `cd frontend && pnpm run lint`: run ESLint.
22
+ - `cd backend && uv sync && uvicorn src.main:app --reload --host 0.0.0.0 --port 8000`: run API locally.
23
+ - `cd backend && .venv/bin/arq src.workers.tasks.WorkerSettings`: run the worker.
24
+
25
+ ## Coding Style & Naming Conventions
26
+ - Python: 4-space indentation, type hints where practical, `snake_case` for functions/modules.
27
+ - TypeScript/React: 2-space indentation, `PascalCase` for component names, `camelCase` for variables/functions, route files in Next.js App Router conventions (`app/.../page.tsx`, `route.ts`).
28
+ - Linting: Next.js ESLint configs in `frontend/eslint.config.mjs`.
29
+ - Imports: use the `@/*` alias in Next.js apps when possible.
30
+
31
+ ## Testing Guidelines
32
+ Automated coverage uses pytest, Vitest, and Playwright:
33
+ - Run `make check` for frontend lint and TypeScript checks.
34
+ - Run `make test` for backend and frontend unit/integration tests. Backend integration tests need a dedicated Postgres database.
35
+ - Run `make test-e2e` for the database-backed browser smoke tests.
36
+ - Run `cd frontend && pnpm run test:polish` for isolated browser workflow tests with mocked APIs.
37
+ - Install frontend dependencies with `pnpm install --frozen-lockfile`; use the committed pnpm lockfile.
38
+ - Smoke test core flows with `docker-compose` (create task, process clips, view task page).
39
+
40
+ When adding tests, place them near code or under `tests/` with clear names (`test_*.py`, `*.test.ts[x]`).
41
+
42
+ ## Commit & Pull Request Guidelines
43
+ Recent history favors short imperative commit subjects (`Add list endpoint`, `Fix typo`, `improve UX`). Prefer:
44
+ - `type(scope): concise summary` (example: `feat(backend): add task list pagination`).
45
+ - One logical change per commit.
46
+
47
+ PRs should include:
48
+ - What changed and why.
49
+ - Any env/config or migration impact.
50
+ - Screenshots/GIFs for UI changes.
51
+ - Linked issue(s) and manual verification steps.
52
+ - A `CHANGELOG.md` entry for user-visible changes, or a brief explanation of why no entry is needed.
53
+
54
+ ## Changelog Requirements
55
+ - Update the root `CHANGELOG.md` in the same PR as every user-visible feature, improvement, or bug fix. This includes UI wording changes and backend fixes that affect the user experience.
56
+ - Follow the file's format: newest date first, plain-language descriptions, a **New**, **Improved**, **Fixed**, or **Under the hood** category, and a link to the relevant PR. Never include customer names, email addresses, IDs, or other private details.
57
+ - Internal-only changes, including repository instructions and tests with no product behavior change, do not need a release note.
58
+ - Before merging, explicitly check that the required entry is present and run `cd frontend && pnpm exec vitest run src/lib/changelog.test.ts` when the changelog changes.
59
+ - When deploying a user-visible change, verify its entry appears on the live `/changelog` page before reporting the release complete. Do not defer the entry to a later follow-up.
60
+
61
+ ## Security & Configuration Tips
62
+ - Never commit real secrets; use `.env.example` as the template.
63
+ - Preserve the committed dependency lockfiles and patched base-image versions when deploying. Run the `Image security` checks against freshly built final images; do not bypass a failing critical-vulnerability check with a server-only tag or an unpinned package install.
64
+ - Before a production restart, check that no SupoClip tasks are queued or processing and the worker has no ongoing jobs; let active clips finish first.
65
+ - Required runtime keys include `ASSEMBLY_AI_API_KEY` and either one hosted LLM provider key (`OPENAI_API_KEY`, `GOOGLE_API_KEY`, `ANTHROPIC_API_KEY`, or `OPENROUTER_API_KEY`) or an Ollama model configuration (`LLM=ollama:*`, optional `OLLAMA_BASE_URL`).
CHANGELOG.md ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Changelog
2
+
3
+ What changed in SupoClip for people using the product. Newest dates are first.
4
+
5
+ Add a line here when a pull request changes something a user can see. Use **New**, **Improved**, **Fixed**, or **Under the hood**, describe the change in plain language, and link the pull request. Skip internal-only work, or fold it into one **Under the hood** line. Do not include customer names, email addresses, user IDs, or anything else private.
6
+
7
+ ## 2026-11-09
8
+
9
+ - **New:** A single-container Hugging Face deployment runs CPU clipping with a protected owner login, temporary local services, and one-at-a-time media processing. ([Docker Spaces](https://huggingface.co/docs/hub/spaces-sdks-docker))
10
+ - **New:** Self-hosted admins can select NVIDIA-hosted MiniMax for clip selection and reranking, with encrypted API-key storage and editable model presets. ([NVIDIA API Catalog](https://build.nvidia.com/minimaxai/minimax-m3.1-flash))
11
+
12
+ ## 2026-11-07
13
+
14
+ - **Fixed:** TikTok publishing is paused for now, with a short note in Social settings, while an issue with TikTok is fixed. ([#343](https://github.com/FujiwaraChoki/supoclip/pull/343))
15
+
16
+ ## 2026-11-06
17
+
18
+ - **Fixed:** When YouTube audio comes through the backup download route, the video's length is read correctly, so clips from its last minutes are no longer dropped. ([#333](https://github.com/FujiwaraChoki/supoclip/pull/333))
19
+ - **Under the hood:** New features can be switched on for the web and iPhone apps separately, without an update. ([#340](https://github.com/FujiwaraChoki/supoclip/pull/340))
20
+
21
+ ## 2026-11-05
22
+
23
+ - **Fixed:** The homepage shows TikTok publishing and scheduling as available alongside YouTube, with updated pricing details and FAQ answers. Instagram remains marked as coming soon. ([#339](https://github.com/FujiwaraChoki/supoclip/pull/339))
24
+ - **Improved:** Generations show a short, varied notice when a video takes longer than usual. The notice survives a page refresh, replaces the time estimate during delays, and clears when processing continues. ([#336](https://github.com/FujiwaraChoki/supoclip/pull/336))
25
+ - **Improved:** Pro includes 10 AI edits per month and Creator includes 100. The editor shows the remaining allowance and reset date, and failed requests restore the edit. ([#335](https://github.com/FujiwaraChoki/supoclip/pull/335))
26
+ - **New:** A dedicated FAQ lists every supported spoken language and regional variant, with search and answers about language detection, captions, translation limits, and video processing. It is available in all six interface languages and linked from the homepage and footer. ([#334](https://github.com/FujiwaraChoki/supoclip/pull/334))
27
+ - **Under the hood:** Preview deployments use an upload timeout within the hosting platform's supported limit. ([#334](https://github.com/FujiwaraChoki/supoclip/pull/334))
28
+ - **Fixed:** Clips stitched together after cutting pauses no longer risk a frozen picture while the audio keeps playing. ([#333](https://github.com/FujiwaraChoki/supoclip/pull/333))
29
+ - **Under the hood:** Groundwork for new ways to turn a video into clips, not yet available to everyone. ([#333](https://github.com/FujiwaraChoki/supoclip/pull/333))
30
+ - **Improved:** The create screen keeps length, captions, framing, cleanup, and B-roll in one Settings menu, so the composer stays on one line. ([#337](https://github.com/FujiwaraChoki/supoclip/pull/337))
31
+ - **Improved:** The create screen remembers your captions, framing, cleanup, B-roll, length, and other settings on your account, and Settings has a one-click reset. Topics, instructions, and part counts still start fresh for each video. ([#337](https://github.com/FujiwaraChoki/supoclip/pull/337))
32
+ - **New:** A short, skippable tour walks you through new features once, on the real page, so you can find them without reading release notes. ([#337](https://github.com/FujiwaraChoki/supoclip/pull/337))
33
+ - **Fixed:** Long Chinese, Japanese, and Korean titles stay inside the frame instead of running off both edges. ([#337](https://github.com/FujiwaraChoki/supoclip/pull/337))
34
+ - **Fixed:** Clips no longer carry chapter markers or extra data tracks from an uploaded MKV file. ([#337](https://github.com/FujiwaraChoki/supoclip/pull/337))
35
+ - **Fixed:** Failed generations no longer show file paths or technical processing errors. ([#337](https://github.com/FujiwaraChoki/supoclip/pull/337))
36
+ - **Under the hood:** Updated sign-in, video-processing, and developer tools to address published security vulnerabilities. ([#338](https://github.com/FujiwaraChoki/supoclip/pull/338))
37
+
38
+ ## 2026-11-03
39
+
40
+ - **Fixed:** YouTube videos blocked in the downloader's region can retry from a supported region while keeping saved transcripts and other download options available. Generation and editing explain any remaining regional restriction and suggest uploading the file or choosing another source. ([#332](https://github.com/FujiwaraChoki/supoclip/pull/332))
41
+ - **Fixed:** Retrying a failed generation keeps completed clips and your edits, reuses finished transcription and analysis, and generates only the missing clips. Temporary YouTube download failures get a limited automatic retry before falling back. ([#329](https://github.com/FujiwaraChoki/supoclip/pull/329))
42
+ - **Improved:** The recovery action is now called “Retry generation” instead of “Resume.” ([#329](https://github.com/FujiwaraChoki/supoclip/pull/329))
43
+
44
+ ## 2026-10-31
45
+
46
+ - **New:** Download all of a generation's clips at once as a ZIP from the task page. The download starts right away and streams the original files. ([#321](https://github.com/FujiwaraChoki/supoclip/pull/321))
47
+ - **Improved:** The footer, terms, and privacy policy now identify the company operating SupoClip. ([#314](https://github.com/FujiwaraChoki/supoclip/pull/314))
48
+ - **New:** Switch between a light and dark theme from the sidebar (or the header on mobile). The app starts light and remembers your choice; the website and sign-in pages stay light. ([#312](https://github.com/FujiwaraChoki/supoclip/pull/312))
49
+
50
+ ## 2026-10-29
51
+
52
+ - **Fixed:** A large video upload finishes once the file is stored, instead of waiting on a copy that can time out. Uploading the same file again reuses it. ([#306](https://github.com/FujiwaraChoki/supoclip/pull/306))
53
+
54
+ ## 2026-10-28
55
+
56
+ - **Fixed:** When a YouTube download has to fall back to HLS audio, clips stay in the video's original language instead of an automatic dub or an audio-description track. ([#303](https://github.com/FujiwaraChoki/supoclip/pull/303))
57
+
58
+ ## 2026-10-25
59
+
60
+ - **Fixed:** Deleting a generation no longer restores used video minutes, and every new video has its length verified before minutes are charged. ([#261](https://github.com/FujiwaraChoki/supoclip/pull/261))
61
+ - **Fixed:** Upgrading from Pro to Creator takes effect after the upgrade payment succeeds. If that payment is still open or does not go through, you stay on the plan you already paid for. ([#260](https://github.com/FujiwaraChoki/supoclip/pull/260))
62
+ - **Fixed:** Downloading a clip in a social format no longer waits on the whole re-encode, so a long export can finish instead of timing out. ([#258](https://github.com/FujiwaraChoki/supoclip/pull/258))
63
+ - **Fixed:** Copying an API key, a creator code, or a share link still works when the browser blocks the clipboard. If it cannot copy, the text is selected and a message tells you to copy it yourself. ([#257](https://github.com/FujiwaraChoki/supoclip/pull/257))
64
+ - **Under the hood:** A brief server error no longer clears the YouTube download notice or the What's new list, and those checks are not reported as crashes. ([#257](https://github.com/FujiwaraChoki/supoclip/pull/257))
65
+
66
+ ## 2026-10-24
67
+
68
+ - **Fixed:** A YouTube video whose direct audio link is blocked is retried over HLS before a paid download. ([#250](https://github.com/FujiwaraChoki/supoclip/pull/250))
69
+ - **New:** The site is available in Bahasa Indonesia. ([#243](https://github.com/FujiwaraChoki/supoclip/pull/243))
70
+ - **Fixed:** Phone videos recorded in portrait no longer fail to render. ([#241](https://github.com/FujiwaraChoki/supoclip/pull/241))
71
+ - **Fixed:** Editing a clip keeps a split-screen or stacked layout instead of flattening it back to a single frame. ([#238](https://github.com/FujiwaraChoki/supoclip/pull/238))
72
+
73
+ ## 2026-10-23
74
+
75
+ - **Improved:** Uploads can be as large as 4 GB. Video above 1080p or 60 fps is scaled down automatically before clipping. ([#220](https://github.com/FujiwaraChoki/supoclip/pull/220))
76
+ - **Improved:** Automatic vertical framing keeps more of the scene around the speaker, instead of cropping in on the face alone. ([#236](https://github.com/FujiwaraChoki/supoclip/pull/236))
77
+ - **Improved:** Clip analysis on Claude Sonnet uses the model's structured output, so a long video is more likely to come back with a full set of clips. ([ddbc537](https://github.com/FujiwaraChoki/supoclip/commit/ddbc53715c15fdba25d33f6ec4dfc45943b96476))
78
+ - **Under the hood:** When you submit a video link, a sanitized copy is written to the logs, including when the job is rejected. ([#235](https://github.com/FujiwaraChoki/supoclip/pull/235))
79
+
80
+ ## 2026-10-22
81
+
82
+ - **New:** Reaction videos and two people talking over each other can be stacked in the vertical frame. ([#224](https://github.com/FujiwaraChoki/supoclip/pull/224))
83
+
84
+ ## 2026-10-21
85
+
86
+ - **New:** Hosted plans are billed by hours of source video. Pro is $9.99/month for 10 hours at 720p, Creator is $24.99/month for 25 hours at 1080p, and yearly billing is two months free. Pro subscribers from before this change keep 1080p. ([#216](https://github.com/FujiwaraChoki/supoclip/pull/216))
87
+ - **Improved:** Pricing cards spell out how much video a plan includes, and the price stays inside the card. ([#225](https://github.com/FujiwaraChoki/supoclip/pull/225))
88
+ - **New:** Paste a Twitch or Kick link — a VOD or a clip — and those sources show up alongside YouTube. ([#227](https://github.com/FujiwaraChoki/supoclip/pull/227), [#228](https://github.com/FujiwaraChoki/supoclip/pull/228))
89
+ - **Improved:** Calls and talking-head videos are framed more carefully for a vertical crop. ([#217](https://github.com/FujiwaraChoki/supoclip/pull/217))
90
+ - **Fixed:** A clip that rewinds to set up the hook stays within 60 seconds, and a long hook title fits on screen. ([#221](https://github.com/FujiwaraChoki/supoclip/pull/221))
91
+ - **New:** The site and app are available in English, Spanish, Portuguese, German, and Chinese. ([#211](https://github.com/FujiwaraChoki/supoclip/pull/211))
92
+ - **Under the hood:** YouTube downloads hold up better when several jobs run at once, including through a residential proxy when one is configured. ([#218](https://github.com/FujiwaraChoki/supoclip/pull/218), [#223](https://github.com/FujiwaraChoki/supoclip/pull/223))
93
+
94
+ ## 2026-10-20
95
+
96
+ - **Fixed:** After you edit a clip, the caption animation and the hook title from the original render stay in place. ([#210](https://github.com/FujiwaraChoki/supoclip/pull/210))
97
+
98
+ ## 2026-10-18
99
+
100
+ - **Fixed:** The editor keeps karaoke captions from the generated clip, including the font, size, and position. ([#200](https://github.com/FujiwaraChoki/supoclip/pull/200))
101
+
102
+ ## 2026-10-17
103
+
104
+ - **Under the hood:** YouTube downloads go through yt-dlp or Apify. ([#198](https://github.com/FujiwaraChoki/supoclip/pull/198))
105
+
106
+ ## 2026-10-16
107
+
108
+ - **New:** Connect YouTube, TikTok, or Instagram to publish a clip and see how those posts perform. ([#98](https://github.com/FujiwaraChoki/supoclip/pull/98))
109
+ - **Improved:** The library groups each generation with its original video, and an uploaded file keeps its filename. ([#197](https://github.com/FujiwaraChoki/supoclip/pull/197))
110
+ - **New:** A self-hosted install can use its own YouTube download service. ([#196](https://github.com/FujiwaraChoki/supoclip/pull/196))
111
+ - **Under the hood:** If the first YouTube download does not check out, SupoClip can try another one within the same limit. ([#195](https://github.com/FujiwaraChoki/supoclip/pull/195))
112
+
113
+ ## 2026-10-15
114
+
115
+ - **Under the hood:** Clips and uploads are stored durably and removed when you delete them. ([#186](https://github.com/FujiwaraChoki/supoclip/pull/186))
116
+
117
+ ## 2026-10-14
118
+
119
+ - **Improved:** The generation page shows while a video is still importing, then clears that note once it is ready. ([#189](https://github.com/FujiwaraChoki/supoclip/pull/189), [#190](https://github.com/FujiwaraChoki/supoclip/pull/190))
120
+
121
+ ## 2026-10-13
122
+
123
+ - **New:** A public status page shows whether SupoClip is up. ([0aab079](https://github.com/FujiwaraChoki/supoclip/commit/0aab079))
124
+ - **Fixed:** Closing a video stops the transfer instead of leaving it running. ([#187](https://github.com/FujiwaraChoki/supoclip/pull/187))
125
+
126
+ ## 2026-10-12
127
+
128
+ - **Fixed:** Caption templates use the real TikTok Sans Bold and THEBOLDFONT, and oversized caption styles are smaller. ([#185](https://github.com/FujiwaraChoki/supoclip/pull/185))
129
+
130
+ ## 2026-10-11
131
+
132
+ - **New:** Clips open on a short hook, then cut to the sentence where the moment actually starts. ([#174](https://github.com/FujiwaraChoki/supoclip/pull/174))
133
+ - **Improved:** Long pauses are tightened so a clip keeps moving. ([#173](https://github.com/FujiwaraChoki/supoclip/pull/173))
134
+ - **Improved:** On a wide shot with several people, the crop follows whoever is speaking. ([#175](https://github.com/FujiwaraChoki/supoclip/pull/175))
135
+ - **Improved:** A long video is reviewed in sections, then the best moments are ranked together. ([#176](https://github.com/FujiwaraChoki/supoclip/pull/176))
136
+ - **Fixed:** Face tracking works again, so a vertical crop can stay on the person. ([#177](https://github.com/FujiwaraChoki/supoclip/pull/177))
137
+ - **Improved:** Upscaled vertical crops look sharper. ([#172](https://github.com/FujiwaraChoki/supoclip/pull/172))
138
+ - **Improved:** Each video produces at most 10 clips. ([#181](https://github.com/FujiwaraChoki/supoclip/pull/181))
139
+ - **New:** The home page and the demo play a new set of podcast clips. ([#182](https://github.com/FujiwaraChoki/supoclip/pull/182))
140
+ - **New:** Checkout accepts a creator promo code. ([#183](https://github.com/FujiwaraChoki/supoclip/pull/183))
141
+ - **New:** The app can show an announcement from the SupoClip team. ([#179](https://github.com/FujiwaraChoki/supoclip/pull/179))
142
+ - **Improved:** The home page includes the Product Hunt badge. ([#184](https://github.com/FujiwaraChoki/supoclip/pull/184))
143
+ - **Fixed:** If every clip fails to render, the job is marked failed instead of looking finished. A job that never starts does not use your monthly video allowance. ([#169](https://github.com/FujiwaraChoki/supoclip/pull/169), [#170](https://github.com/FujiwaraChoki/supoclip/pull/170), [#171](https://github.com/FujiwaraChoki/supoclip/pull/171))
144
+
145
+ ## 2026-10-10
146
+
147
+ - **New:** The creator program is open. Apply, share your code, and your audience gets 20% off for 3 months. Approved creators get Pro. ([#165](https://github.com/FujiwaraChoki/supoclip/pull/165))
148
+ - **Improved:** Pricing explains that self-hosting is free, next to the hosted plans. ([#166](https://github.com/FujiwaraChoki/supoclip/pull/166))
149
+ - **Improved:** Affiliate is linked from the top of the site and the footer. ([#168](https://github.com/FujiwaraChoki/supoclip/pull/168))
150
+
151
+ ## 2026-10-06
152
+
153
+ - **Improved:** Captions detect the spoken language, stay lined up with the audio, and use fonts that cover more languages. ([#163](https://github.com/FujiwaraChoki/supoclip/pull/163))
154
+
155
+ ## 2026-10-05
156
+
157
+ - **New:** A demo page and practical guides cover clipping, self-hosting, and how SupoClip compares with other tools. ([#160](https://github.com/FujiwaraChoki/supoclip/pull/160))
158
+
159
+ ## 2026-10-04
160
+
161
+ - **Improved:** Upgrade prompts explain what the next plan adds, and you can move from Pro to Creator without starting a new subscription. ([#159](https://github.com/FujiwaraChoki/supoclip/pull/159))
162
+
163
+ ## 2026-10-03
164
+
165
+ - **New:** You can delete your account from Settings. ([#158](https://github.com/FujiwaraChoki/supoclip/pull/158))
166
+ - **New:** If you forget your password, you can reset it by email. ([#157](https://github.com/FujiwaraChoki/supoclip/pull/157))
167
+
168
+ ## 2026-10-02
169
+
170
+ - **Fixed:** A transcription that stalls gives up instead of waiting forever, and the app can tell when the worker is down. ([#155](https://github.com/FujiwaraChoki/supoclip/pull/155))
171
+ - **Under the hood:** Self-hosted installs can build a CPU-only image and keep the sign-in addresses they already use. ([#153](https://github.com/FujiwaraChoki/supoclip/pull/153), [#154](https://github.com/FujiwaraChoki/supoclip/pull/154))
CLAUDE.md ADDED
@@ -0,0 +1,454 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ SupoClip is an open-source alternative to OpusClip — an AI-powered video clipping tool that transforms long-form content into viral short clips. AGPL-3.0 licensed.
8
+
9
+ ## Development Commands
10
+
11
+ ### Docker (recommended)
12
+
13
+ ```bash
14
+ docker-compose up -d # Start all 6 services
15
+ docker-compose up -d --build # Rebuild after changes
16
+ docker-compose logs -f backend # Debug backend
17
+ docker-compose logs -f worker # Debug video processing
18
+ docker-compose logs -f ai-worker # Debug AI editing in the clip studio
19
+ docker-compose down # Stop all services
20
+ ```
21
+
22
+ Services: Frontend (:3107), Backend API (:8000, docs at /docs), Worker (ARQ), AI worker (ARQ, `supoclip_ai` queue), PostgreSQL (:5432), Redis (:6379)
23
+
24
+ ### Backend (local)
25
+
26
+ Uses `uv` (not pip/poetry). Requires Python 3.11+, ffmpeg, running PostgreSQL and Redis.
27
+
28
+ ```bash
29
+ cd backend
30
+ uv venv .venv && source .venv/bin/activate
31
+ uv sync
32
+
33
+ # API server (uses refactored entry point)
34
+ uvicorn src.main:app --reload --host 0.0.0.0 --port 8000
35
+
36
+ # Worker process (required for video processing)
37
+ arq src.workers.tasks.WorkerSettings
38
+ ```
39
+
40
+ ### Frontend (local)
41
+
42
+ ```bash
43
+ cd frontend
44
+ pnpm install
45
+ pnpm run dev # Dev server with Turbopack
46
+ pnpm run build # Prisma generate + Next.js build
47
+ pnpm run lint
48
+ ```
49
+
50
+ ### Tests
51
+
52
+ ```bash
53
+ cd backend && .venv/bin/pytest # unit + integration (needs Postgres/Redis; TEST_DATABASE_URL)
54
+ cd backend && .venv/bin/pytest --no-cov tests/unit/test_workflow_options.py # one file (coverage gate is in addopts)
55
+ cd frontend && pnpm run test # vitest; pnpm run lint && pnpm exec tsc --noEmit
56
+ cd mcp && uv run --with pytest pytest tests -q
57
+ ```
58
+
59
+ ## Architecture
60
+
61
+ ### System Overview
62
+
63
+ ```
64
+ User → Frontend (Next.js 15) → Backend API (FastAPI) → Redis Queue → ARQ Worker
65
+ ↓ ↓
66
+ PostgreSQL ←───────────────────────────────┘
67
+ ```
68
+
69
+ Task creation returns immediately (<100ms). Video processing happens asynchronously in the worker. Frontend connects via SSE for real-time progress updates.
70
+
71
+ ### Backend: Layered Architecture
72
+
73
+ The backend uses the layered application in `main.py`; `main_refactored.py` is a compatibility import:
74
+
75
+ ```
76
+ api/routes/ → HTTP handlers (tasks.py, media.py)
77
+ services/ → Business logic (task_service.py, video_service.py)
78
+ repositories/ → Raw SQL via asyncpg (task_repository.py, clip_repository.py, source_repository.py)
79
+ workers/ → ARQ job queue (tasks.py, job_queue.py, progress.py)
80
+ utils/ → Thread pool helpers for blocking operations (async_helpers.py)
81
+ ```
82
+
83
+ **Key patterns:**
84
+ - All DB access goes through repository classes using raw SQL (`text()` queries), not SQLAlchemy ORM
85
+ - Blocking operations (video processing, downloads, transcription) wrapped in `run_in_thread()` to avoid blocking the async event loop
86
+ - Progress tracking uses Redis pub/sub → SSE to frontend
87
+ - Task status flow: `queued → processing → completed/error/cancelled`
88
+
89
+ ### Video Processing Pipeline
90
+
91
+ 1. **Input** → YouTube URL (yt-dlp) or uploaded file
92
+ 2. **Transcription** → AssemblyAI word-level timestamps (cached as `.transcript_cache.json`)
93
+ 3. **AI Analysis** → Pydantic AI selects viral segments (15-60s each) with virality scoring. Transcripts over 15 min are analysed in 12-min windows (2-min overlap, 3 concurrent), deduplicated, then reranked together in one comparative call (`RERANK_LLM`, default `LLM`); final count scales ~1 clip per 5 min, capped by `MAX_CLIPS` (default 10)
94
+ 4. **Clip Generation** → MoviePy creates 9:16 clips with:
95
+ - Face-centered cropping: MediaPipe → OpenCV DNN → Haar cascade (fallback chain)
96
+ - Word-synced subtitles from AssemblyAI
97
+ - Custom fonts (TTF files in `backend/fonts/`)
98
+ - Optional transition effects (`backend/transitions/`)
99
+ - Optional B-roll overlays (Pexels API)
100
+ - Caption templates with animation styles
101
+ 5. **Storage** → Clips to `{TEMP_DIR}/clips/`, metadata to PostgreSQL
102
+
103
+ ### Frontend Architecture
104
+
105
+ - **Next.js 15** with App Router, React 19, TailwindCSS v4
106
+ - **ShadCN UI** (New York style, stone base color, Radix primitives)
107
+ - **Better Auth** with Prisma adapter for email/password auth
108
+ - **No global state library** — React hooks only (`useState`, `useEffect`, `useSession`)
109
+ - All pages use `"use client"` — SSR is minimal
110
+ - Prisma client generated to `frontend/src/generated/prisma/` (custom output path)
111
+ - Build: `prisma generate && next build` (Prisma generate runs on both build and postinstall)
112
+
113
+ **Auth flow:** Frontend calls Better Auth → session cookie → passes `user_id` header to backend API
114
+
115
+ ### Database
116
+
117
+ PostgreSQL 15. Schema in `init.sql`. Mixed naming conventions:
118
+ - `tasks`, `sources`, `generated_clips` → snake_case
119
+ - `session`, `account`, `verification`, `users` → camelCase (Better Auth)
120
+ - UUIDs stored as VARCHAR(36)
121
+ - Auto-update triggers on `updated_at`/`updatedAt` columns
122
+
123
+ ## Key Backend Files
124
+
125
+ | File | Purpose |
126
+ |------|---------|
127
+ | `src/main_refactored.py` | Compatibility import for existing deployments |
128
+ | `src/main.py` | Canonical FastAPI application factory |
129
+ | `src/api/routes/tasks.py` | Task CRUD, SSE progress, clip editing endpoints (711 lines) |
130
+ | `src/api/routes/media.py` | Fonts, transitions, uploads, templates |
131
+ | `src/services/task_service.py` | Task orchestration, clip editing logic (574 lines) |
132
+ | `src/services/video_service.py` | Video download, transcription, AI analysis, clip generation |
133
+ | `src/workers/tasks.py` | ARQ worker task definitions |
134
+ | `src/workers/job_queue.py` | Job queue management |
135
+ | `src/workers/progress.py` | Real-time progress via Redis |
136
+ | `src/ai.py` | Pydantic AI agents, system prompt, segment validation |
137
+ | `src/video_utils.py` | Video processing, cropping, subtitles (~820 lines) |
138
+ | `src/clip_editor.py` | Clip trim, split, merge, export presets |
139
+ | `src/editor_document.py` | Clip studio draft model (segments, words, captions, framing, B-roll) and server render |
140
+ | `src/workflows/` | Workflows (series, topic, recap, trailer): contracts, options/gate, units, outline, planners, solvers |
141
+ | `src/services/ai_edit_service.py` | Studio AI editing: Sonnet 5.5 plans typed operations, applied and validated here |
142
+ | `src/workers/ai_worker.py` | Light ARQ worker for AI edits (`supoclip_ai` queue, own container) |
143
+ | `src/broll.py` | Pexels API B-roll integration |
144
+ | `src/caption_templates.py` | Caption template system |
145
+ | `src/config.py` | Environment variable configuration |
146
+ | `src/social/` | Social publishing providers (YouTube, TikTok, Instagram): OAuth, upload, metrics |
147
+ | `src/services/social_service.py` | Account connections, publish/schedule, metrics refresh, AI performance context |
148
+ | `src/repositories/social_repository.py` | `social_accounts`, `social_posts`, `social_post_metrics` SQL |
149
+ | `src/api/routes/social.py` | `/social/*` routes |
150
+
151
+ ## API Endpoints (routes in `api/routes/`)
152
+
153
+ **Task lifecycle:**
154
+ - `POST /tasks/` — Create task, enqueue to worker (returns task_id); optional `workflow`, `workflow_options`, `instructions`
155
+ - `GET /tasks/workflows` — What the user can make on this platform (workflows flag, env gate, limits)
156
+ - `GET /feature-flags` — Feature flags evaluated for the caller and platform
157
+ - `GET /tasks/` — List user tasks
158
+ - `GET /tasks/{id}` — Get task with clips
159
+ - `GET /tasks/{id}/progress` — SSE real-time progress stream
160
+ - `POST /tasks/{id}/cancel` — Cancel processing
161
+ - `POST /tasks/{id}/resume` — Resume cancelled/errored task
162
+ - `DELETE /tasks/{id}` — Delete task
163
+
164
+ **Clip editing:**
165
+ - `PATCH /tasks/{id}/clips/{clip_id}` — Trim clip
166
+ - `POST /tasks/{id}/clips/{clip_id}/split` — Split at timestamp
167
+ - `POST /tasks/{id}/clips/merge` — Merge selected clips
168
+ - `PATCH /tasks/{id}/clips/{clip_id}/captions` — Update captions
169
+ - `GET /tasks/{id}/clips/{clip_id}/export?preset=tiktok` — Export with platform preset
170
+ - `GET /tasks/{id}/clips/zip` — Stream every existing clip as one ZIP, built on the fly (`clip_archive.py`); `GET .../clips/zip/preflight` runs the same checks first. One ZIP download per user at a time (Redis slot, 429)
171
+
172
+ **Media:**
173
+ - `GET /fonts`, `GET /transitions`, `GET /caption-templates`, `GET /broll/status`
174
+ - `POST /upload` — Upload video file
175
+ - `GET /clips/{filename}` — Serve generated clips
176
+
177
+ **Social publishing:**
178
+ - `GET /social/providers`, `GET /social/connections` — configured platforms and connected accounts
179
+ - `POST /social/connections/{provider}/authorize` + `/callback` — OAuth handshake (session auth only)
180
+ - `POST /social/posts` — publish or schedule a clip; `GET /social/posts?task_id=` — list with metrics
181
+ - `POST /social/posts/{id}/cancel|retry|refresh-metrics`, `DELETE /social/posts/{id}`
182
+ - `GET /social/performance` — metrics by hook type / platform / clip length (also fed into the AI prompt)
183
+ - `GET /social/performance/timeseries?days=30` — daily new views from metrics snapshots (Analytics chart)
184
+ - `GET /social/media/{token}` — public token-gated clip stream for Instagram
185
+
186
+ Worker crons (`workers/tasks.py`): every minute `dispatch_scheduled_social_posts`, hourly `refresh_social_metrics`.
187
+ Post status flow: `scheduled → queued → publishing → published/failed/cancelled`.
188
+
189
+ **API keys (programmatic access):**
190
+ - `GET /api-keys/` — List the user's API keys (metadata only)
191
+ - `POST /api-keys/` — Create a key (plaintext `sk_...` returned exactly once)
192
+ - `DELETE /api-keys/{key_id}` — Revoke a key
193
+
194
+ API keys authenticate `/tasks/*`, `/fonts` and `/upload` directly via
195
+ `Authorization: Bearer sk_...` or `x-api-key`. Resolution lives in
196
+ `auth_headers.resolve_authenticated_user_id` (API key → DB lookup, else falls
197
+ back to the frontend's HMAC-signed session headers). Only the SHA-256 hash is
198
+ stored (`api_keys` table). The frontend manages keys at `/settings/api-keys`.
199
+
200
+ ## Plans & billing
201
+
202
+ Hosted plans are **Pro** ($9.99/mo, $99.90/yr) and **Creator** ($24.99/mo, $249.90/yr).
203
+ Creator's internal plan id is still `scale` (DB `users.plan`, Stripe metadata,
204
+ RevenueCat `...scale.monthly/annual` product IDs); only the display name changed.
205
+
206
+ - **Metered in minutes of source video** per month (`PRO_/SCALE_PLAN_MINUTE_LIMIT`,
207
+ 600/1500). `tasks.source_duration_seconds` is recorded at task creation (YouTube
208
+ preflight, ffprobe for uploads) and `BillingService` sums started minutes.
209
+ Yearly subscriptions still reset monthly (`_usage_window`).
210
+ - **Resolution:** Pro gets 720p via a final `cap_video_short_side` pass on generated
211
+ clips and editor renders; Creator gets 1080p. Pro subscribers from before the
212
+ change have `users.legacy_hd` (backfilled once) and keep 1080p until they cancel.
213
+ Admins can grant or remove it per user in the `/admin` Users panel (searchable by
214
+ email/name; `PATCH /api/admin/users/{id}/legacy-hd`).
215
+ 720p plans also *download* YouTube at 720p (`reduced_media_limits` → Apify quality /
216
+ yt-dlp height cap), and their `processing_cache` key gets a `|q720` suffix so a 1080p
217
+ request never reuses a 720p source. Full-quality keys are unchanged. The durable
218
+ `youtube-cache/<video_id>` full file records its height (`full_height`, one file per
219
+ height) and is reused only at or above the requested cap; sections always use the global cap.
220
+ - **Scheduling** social posts requires Creator (`can_schedule_posts`); publishing
221
+ immediately works on Pro.
222
+ - **Annual** checkout: `interval: "year"` uses `STRIPE_PRO_/SCALE_ANNUAL_PRICE_ID`.
223
+ - **Stripe prices (2026-10):** new subscribers get new prices (lookup keys `pro_monthly_2026_10`,
224
+ `pro_yearly_2026_10`, `creator_monthly_2026_10`, `creator_yearly_2026_10`). The earlier Pro price stays
225
+ for existing subscribers via `STRIPE_PRO_LEGACY_PRICE_IDS`; the webhook maps it to Pro and sets
226
+ `legacy_hd`, so dropping it from that list would downgrade those subscribers on their next renewal.
227
+
228
+ ## Creator (affiliate) program
229
+
230
+ Creators apply at `/settings/creator-program` (public pitch page: `/affiliate`).
231
+ Admins approve/decline/revoke in the `/admin` "Creator Program" panel. Logic
232
+ lives in `frontend/src/server/affiliates.ts`; applications are the `affiliates`
233
+ table (one per user, `slug` cleared on decline).
234
+
235
+ - **Approve** creates Stripe promotion code `SLUG` on the shared coupon
236
+ `STRIPE_CREATOR_COUPON_ID` (default `creator-20-3mo`, 20% off for 3 months) and
237
+ grants Pro with `subscription_provider = "affiliate"` (Stripe/Apple webhooks
238
+ never clobber it with a non-paid state).
239
+ - **Checkout** applies the coupon from a typed/remembered code (`body.code`) or the
240
+ signup `user_acquisition.ref`. The browser remembers validated `?ref=` codes
241
+ (`lib/creator-code.ts`).
242
+ - **Emails** go through the backend `POST /account/affiliate-email` (SES): new
243
+ applications to every `is_admin` user, decisions to the applicant.
244
+ - **iOS:** creators' free Pro reaches the app through the billing summary
245
+ (`subscription_provider: "affiliate"`). The audience discount on iPhone is an
246
+ App Store offer code: custom codes on the Pro subscription's "Creator offer"
247
+ (20% off for 3 months), added by hand in App Store Connect; admins then mark
248
+ "App Store code added" and the creator page shows `appStoreRedeemUrl(code)`.
249
+ The app's paywall opens Apple's redeem sheet ("Have a creator code?").
250
+
251
+ ## Feature tours
252
+
253
+ When a change gives existing users something new to find, add a tour: an entry in
254
+ `frontend/src/lib/feature-tours.ts`, `data-tour` on its target, and text in
255
+ `frontend/messages/*/tours.json`. Explain the feature, don't just point at it. Rules and steps: `docs/feature-tours.md`.
256
+
257
+ ## Environment Variables
258
+
259
+ Required in `.env` (root) or `backend/.env`:
260
+
261
+ ```bash
262
+ ASSEMBLY_AI_API_KEY=... # Required: video transcription
263
+ TRANSCRIPTION_LANGUAGE= # Optional: empty = auto-detect; e.g. es, de, en_us forces it
264
+ LLM=google-gla:gemini-3-flash-preview # Format: provider:model-name
265
+ GOOGLE_API_KEY=... # Or OPENAI_API_KEY / ANTHROPIC_API_KEY
266
+ OLLAMA_BASE_URL=http://localhost:11434/v1 # Optional for ollama:* models
267
+ OLLAMA_API_KEY=... # Optional; required for Ollama Cloud
268
+ RERANK_LLM= # Optional; model for the long-video candidate rerank (default: LLM)
269
+ YOUTUBE_DOWNLOAD_PROVIDER=yt_dlp # yt_dlp | apify
270
+ YOUTUBE_PROXY_URL= # Optional residential proxy template; empty = off
271
+ YOUTUBE_POT_PROVIDER_URL= # Optional bgutil base URL (http://bgutil:4416)
272
+ YOUTUBE_DOWNLOAD_MAX_BYTES=2000000000
273
+ YOUTUBE_MAX_HEIGHT=1080 # Hard cap; lower values are honored
274
+ APIFY_EXPENSIVE_FALLBACKS=false # Skip high-cap Apify fallback actors
275
+
276
+ # Optional
277
+ PEXELS_API_KEY=... # B-roll stock footage
278
+ YOUTUBE_OAUTH_CLIENT_ID=... # Social publishing: Google OAuth client (+ _SECRET)
279
+ TIKTOK_CLIENT_KEY=... # Social publishing: TikTok app (+ TIKTOK_CLIENT_SECRET)
280
+ TIKTOK_APP_AUDITED=false # true only after TikTok's audit; unaudited = private posts from private accounts
281
+ INSTAGRAM_APP_ID=... # Social publishing: Meta app with Instagram Login (+ _SECRET)
282
+ SOCIAL_PERFORMANCE_MIN_POSTS=3 # Measured posts before AI selection is personalized
283
+ SOCIAL_PUBLISHING_ACCESS=off # Rollout gate: off (default) | admins (admins + allowlist) | all
284
+ SOCIAL_PUBLISHING_ALLOWED_EMAILS= # Comma-separated beta emails when access=admins
285
+ WORKFLOWS_ACCESS=admins # Series/topic/recap/trailer + instructions: off | admins | all (self-host: all)
286
+ WORKFLOWS_ALLOWED_EMAILS= # Comma-separated beta emails when access=admins
287
+ WORKFLOWS_PUBLIC= # Workflows open to everyone while access=admins, e.g. trailer,topic
288
+ WORKFLOW_TOPIC_MAX_CLIPS=15 # Most clips a topic run returns
289
+ WORKFLOW_PLAN_TIMEOUT_SECONDS=1800 # Planning wall clock; past it the task fails with plan_failed
290
+ WORKFLOW_FULL_CONTEXT_MAX_WORDS=0 # Words read in one outline call; 0 = provider default
291
+ REDIS_HOST=localhost # Default: localhost
292
+ REDIS_PORT=6379 # Default: 6379
293
+ QUEUED_TASK_TIMEOUT_SECONDS=180 # Fail-safe for stuck tasks
294
+ AI_EDIT_DAILY_LIMIT=150 # Studio AI edits per user per day (needs ANTHROPIC_API_KEY)
295
+ TEMP_DIR=/tmp # Temp file storage
296
+ DATABASE_URL=postgresql+asyncpg://...
297
+ BETTER_AUTH_SECRET=... # Frontend auth secret
298
+ ```
299
+
300
+ ## Feature flags
301
+
302
+ `feature_flags` table (key, `web_enabled`, `ios_enabled`, `admins_bypass`, description, `updated_by`):
303
+ switch a feature per platform without a deploy, in the `/admin` "Feature Flags" panel
304
+ (`/api/admin/feature-flags/[key]`, written with Prisma). `backend/src/feature_flags.py` reads them with a
305
+ 15-second in-process cache; a missing row or unreadable table falls back to `DEFAULT_FLAGS` (off, admins bypass).
306
+
307
+ - **Platform:** `x-supoclip-client: ios` from the iOS app (`AuthInterceptor`), forwarded by the web proxies
308
+ (`backendTraceHeaders` in `server/backend-api.ts`); anything else, API keys and MCP included, is web.
309
+ - **On** = the platform column, or the caller is an admin and `admins_bypass` is set.
310
+ - `GET /feature-flags` (proxied at `/api/feature-flags`) returns the evaluated booleans for the caller.
311
+ - **`workflows`:** seeded off on web and iOS (admins bypass) until the iOS build with workflows is approved.
312
+ It sits on top of `WORKFLOWS_ACCESS`: both must allow. Off hides workflows in `GET /tasks/workflows` for that
313
+ platform and makes create/resume with a workflow 403 `WORKFLOW_NOT_AVAILABLE` before any charge.
314
+ - **`tiktok_publishing`:** seeded off on web and iOS, no admin bypass, until TikTok audits the app's Direct Post
315
+ access (unaudited, TikTok rejects posts from public accounts). Off, `/social/providers` reports TikTok `configured: false,
316
+ paused: true` (the web shows a short notice; iOS hides it) and connect/options/publish/retry return 503. Self-hosters
317
+ with their own audited TikTok app turn it on in /admin.
318
+ - Adding a flag: seed it in a migration (and `init.sql`), add its default to `DEFAULT_FLAGS`, check it with
319
+ `feature_flags.is_enabled(db, key, platform=client_platform(request), user_id=...)`.
320
+
321
+ ## Common Workflows
322
+
323
+ ### Adding fonts/transitions
324
+
325
+ Drop `.ttf` files into `backend/fonts/` or `.mp4` files into `backend/transitions/`. They auto-appear via their respective `GET` endpoints.
326
+
327
+ ### Social publishing & the performance loop
328
+
329
+ Users connect accounts at `/settings/social` (OAuth via `/api/social/connect/{provider}` →
330
+ `/api/social/callback/{provider}` → backend `/social/connections/{provider}/callback`).
331
+ Publishing runs in the ARQ worker (`publish_social_post`). Metrics are pulled back hourly into
332
+ `social_post_metrics` and summarized by `SocialService.build_performance_context()`, which
333
+ `TaskService.process_task` injects into `build_transcript_analysis_prompt(performance_context=...)`.
334
+ Personalized analyses skip the shared `processing_cache` analysis entry.
335
+
336
+ - **Pages:** `/settings/social` (accounts + every scheduled post) and `/analytics` (totals, daily
337
+ views chart, top clips, breakdowns), both in the sidebar. Clips publish from the task page.
338
+ - **Rollout gate:** `SOCIAL_PUBLISHING_ACCESS` defaults to `off`. Social and Analytics stay out of
339
+ the nav, command palette, and settings until it is `admins` or `all`. Outside the gate every
340
+ `/social/*` route returns 403 except `GET /social/providers`, which reports `enabled: false` with
341
+ all platforms unconfigured (clients hide publishing unless `enabled` is exactly true) and the
342
+ disconnect routes (account deletion revokes tokens).
343
+ - **iOS app:** `POST .../authorize` with `{"client": "ios"}` prefixes the OAuth state with `m.`; the
344
+ web callback then redirects to `supoclip://social-callback?provider&code&state` and the app
345
+ completes `/callback` with its own session (the state stays bound to the starting user).
346
+ - **Platform approvals gate real users:** TikTok only allows sandbox target users until its audit,
347
+ Instagram only app testers until Meta review, and YouTube uploads from an unaudited project stay
348
+ private. Provider app IDs and setup notes are in `docs/configuration.md`.
349
+
350
+ ### Clip studio (editor)
351
+
352
+ Full-screen, classic NLE layout at `/tasks/{id}/edit` (`frontend/src/components/editor/`): clip picker in the header, viewer and
353
+ inspector on top, a full-width sequence timeline (`timeline.tsx`: V1 segments, B-roll, captions and audio tracks, in
354
+ edit time) below. Drafts are `EditDocument`s on the `clean.mp4` (source) timeline; `sequence`/`locate` map between
355
+ edit and source time. Preview and browser export draw through `lib/editor/render.ts`, the server export through
356
+ `render_document`. Generated clips' B-roll opens as editable items (`broll-panel.tsx`).
357
+
358
+ **AI editing:** the "AI edit" field under the viewer (`ai-prompt.tsx`, ⌘J) posts `POST .../editor/ai` → Redis → `ai_edit_job` on the
359
+ AI worker → Claude Sonnet 5.5 returns typed operations (`keep_ranges`, `remove_words`, `set`, `add_broll`, ...) →
360
+ `apply_plan` clamps and validates → the browser applies the result as one undoable change (never over edits made
361
+ meanwhile). Keep the output schema free of optional fields: the API rejects schemas whose grammar is too large.
362
+
363
+ ### Workflows (series, topic clips, recap, trailer)
364
+
365
+ `tasks.workflow` picks what a task makes: `highlights` (default, unchanged), `series` (Part 1..N of one
366
+ story, adjacent parts share one exact cut), `topic` (every strong moment about `workflow_options.topic`),
367
+ `recap` (one clip of the main points) or `trailer` (one teaser that never reveals the payoff). Free-text
368
+ `instructions` steer any workflow. Code lives in `backend/src/workflows/`; full design in `docs/workflows.md`.
369
+
370
+ - **Units, not timestamps:** the transcript becomes numbered sentence units (clauses for trailers); the model
371
+ returns unit ids and code converts them to word-exact seconds. A cached **source outline** (chapters, points,
372
+ arcs, payoffs) is shared by every planner. Each planner is draft → validate → one repair → deterministic solve
373
+ → critique → re-solve; budgets, contiguity and spoilers never depend on the model.
374
+ - **Locked render:** planned segments (`source_ranges`, `planned: True`) skip snapping, end extension and the
375
+ cold-open teaser; multi-range clips use explicit output offsets everywhere. The plan is saved to
376
+ `tasks.workflow_plan` before rendering; clips carry `workflow_role`, `part_number`, `workflow_meta`.
377
+ - **Invariant:** highlights without instructions is byte-identical (prompts, cache keys, job args, render path).
378
+ - **Fail loud, refund:** a workflow that can't deliver raises `WorkflowError` (`topic_not_found` with suggested
379
+ topics, `no_story`, `trailer_unbuildable`, …); its clips are deleted so the minutes are refunded, and
380
+ `error_code` drives the task page's next-step screen. Series/recap/trailer are all-or-nothing.
381
+ - **Gate:** `WORKFLOWS_ACCESS=off|admins|all` (default `admins`, plus verified `WORKFLOWS_ALLOWED_EMAILS`), checked on
382
+ create and resume; self-hosters set `all`. The `workflows` feature flag (below) must also be on for the platform. Also `WORKFLOW_TOPIC_MAX_CLIPS`, `WORKFLOW_PLAN_TIMEOUT_SECONDS`, `WORKFLOW_FULL_CONTEXT_MAX_WORDS`.
383
+ - **Frontend:** contract in `lib/workflows.ts`; results in `components/app/series-view.tsx`,
384
+ `hero-clip-view.tsx` and `workflow-failure.tsx`. MCP: `workflow`/`topic`/`part_count`/`instructions` on
385
+ `supoclip_create_clip_task`, plus `supoclip_list_workflows`.
386
+
387
+ ### Modifying AI clip selection
388
+
389
+ Edit `backend/src/ai.py`: `simplified_system_prompt` controls selection criteria, `TranscriptSegment` defines the output model, `get_most_relevant_parts_by_transcript()` runs analysis with validation.
390
+
391
+ ### Video processing constraints
392
+
393
+ - Output: 9:16 vertical format, H.264, even pixel dimensions (`round_to_even()`)
394
+ - Subtitles positioned at 75% down the frame
395
+ - Virality scoring: `hook_score`, `engagement_score`, `value_score`, `shareability_score` (0-25 each, summed to `virality_score` 0-100)
396
+ - Each segment gets an AI-written `hook_title` (3-9 words) burned into the top safe area for the first ~4s (`build_hook_title_ass` in `video_utils.py`), persisted on `generated_clips.hook_title`
397
+ - Static talking-head crops get a slow ~5% Ken Burns punch-in (`kenburns_zoom_fragment`); tracked pans and split screens keep their own motion
398
+
399
+ ## Observability
400
+
401
+ Errors and analytics go to PostHog (project "SupoClip", EU, id `314504`); logs go to
402
+ Axiom (dataset `supoclip-prod`). Everything is off unless tokens are set. Details in
403
+ `docs/observability.md`.
404
+
405
+ - **Backend/worker:** `src/observability.py` sends every log record with a traceback to
406
+ PostHog (`POSTHOG_PROJECT_TOKEN`) and stamps logs with `service`, `trace_id`, `user_id`.
407
+ The auth helpers bind the user (`bind_request_user`).
408
+ - **Web:** `posthog-js` in `instrumentation-client.ts` (analytics, replay, exceptions) via the
409
+ `/ingest` rewrite; `instrumentation.ts` reports server errors. `lib/trace-fetch.ts` tags
410
+ every `/api/*` call with `x-trace-id`, which the proxies forward to the backend.
411
+ - **Correlation:** an exception's `trace_id` property matches `trace_id` in Axiom logs
412
+ (worker jobs: `task-<id>`); the PostHog distinct id is the Better Auth user id everywhere.
413
+ - **Logs:** the `vector` service (`observability/vector.yaml`, compose profile `axiom`)
414
+ ships `supoclip-*` container logs and the host nginx's SupoClip logs.
415
+
416
+ ## iOS App
417
+
418
+ A native iOS app ships on the App Store
419
+ (https://apps.apple.com/us/app/supoclip/id6784760040, app id `6784760040`). Its
420
+ source lives outside this repo. It talks to the hosted API and bills through
421
+ RevenueCat, which is what `frontend/src/app/api/billing/revenuecat-webhook/`
422
+ serves; App Store subscribers are blocked from Stripe checkout/portal by the
423
+ "managed through the App Store" guard in the billing routes. The www references
424
+ the app via `APP_STORE_ID`/`APP_STORE_URL` in `frontend/src/lib/site.ts`
425
+ (Smart App Banner meta, JSON-LD `MobileApplication`, hero badge, footer link).
426
+
427
+ ## YouTube Downloads
428
+
429
+ `YOUTUBE_DOWNLOAD_PROVIDER` accepts `yt_dlp` (free default) or `apify`.
430
+ Apify requires `APIFY_API_TOKEN` and explicit worker configuration. Each provider
431
+ falls back to the other when available. Paid worker identities belong in private
432
+ environment configuration. See `backend/README.md` for setup.
433
+
434
+ `YOUTUBE_PROXY_URL` (empty by default) puts yt-dlp through a residential proxy
435
+ first: sticky `{session}` per job, IPv4, optional bgutil PO tokens, audio first,
436
+ then only the padded clip ranges at or below 1080p. Cached audio and sections
437
+ are reused by later edits. `APIFY_EXPENSIVE_FALLBACKS` defaults to off so
438
+ high-cap fallback actors are not called. Runbook: `docs/youtube-download.md`.
439
+
440
+ ## MCP Server
441
+
442
+ `mcp/` is a standalone [MCP](https://modelcontextprotocol.io) server
443
+ (`supoclip-mcp`, Python/FastMCP, stdio) that exposes SupoClip to MCP clients
444
+ (Claude Desktop/Code, Cursor, …). It is a thin client over the REST API.
445
+
446
+ - **Default target:** the hosted API `https://api.supoclip.com`. Override with
447
+ `SUPOCLIP_API_URL` for self-hosting (e.g. `http://localhost:8000`).
448
+ - **Auth:** a per-user API key in `SUPOCLIP_API_KEY` (see API keys above).
449
+ Self-hosters may instead use `SUPOCLIP_USER_ID` (+ `SUPOCLIP_AUTH_SECRET` when
450
+ signing is enforced).
451
+ - **Tools:** create/list/get/wait/cancel/resume/delete tasks (any workflow),
452
+ list workflows, list/download/export clips, and public discovery
453
+ (templates, transitions, fonts, B-roll).
454
+ - Run with `cd mcp && uv run supoclip-mcp`. Details in `mcp/README.md`.
CONTRIBUTING.md ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contributing to SupoClip
2
+
3
+ Thanks for your interest in improving SupoClip. By submitting a pull request,
4
+ patch, commit, issue attachment, or other contribution to this repository, you
5
+ agree to the terms below.
6
+
7
+ ## Contribution License
8
+
9
+ You represent that you have the right to submit your contribution and that it
10
+ does not knowingly violate any third-party rights.
11
+
12
+ Unless a separate written agreement says otherwise, you grant the SupoClip
13
+ project owner a perpetual, worldwide, non-exclusive, royalty-free, irrevocable
14
+ license to use, reproduce, modify, distribute, publicly perform, publicly
15
+ display, sublicense, and relicense your contribution as part of SupoClip or
16
+ related products and services.
17
+
18
+ This grant includes the right to distribute your contribution under the
19
+ AGPL-3.0 license, under future open-source licenses used by SupoClip, and under
20
+ commercial or proprietary licenses offered by the project owner.
21
+
22
+ To the maximum extent permitted by law, you waive any moral rights, neighboring
23
+ rights, or similar rights that would prevent the project owner from exercising
24
+ the license granted above.
25
+
26
+ Submitting a contribution does not give you ownership of SupoClip, any SupoClip
27
+ trademarks, or any commercial license rights beyond the public license that
28
+ applies to the repository.
29
+
30
+ ## Development
31
+
32
+ See [README.md](README.md) and [CLAUDE.md](CLAUDE.md) for local development
33
+ instructions.
34
+
35
+ ## Changelog
36
+
37
+ If a pull request changes something a person using SupoClip can see, add a line
38
+ to [CHANGELOG.md](CHANGELOG.md) at the repository root. Put it under today's
39
+ date (`## YYYY-MM-DD`, newest dates first). Write what changed for users, tag
40
+ it **New**, **Improved**, **Fixed**, or **Under the hood**, and link the pull
41
+ request. Skip internal-only or CI-only changes, or fold several of them into
42
+ one **Under the hood** line. Do not include customer names, email addresses,
43
+ user IDs, or other private details. This repository is public.
DEPLOY_NOTES.md ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # RevenueCat Apple IAP Deploy Notes
2
+
3
+ ## Completed from this session
4
+
5
+ - Vercel project identified: `fujiwarachokis-projects/supoclip`
6
+ - Vercel production URL: `https://www.supoclip.com`
7
+ - Vercel root directory: `frontend`
8
+ - Production env var added in Vercel:
9
+ - `REVENUECAT_WEBHOOK_AUTH_HEADER`
10
+ - Source: copy the value from local `frontend/.env`
11
+ - Optional override vars were not present in local `frontend/.env`, so they were not set:
12
+ - `REVENUECAT_PRO_PRODUCT_IDS`
13
+ - `REVENUECAT_SCALE_PRODUCT_IDS`
14
+
15
+ ## Manual production steps still required
16
+
17
+ 1. Confirm `REVENUECAT_WEBHOOK_AUTH_HEADER` exists in the Vercel Production environment for `supoclip`.
18
+
19
+ 2. If custom RevenueCat product identifiers are needed, set these Vercel Production env vars from the production billing configuration:
20
+ - `REVENUECAT_PRO_PRODUCT_IDS`
21
+ - `REVENUECAT_SCALE_PRODUCT_IDS`
22
+
23
+ 3. Run the Prisma migration against the production frontend database only after positively identifying the production `DATABASE_URL`:
24
+
25
+ ```bash
26
+ cd frontend
27
+ DATABASE_URL="<production-database-url>" npx prisma migrate deploy
28
+ ```
29
+
30
+ 4. Apply the backend SQL migration against the production backend database:
31
+
32
+ ```bash
33
+ psql "<production-backend-database-url>" -f backend/migrations/003_add_revenuecat_subscription_provider.sql
34
+ ```
35
+
36
+ 5. Deploy/redeploy production after the database migrations have completed.
37
+
38
+ 6. Verify the RevenueCat dashboard webhook URL is configured as:
39
+
40
+ ```text
41
+ https://www.supoclip.com/api/billing/revenuecat-webhook
42
+ ```
Dockerfile CHANGED
@@ -1,28 +1,92 @@
1
- # Use Node.js 18 (LTS)
2
- FROM node:18-alpine
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
- # Set working directory
5
- WORKDIR /app
6
 
7
- # Copy root package files
8
- COPY package.json package-lock.json ./
 
 
 
 
 
9
 
10
- # Copy client package files
11
- COPY client/package.json ./client/
12
-
13
- # Install dependencies for both backend and frontend
14
- RUN npm install
15
- RUN cd client && npm install
16
-
17
- # Copy source code
18
- COPY . .
19
-
20
- # Build the React frontend
21
- RUN npm run build
22
-
23
- # Expose Hugging Face Space port
24
- ENV PORT=7860
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  EXPOSE 7860
26
-
27
- # Start the server
28
- CMD ["npm", "start"]
 
1
+ # syntax=docker/dockerfile:1.7
2
+ # Hugging Face Space: one nonroot, CPU-only container; no Compose inside.
3
+ FROM node:22.23.4-bookworm-slim AS web-builder
4
+ WORKDIR /build/frontend
5
+ ENV NEXT_TELEMETRY_DISABLED=1 PNPM_HOME=/pnpm
6
+ ENV PATH="/pnpm:${PATH}"
7
+ RUN apt-get update && apt-get install -y --no-install-recommends openssl ca-certificates \
8
+ && rm -rf /var/lib/apt/lists/* \
9
+ && npm install -g pnpm@10.27.0
10
+ COPY frontend/package.json frontend/pnpm-lock.yaml ./
11
+ RUN --mount=type=cache,id=hf-pnpm,target=/pnpm/store \
12
+ pnpm install --frozen-lockfile --ignore-scripts --store-dir /pnpm/store
13
+ COPY frontend/ ./
14
+ COPY CHANGELOG.md ./CHANGELOG.md
15
+ ARG SPACE_HOST
16
+ ARG NEXT_PUBLIC_APP_URL
17
+ ENV NEXT_PUBLIC_API_URL=/api \
18
+ NEXT_PUBLIC_SELF_HOST=true \
19
+ NEXT_PUBLIC_LANDING_ONLY_MODE=false \
20
+ NEXT_PUBLIC_MAX_VIDEO_UPLOAD_BYTES=4000000000 \
21
+ NEXT_PUBLIC_SOCIAL_PUBLISHING=false
22
+ # Non-secret build placeholders only. Real credentials are created at runtime.
23
+ RUN export NEXT_PUBLIC_APP_URL="${NEXT_PUBLIC_APP_URL:-https://${SPACE_HOST:-localhost}}" \
24
+ DATABASE_URL="postgresql://build:build@127.0.0.1:5432/build" \
25
+ BETTER_AUTH_SECRET="build-placeholder-not-a-runtime-secret-000000" \
26
+ BACKEND_AUTH_SECRET="build-placeholder-not-a-runtime-secret-111111" \
27
+ DISABLE_SIGN_UP=true SKIP_LINT=1 NODE_OPTIONS=--max-old-space-size=4096; \
28
+ pnpm run build
29
+ RUN node scripts/build-hf-bootstrap.cjs
30
 
31
+ FROM ghcr.io/astral-sh/uv:0.13.7 AS uv-bin
32
+ FROM denoland/deno:bin-2.9.8 AS deno-bin
33
 
34
+ FROM python:3.11.17-slim-trixie AS backend-builder
35
+ COPY --from=uv-bin /uv /usr/local/bin/uv
36
+ ENV UV_LINK_MODE=copy UV_PYTHON_DOWNLOADS=never
37
+ WORKDIR /app/backend
38
+ COPY backend/pyproject.toml backend/uv.lock backend/README.md ./
39
+ RUN --mount=type=cache,id=hf-uv,target=/root/.cache/uv \
40
+ uv sync --frozen --extra cpu --no-dev --no-install-project
41
 
42
+ FROM python:3.11.17-slim-trixie AS space
43
+ ENV DEBIAN_FRONTEND=noninteractive
44
+ RUN apt-get update && apt-get install -y --no-install-recommends \
45
+ postgresql-17 postgresql-contrib redis-server nginx-light tini \
46
+ ffmpeg tesseract-ocr tesseract-ocr-eng fontconfig \
47
+ fonts-noto-core fonts-noto-cjk fonts-noto-color-emoji \
48
+ libgl1 libglib2.0-0t64 libgomp1 libstdc++6 openssl ca-certificates curl \
49
+ && fc-cache -f && rm -rf /var/lib/apt/lists/* \
50
+ && groupadd --gid 1000 user \
51
+ && useradd --uid 1000 --gid 1000 --create-home --shell /bin/sh user
52
+ COPY --from=web-builder /usr/local/bin/node /usr/local/bin/node
53
+ COPY --from=deno-bin /deno /usr/local/bin/deno
54
+ COPY --from=backend-builder --chown=1000:1000 /app/backend/.venv /app/backend/.venv
55
+ COPY --chown=1000:1000 backend/src /app/backend/src
56
+ COPY --chown=1000:1000 backend/fonts /app/backend/fonts
57
+ COPY --chown=1000:1000 backend/transitions /app/backend/transitions
58
+ COPY --from=web-builder --chown=1000:1000 /build/frontend/.next/standalone /app/frontend
59
+ COPY --from=web-builder --chown=1000:1000 /build/frontend/.next/static /app/frontend/.next/static
60
+ COPY --from=web-builder --chown=1000:1000 /build/frontend/public /app/frontend/public
61
+ COPY --from=web-builder --chown=1000:1000 /build/frontend/src/generated/prisma /app/frontend/src/generated/prisma
62
+ COPY --from=web-builder --chown=1000:1000 /build/frontend/src/generated/prisma/libquery_engine-debian-openssl-3.0.x.so.node /app/prisma-engine/libquery_engine-debian-openssl-3.0.x.so.node
63
+ COPY --from=web-builder --chown=1000:1000 /build/frontend/scripts/hf-bootstrap-owner.cjs /app/frontend/scripts/hf-bootstrap-owner.cjs
64
+ COPY --chown=1000:1000 CHANGELOG.md /app/frontend/CHANGELOG.md
65
+ COPY --chown=1000:1000 init.sql /app/init.sql
66
+ COPY --chown=1000:1000 deploy/huggingface /app/deploy/huggingface
67
+ COPY --chmod=755 deploy/huggingface/ffmpeg_limited.py /usr/local/bin/ffmpeg
68
+ RUN mkdir -p /app/backend/logs /app/backend/fonts/users /app/frontend/.next/cache /home/user/runtime /home/user/.cache \
69
+ && chown -R 1000:1000 /app/backend/logs /app/backend/fonts/users /app/frontend/.next/cache /home/user/runtime /home/user/.cache \
70
+ && chmod 700 /home/user/runtime
71
+ ENV HOME=/home/user \
72
+ PATH="/app/backend/.venv/bin:/usr/lib/postgresql/17/bin:/usr/local/bin:/usr/bin:/bin" \
73
+ PYTHONPATH=/app/backend PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1 \
74
+ NODE_ENV=production NEXT_TELEMETRY_DISABLED=1 \
75
+ PRISMA_QUERY_ENGINE_LIBRARY=/app/prisma-engine/libquery_engine-debian-openssl-3.0.x.so.node \
76
+ XDG_CACHE_HOME=/home/user/.cache DENO_DIR=/home/user/.cache/deno \
77
+ CUDA_VISIBLE_DEVICES="" \
78
+ OMP_NUM_THREADS=1 OPENBLAS_NUM_THREADS=1 MKL_NUM_THREADS=1 NUMEXPR_NUM_THREADS=1 OPENCV_FOR_THREADS_NUM=1 \
79
+ HF_RUNTIME_DIR=/home/user/runtime HF_FFMPEG_THREADS=1 \
80
+ TRANSCRIPTION_PROVIDER=whisper WHISPER_MODEL_SIZE=small WHISPER_FAST_MODEL_SIZE=small \
81
+ LLM=nvidia:minimaxai/minimax-m3.1-flash \
82
+ MAX_VIDEO_DURATION=10800 DEFAULT_PROCESSING_MODE=fast \
83
+ MAX_VIDEO_UPLOAD_BYTES=4000000000 MEDIA_UPLOAD_CONCURRENCY=1 \
84
+ SOCIAL_PUBLISHING_ACCESS=off
85
+ WORKDIR /app/backend
86
+ # No weight downloads or API calls: verify the CPU dependencies can import.
87
+ RUN python -c "import torch, cv2, whisper, asyncpg; assert torch.version.cuda is None; assert callable(whisper.load_model)"
88
+ USER user
89
  EXPOSE 7860
90
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=240s --retries=3 \
91
+ CMD curl --fail --silent http://127.0.0.1:7860/api/auth/get-session >/dev/null || exit 1
92
+ ENTRYPOINT ["/usr/bin/tini", "--", "python", "/app/deploy/huggingface/start.py"]
LICENSE ADDED
@@ -0,0 +1,661 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU AFFERO GENERAL PUBLIC LICENSE
2
+ Version 3, 19 November 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU Affero General Public License is a free, copyleft license for
11
+ software and other kinds of works, specifically designed to ensure
12
+ cooperation with the community in the case of network server software.
13
+
14
+ The licenses for most software and other practical works are designed
15
+ to take away your freedom to share and change the works. By contrast,
16
+ our General Public Licenses are intended to guarantee your freedom to
17
+ share and change all versions of a program--to make sure it remains free
18
+ software for all its users.
19
+
20
+ When we speak of free software, we are referring to freedom, not
21
+ price. Our General Public Licenses are designed to make sure that you
22
+ have the freedom to distribute copies of free software (and charge for
23
+ them if you wish), that you receive source code or can get it if you
24
+ want it, that you can change the software or use pieces of it in new
25
+ free programs, and that you know you can do these things.
26
+
27
+ Developers that use our General Public Licenses protect your rights
28
+ with two steps: (1) assert copyright on the software, and (2) offer
29
+ you this License which gives you legal permission to copy, distribute
30
+ and/or modify the software.
31
+
32
+ A secondary benefit of defending all users' freedom is that
33
+ improvements made in alternate versions of the program, if they
34
+ receive widespread use, become available for other developers to
35
+ incorporate. Many developers of free software are heartened and
36
+ encouraged by the resulting cooperation. However, in the case of
37
+ software used on network servers, this result may fail to come about.
38
+ The GNU General Public License permits making a modified version and
39
+ letting the public access it on a server without ever releasing its
40
+ source code to the public.
41
+
42
+ The GNU Affero General Public License is designed specifically to
43
+ ensure that, in such cases, the modified source code becomes available
44
+ to the community. It requires the operator of a network server to
45
+ provide the source code of the modified version running there to the
46
+ users of that server. Therefore, public use of a modified version, on
47
+ a publicly accessible server, gives the public access to the source
48
+ code of the modified version.
49
+
50
+ An older license, called the Affero General Public License and
51
+ published by Affero, was designed to accomplish similar goals. This is
52
+ a different license, not a version of the Affero GPL, but Affero has
53
+ released a new version of the Affero GPL which permits relicensing under
54
+ this license.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ TERMS AND CONDITIONS
60
+
61
+ 0. Definitions.
62
+
63
+ "This License" refers to version 3 of the GNU Affero General Public License.
64
+
65
+ "Copyright" also means copyright-like laws that apply to other kinds of
66
+ works, such as semiconductor masks.
67
+
68
+ "The Program" refers to any copyrightable work licensed under this
69
+ License. Each licensee is addressed as "you". "Licensees" and
70
+ "recipients" may be individuals or organizations.
71
+
72
+ To "modify" a work means to copy from or adapt all or part of the work
73
+ in a fashion requiring copyright permission, other than the making of an
74
+ exact copy. The resulting work is called a "modified version" of the
75
+ earlier work or a work "based on" the earlier work.
76
+
77
+ A "covered work" means either the unmodified Program or a work based
78
+ on the Program.
79
+
80
+ To "propagate" a work means to do anything with it that, without
81
+ permission, would make you directly or secondarily liable for
82
+ infringement under applicable copyright law, except executing it on a
83
+ computer or modifying a private copy. Propagation includes copying,
84
+ distribution (with or without modification), making available to the
85
+ public, and in some countries other activities as well.
86
+
87
+ To "convey" a work means any kind of propagation that enables other
88
+ parties to make or receive copies. Mere interaction with a user through
89
+ a computer network, with no transfer of a copy, is not conveying.
90
+
91
+ An interactive user interface displays "Appropriate Legal Notices"
92
+ to the extent that it includes a convenient and prominently visible
93
+ feature that (1) displays an appropriate copyright notice, and (2)
94
+ tells the user that there is no warranty for the work (except to the
95
+ extent that warranties are provided), that licensees may convey the
96
+ work under this License, and how to view a copy of this License. If
97
+ the interface presents a list of user commands or options, such as a
98
+ menu, a prominent item in the list meets this criterion.
99
+
100
+ 1. Source Code.
101
+
102
+ The "source code" for a work means the preferred form of the work
103
+ for making modifications to it. "Object code" means any non-source
104
+ form of a work.
105
+
106
+ A "Standard Interface" means an interface that either is an official
107
+ standard defined by a recognized standards body, or, in the case of
108
+ interfaces specified for a particular programming language, one that
109
+ is widely used among developers working in that language.
110
+
111
+ The "System Libraries" of an executable work include anything, other
112
+ than the work as a whole, that (a) is included in the normal form of
113
+ packaging a Major Component, but which is not part of that Major
114
+ Component, and (b) serves only to enable use of the work with that
115
+ Major Component, or to implement a Standard Interface for which an
116
+ implementation is available to the public in source code form. A
117
+ "Major Component", in this context, means a major essential component
118
+ (kernel, window system, and so on) of the specific operating system
119
+ (if any) on which the executable work runs, or a compiler used to
120
+ produce the work, or an object code interpreter used to run it.
121
+
122
+ The "Corresponding Source" for a work in object code form means all
123
+ the source code needed to generate, install, and (for an executable
124
+ work) run the object code and to modify the work, including scripts to
125
+ control those activities. However, it does not include the work's
126
+ System Libraries, or general-purpose tools or generally available free
127
+ programs which are used unmodified in performing those activities but
128
+ which are not part of the work. For example, Corresponding Source
129
+ includes interface definition files associated with source files for
130
+ the work, and the source code for shared libraries and dynamically
131
+ linked subprograms that the work is specifically designed to require,
132
+ such as by intimate data communication or control flow between those
133
+ subprograms and other parts of the work.
134
+
135
+ The Corresponding Source need not include anything that users
136
+ can regenerate automatically from other parts of the Corresponding
137
+ Source.
138
+
139
+ The Corresponding Source for a work in source code form is that
140
+ same work.
141
+
142
+ 2. Basic Permissions.
143
+
144
+ All rights granted under this License are granted for the term of
145
+ copyright on the Program, and are irrevocable provided the stated
146
+ conditions are met. This License explicitly affirms your unlimited
147
+ permission to run the unmodified Program. The output from running a
148
+ covered work is covered by this License only if the output, given its
149
+ content, constitutes a covered work. This License acknowledges your
150
+ rights of fair use or other equivalent, as provided by copyright law.
151
+
152
+ You may make, run and propagate covered works that you do not
153
+ convey, without conditions so long as your license otherwise remains
154
+ in force. You may convey covered works to others for the sole purpose
155
+ of having them make modifications exclusively for you, or provide you
156
+ with facilities for running those works, provided that you comply with
157
+ the terms of this License in conveying all material for which you do
158
+ not control copyright. Those thus making or running the covered works
159
+ for you must do so exclusively on your behalf, under your direction
160
+ and control, on terms that prohibit them from making any copies of
161
+ your copyrighted material outside their relationship with you.
162
+
163
+ Conveying under any other circumstances is permitted solely under
164
+ the conditions stated below. Sublicensing is not allowed; section 10
165
+ makes it unnecessary.
166
+
167
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
168
+
169
+ No covered work shall be deemed part of an effective technological
170
+ measure under any applicable law fulfilling obligations under article
171
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
172
+ similar laws prohibiting or restricting circumvention of such
173
+ measures.
174
+
175
+ When you convey a covered work, you waive any legal power to forbid
176
+ circumvention of technological measures to the extent such circumvention
177
+ is effected by exercising rights under this License with respect to
178
+ the covered work, and you disclaim any intention to limit operation or
179
+ modification of the work as a means of enforcing, against the work's
180
+ users, your or third parties' legal rights to forbid circumvention of
181
+ technological measures.
182
+
183
+ 4. Conveying Verbatim Copies.
184
+
185
+ You may convey verbatim copies of the Program's source code as you
186
+ receive it, in any medium, provided that you conspicuously and
187
+ appropriately publish on each copy an appropriate copyright notice;
188
+ keep intact all notices stating that this License and any
189
+ non-permissive terms added in accord with section 7 apply to the code;
190
+ keep intact all notices of the absence of any warranty; and give all
191
+ recipients a copy of this License along with the Program.
192
+
193
+ You may charge any price or no price for each copy that you convey,
194
+ and you may offer support or warranty protection for a fee.
195
+
196
+ 5. Conveying Modified Source Versions.
197
+
198
+ You may convey a work based on the Program, or the modifications to
199
+ produce it from the Program, in the form of source code under the
200
+ terms of section 4, provided that you also meet all of these conditions:
201
+
202
+ a) The work must carry prominent notices stating that you modified
203
+ it, and giving a relevant date.
204
+
205
+ b) The work must carry prominent notices stating that it is
206
+ released under this License and any conditions added under section
207
+ 7. This requirement modifies the requirement in section 4 to
208
+ "keep intact all notices".
209
+
210
+ c) You must license the entire work, as a whole, under this
211
+ License to anyone who comes into possession of a copy. This
212
+ License will therefore apply, along with any applicable section 7
213
+ additional terms, to the whole of the work, and all its parts,
214
+ regardless of how they are packaged. This License gives no
215
+ permission to license the work in any other way, but it does not
216
+ invalidate such permission if you have separately received it.
217
+
218
+ d) If the work has interactive user interfaces, each must display
219
+ Appropriate Legal Notices; however, if the Program has interactive
220
+ interfaces that do not display Appropriate Legal Notices, your
221
+ work need not make them do so.
222
+
223
+ A compilation of a covered work with other separate and independent
224
+ works, which are not by their nature extensions of the covered work,
225
+ and which are not combined with it such as to form a larger program,
226
+ in or on a volume of a storage or distribution medium, is called an
227
+ "aggregate" if the compilation and its resulting copyright are not
228
+ used to limit the access or legal rights of the compilation's users
229
+ beyond what the individual works permit. Inclusion of a covered work
230
+ in an aggregate does not cause this License to apply to the other
231
+ parts of the aggregate.
232
+
233
+ 6. Conveying Non-Source Forms.
234
+
235
+ You may convey a covered work in object code form under the terms
236
+ of sections 4 and 5, provided that you also convey the
237
+ machine-readable Corresponding Source under the terms of this License,
238
+ in one of these ways:
239
+
240
+ a) Convey the object code in, or embodied in, a physical product
241
+ (including a physical distribution medium), accompanied by the
242
+ Corresponding Source fixed on a durable physical medium
243
+ customarily used for software interchange.
244
+
245
+ b) Convey the object code in, or embodied in, a physical product
246
+ (including a physical distribution medium), accompanied by a
247
+ written offer, valid for at least three years and valid for as
248
+ long as you offer spare parts or customer support for that product
249
+ model, to give anyone who possesses the object code either (1) a
250
+ copy of the Corresponding Source for all the software in the
251
+ product that is covered by this License, on a durable physical
252
+ medium customarily used for software interchange, for a price no
253
+ more than your reasonable cost of physically performing this
254
+ conveying of source, or (2) access to copy the
255
+ Corresponding Source from a network server at no charge.
256
+
257
+ c) Convey individual copies of the object code with a copy of the
258
+ written offer to provide the Corresponding Source. This
259
+ alternative is allowed only occasionally and noncommercially, and
260
+ only if you received the object code with such an offer, in accord
261
+ with subsection 6b.
262
+
263
+ d) Convey the object code by offering access from a designated
264
+ place (gratis or for a charge), and offer equivalent access to the
265
+ Corresponding Source in the same way through the same place at no
266
+ further charge. You need not require recipients to copy the
267
+ Corresponding Source along with the object code. If the place to
268
+ copy the object code is a network server, the Corresponding Source
269
+ may be on a different server (operated by you or a third party)
270
+ that supports equivalent copying facilities, provided you maintain
271
+ clear directions next to the object code saying where to find the
272
+ Corresponding Source. Regardless of what server hosts the
273
+ Corresponding Source, you remain obligated to ensure that it is
274
+ available for as long as needed to satisfy these requirements.
275
+
276
+ e) Convey the object code using peer-to-peer transmission, provided
277
+ you inform other peers where the object code and Corresponding
278
+ Source of the work are being offered to the general public at no
279
+ charge under subsection 6d.
280
+
281
+ A separable portion of the object code, whose source code is excluded
282
+ from the Corresponding Source as a System Library, need not be
283
+ included in conveying the object code work.
284
+
285
+ A "User Product" is either (1) a "consumer product", which means any
286
+ tangible personal property which is normally used for personal, family,
287
+ or household purposes, or (2) anything designed or sold for incorporation
288
+ into a dwelling. In determining whether a product is a consumer product,
289
+ doubtful cases shall be resolved in favor of coverage. For a particular
290
+ product received by a particular user, "normally used" refers to a
291
+ typical or common use of that class of product, regardless of the status
292
+ of the particular user or of the way in which the particular user
293
+ actually uses, or expects or is expected to use, the product. A product
294
+ is a consumer product regardless of whether the product has substantial
295
+ commercial, industrial or non-consumer uses, unless such uses represent
296
+ the only significant mode of use of the product.
297
+
298
+ "Installation Information" for a User Product means any methods,
299
+ procedures, authorization keys, or other information required to install
300
+ and execute modified versions of a covered work in that User Product from
301
+ a modified version of its Corresponding Source. The information must
302
+ suffice to ensure that the continued functioning of the modified object
303
+ code is in no case prevented or interfered with solely because
304
+ modification has been made.
305
+
306
+ If you convey an object code work under this section in, or with, or
307
+ specifically for use in, a User Product, and the conveying occurs as
308
+ part of a transaction in which the right of possession and use of the
309
+ User Product is transferred to the recipient in perpetuity or for a
310
+ fixed term (regardless of how the transaction is characterized), the
311
+ Corresponding Source conveyed under this section must be accompanied
312
+ by the Installation Information. But this requirement does not apply
313
+ if neither you nor any third party retains the ability to install
314
+ modified object code on the User Product (for example, the work has
315
+ been installed in ROM).
316
+
317
+ The requirement to provide Installation Information does not include a
318
+ requirement to continue to provide support service, warranty, or updates
319
+ for a work that has been modified or installed by the recipient, or for
320
+ the User Product in which it has been modified or installed. Access to a
321
+ network may be denied when the modification itself materially and
322
+ adversely affects the operation of the network or violates the rules and
323
+ protocols for communication across the network.
324
+
325
+ Corresponding Source conveyed, and Installation Information provided,
326
+ in accord with this section must be in a format that is publicly
327
+ documented (and with an implementation available to the public in
328
+ source code form), and must require no special password or key for
329
+ unpacking, reading or copying.
330
+
331
+ 7. Additional Terms.
332
+
333
+ "Additional permissions" are terms that supplement the terms of this
334
+ License by making exceptions from one or more of its conditions.
335
+ Additional permissions that are applicable to the entire Program shall
336
+ be treated as though they were included in this License, to the extent
337
+ that they are valid under applicable law. If additional permissions
338
+ apply only to part of the Program, that part may be used separately
339
+ under those permissions, but the entire Program remains governed by
340
+ this License without regard to the additional permissions.
341
+
342
+ When you convey a copy of a covered work, you may at your option
343
+ remove any additional permissions from that copy, or from any part of
344
+ it. (Additional permissions may be written to require their own
345
+ removal in certain cases when you modify the work.) You may place
346
+ additional permissions on material, added by you to a covered work,
347
+ for which you have or can give appropriate copyright permission.
348
+
349
+ Notwithstanding any other provision of this License, for material you
350
+ add to a covered work, you may (if authorized by the copyright holders of
351
+ that material) supplement the terms of this License with terms:
352
+
353
+ a) Disclaiming warranty or limiting liability differently from the
354
+ terms of sections 15 and 16 of this License; or
355
+
356
+ b) Requiring preservation of specified reasonable legal notices or
357
+ author attributions in that material or in the Appropriate Legal
358
+ Notices displayed by works containing it; or
359
+
360
+ c) Prohibiting misrepresentation of the origin of that material, or
361
+ requiring that modified versions of such material be marked in
362
+ reasonable ways as different from the original version; or
363
+
364
+ d) Limiting the use for publicity purposes of names of licensors or
365
+ authors of the material; or
366
+
367
+ e) Declining to grant rights under trademark law for use of some
368
+ trade names, trademarks, or service marks; or
369
+
370
+ f) Requiring indemnification of licensors and authors of that
371
+ material by anyone who conveys the material (or modified versions of
372
+ it) with contractual assumptions of liability to the recipient, for
373
+ any liability that these contractual assumptions directly impose on
374
+ those licensors and authors.
375
+
376
+ All other non-permissive additional terms are considered "further
377
+ restrictions" within the meaning of section 10. If the Program as you
378
+ received it, or any part of it, contains a notice stating that it is
379
+ governed by this License along with a term that is a further
380
+ restriction, you may remove that term. If a license document contains
381
+ a further restriction but permits relicensing or conveying under this
382
+ License, you may add to a covered work material governed by the terms
383
+ of that license document, provided that the further restriction does
384
+ not survive such relicensing or conveying.
385
+
386
+ If you add terms to a covered work in accord with this section, you
387
+ must place, in the relevant source files, a statement of the
388
+ additional terms that apply to those files, or a notice indicating
389
+ where to find the applicable terms.
390
+
391
+ Additional terms, permissive or non-permissive, may be stated in the
392
+ form of a separately written license, or stated as exceptions;
393
+ the above requirements apply either way.
394
+
395
+ 8. Termination.
396
+
397
+ You may not propagate or modify a covered work except as expressly
398
+ provided under this License. Any attempt otherwise to propagate or
399
+ modify it is void, and will automatically terminate your rights under
400
+ this License (including any patent licenses granted under the third
401
+ paragraph of section 11).
402
+
403
+ However, if you cease all violation of this License, then your
404
+ license from a particular copyright holder is reinstated (a)
405
+ provisionally, unless and until the copyright holder explicitly and
406
+ finally terminates your license, and (b) permanently, if the copyright
407
+ holder fails to notify you of the violation by some reasonable means
408
+ prior to 60 days after the cessation.
409
+
410
+ Moreover, your license from a particular copyright holder is
411
+ reinstated permanently if the copyright holder notifies you of the
412
+ violation by some reasonable means, this is the first time you have
413
+ received notice of violation of this License (for any work) from that
414
+ copyright holder, and you cure the violation prior to 30 days after
415
+ your receipt of the notice.
416
+
417
+ Termination of your rights under this section does not terminate the
418
+ licenses of parties who have received copies or rights from you under
419
+ this License. If your rights have been terminated and not permanently
420
+ reinstated, you do not qualify to receive new licenses for the same
421
+ material under section 10.
422
+
423
+ 9. Acceptance Not Required for Having Copies.
424
+
425
+ You are not required to accept this License in order to receive or
426
+ run a copy of the Program. Ancillary propagation of a covered work
427
+ occurring solely as a consequence of using peer-to-peer transmission
428
+ to receive a copy likewise does not require acceptance. However,
429
+ nothing other than this License grants you permission to propagate or
430
+ modify any covered work. These actions infringe copyright if you do
431
+ not accept this License. Therefore, by modifying or propagating a
432
+ covered work, you indicate your acceptance of this License to do so.
433
+
434
+ 10. Automatic Licensing of Downstream Recipients.
435
+
436
+ Each time you convey a covered work, the recipient automatically
437
+ receives a license from the original licensors, to run, modify and
438
+ propagate that work, subject to this License. You are not responsible
439
+ for enforcing compliance by third parties with this License.
440
+
441
+ An "entity transaction" is a transaction transferring control of an
442
+ organization, or substantially all assets of one, or subdividing an
443
+ organization, or merging organizations. If propagation of a covered
444
+ work results from an entity transaction, each party to that
445
+ transaction who receives a copy of the work also receives whatever
446
+ licenses to the work the party's predecessor in interest had or could
447
+ give under the previous paragraph, plus a right to possession of the
448
+ Corresponding Source of the work from the predecessor in interest, if
449
+ the predecessor has it or can get it with reasonable efforts.
450
+
451
+ You may not impose any further restrictions on the exercise of the
452
+ rights granted or affirmed under this License. For example, you may
453
+ not impose a license fee, royalty, or other charge for exercise of
454
+ rights granted under this License, and you may not initiate litigation
455
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
456
+ any patent claim is infringed by making, using, selling, offering for
457
+ sale, or importing the Program or any portion of it.
458
+
459
+ 11. Patents.
460
+
461
+ A "contributor" is a copyright holder who authorizes use under this
462
+ License of the Program or a work on which the Program is based. The
463
+ work thus licensed is called the contributor's "contributor version".
464
+
465
+ A contributor's "essential patent claims" are all patent claims
466
+ owned or controlled by the contributor, whether already acquired or
467
+ hereafter acquired, that would be infringed by some manner, permitted
468
+ by this License, of making, using, or selling its contributor version,
469
+ but do not include claims that would be infringed only as a
470
+ consequence of further modification of the contributor version. For
471
+ purposes of this definition, "control" includes the right to grant
472
+ patent sublicenses in a manner consistent with the requirements of
473
+ this License.
474
+
475
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
476
+ patent license under the contributor's essential patent claims, to
477
+ make, use, sell, offer for sale, import and otherwise run, modify and
478
+ propagate the contents of its contributor version.
479
+
480
+ In the following three paragraphs, a "patent license" is any express
481
+ agreement or commitment, however denominated, not to enforce a patent
482
+ (such as an express permission to practice a patent or covenant not to
483
+ sue for patent infringement). To "grant" such a patent license to a
484
+ party means to make such an agreement or commitment not to enforce a
485
+ patent against the party.
486
+
487
+ If you convey a covered work, knowingly relying on a patent license,
488
+ and the Corresponding Source of the work is not available for anyone
489
+ to copy, free of charge and under the terms of this License, through a
490
+ publicly available network server or other readily accessible means,
491
+ then you must either (1) cause the Corresponding Source to be so
492
+ available, or (2) arrange to deprive yourself of the benefit of the
493
+ patent license for this particular work, or (3) arrange, in a manner
494
+ consistent with the requirements of this License, to extend the patent
495
+ license to downstream recipients. "Knowingly relying" means you have
496
+ actual knowledge that, but for the patent license, your conveying the
497
+ covered work in a country, or your recipient's use of the covered work
498
+ in a country, would infringe one or more identifiable patents in that
499
+ country that you have reason to believe are valid.
500
+
501
+ If, pursuant to or in connection with a single transaction or
502
+ arrangement, you convey, or propagate by procuring conveyance of, a
503
+ covered work, and grant a patent license to some of the parties
504
+ receiving the covered work authorizing them to use, propagate, modify
505
+ or convey a specific copy of the covered work, then the patent license
506
+ you grant is automatically extended to all recipients of the covered
507
+ work and works based on it.
508
+
509
+ A patent license is "discriminatory" if it does not include within
510
+ the scope of its coverage, prohibits the exercise of, or is
511
+ conditioned on the non-exercise of one or more of the rights that are
512
+ specifically granted under this License. You may not convey a covered
513
+ work if you are a party to an arrangement with a third party that is
514
+ in the business of distributing software, under which you make payment
515
+ to the third party based on the extent of your activity of conveying
516
+ the work, and under which the third party grants, to any of the
517
+ parties who would receive the covered work from you, a discriminatory
518
+ patent license (a) in connection with copies of the covered work
519
+ conveyed by you (or copies made from those copies), or (b) primarily
520
+ for and in connection with specific products or compilations that
521
+ contain the covered work, unless you entered into that arrangement,
522
+ or that patent license was granted, prior to 28 March 2007.
523
+
524
+ Nothing in this License shall be construed as excluding or limiting
525
+ any implied license or other defenses to infringement that may
526
+ otherwise be available to you under applicable patent law.
527
+
528
+ 12. No Surrender of Others' Freedom.
529
+
530
+ If conditions are imposed on you (whether by court order, agreement or
531
+ otherwise) that contradict the conditions of this License, they do not
532
+ excuse you from the conditions of this License. If you cannot convey a
533
+ covered work so as to satisfy simultaneously your obligations under this
534
+ License and any other pertinent obligations, then as a consequence you may
535
+ not convey it at all. For example, if you agree to terms that obligate you
536
+ to collect a royalty for further conveying from those to whom you convey
537
+ the Program, the only way you could satisfy both those terms and this
538
+ License would be to refrain entirely from conveying the Program.
539
+
540
+ 13. Remote Network Interaction; Use with the GNU General Public License.
541
+
542
+ Notwithstanding any other provision of this License, if you modify the
543
+ Program, your modified version must prominently offer all users
544
+ interacting with it remotely through a computer network (if your version
545
+ supports such interaction) an opportunity to receive the Corresponding
546
+ Source of your version by providing access to the Corresponding Source
547
+ from a network server at no charge, through some standard or customary
548
+ means of facilitating copying of software. This Corresponding Source
549
+ shall include the Corresponding Source for any work covered by version 3
550
+ of the GNU General Public License that is incorporated pursuant to the
551
+ following paragraph.
552
+
553
+ Notwithstanding any other provision of this License, you have
554
+ permission to link or combine any covered work with a work licensed
555
+ under version 3 of the GNU General Public License into a single
556
+ combined work, and to convey the resulting work. The terms of this
557
+ License will continue to apply to the part which is the covered work,
558
+ but the work with which it is combined will remain governed by version
559
+ 3 of the GNU General Public License.
560
+
561
+ 14. Revised Versions of this License.
562
+
563
+ The Free Software Foundation may publish revised and/or new versions of
564
+ the GNU Affero General Public License from time to time. Such new versions
565
+ will be similar in spirit to the present version, but may differ in detail to
566
+ address new problems or concerns.
567
+
568
+ Each version is given a distinguishing version number. If the
569
+ Program specifies that a certain numbered version of the GNU Affero General
570
+ Public License "or any later version" applies to it, you have the
571
+ option of following the terms and conditions either of that numbered
572
+ version or of any later version published by the Free Software
573
+ Foundation. If the Program does not specify a version number of the
574
+ GNU Affero General Public License, you may choose any version ever published
575
+ by the Free Software Foundation.
576
+
577
+ If the Program specifies that a proxy can decide which future
578
+ versions of the GNU Affero General Public License can be used, that proxy's
579
+ public statement of acceptance of a version permanently authorizes you
580
+ to choose that version for the Program.
581
+
582
+ Later license versions may give you additional or different
583
+ permissions. However, no additional obligations are imposed on any
584
+ author or copyright holder as a result of your choosing to follow a
585
+ later version.
586
+
587
+ 15. Disclaimer of Warranty.
588
+
589
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
590
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
591
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
592
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
593
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
594
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
595
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
596
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
597
+
598
+ 16. Limitation of Liability.
599
+
600
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
601
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
602
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
603
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
604
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
605
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
606
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
607
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
608
+ SUCH DAMAGES.
609
+
610
+ 17. Interpretation of Sections 15 and 16.
611
+
612
+ If the disclaimer of warranty and limitation of liability provided
613
+ above cannot be given local legal effect according to their terms,
614
+ reviewing courts shall apply local law that most closely approximates
615
+ an absolute waiver of all civil liability in connection with the
616
+ Program, unless a warranty or assumption of liability accompanies a
617
+ copy of the Program in return for a fee.
618
+
619
+ END OF TERMS AND CONDITIONS
620
+
621
+ How to Apply These Terms to Your New Programs
622
+
623
+ If you develop a new program, and you want it to be of the greatest
624
+ possible use to the public, the best way to achieve this is to make it
625
+ free software which everyone can redistribute and change under these terms.
626
+
627
+ To do so, attach the following notices to the program. It is safest
628
+ to attach them to the start of each source file to most effectively
629
+ state the exclusion of warranty; and each file should have at least
630
+ the "copyright" line and a pointer to where the full notice is found.
631
+
632
+ <one line to give the program's name and a brief idea of what it does.>
633
+ Copyright (C) 2025 Sami Hindi
634
+
635
+ This program is free software: you can redistribute it and/or modify
636
+ it under the terms of the GNU Affero General Public License as published
637
+ by the Free Software Foundation, either version 3 of the License, or
638
+ (at your option) any later version.
639
+
640
+ This program is distributed in the hope that it will be useful,
641
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
642
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
643
+ GNU Affero General Public License for more details.
644
+
645
+ You should have received a copy of the GNU Affero General Public License
646
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
647
+
648
+ Also add information on how to contact you by electronic and paper mail.
649
+
650
+ If your software can interact with users remotely through a computer
651
+ network, you should also make sure that it provides a way for users to
652
+ get its source. For example, if your program is a web application, its
653
+ interface could display a "Source" link that leads users to an archive
654
+ of the code. There are many ways you could offer source, and different
655
+ solutions will be better for different programs; see section 13 for the
656
+ specific requirements.
657
+
658
+ You should also get your employer (if you work as a programmer) or school,
659
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
660
+ For more information on this, and how to apply and follow the GNU AGPL, see
661
+ <https://www.gnu.org/licenses/>.
Makefile ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ BACKEND_TEST_ENV = DATABASE_URL=$${TEST_DATABASE_URL:-$${DATABASE_URL:-postgresql+asyncpg://supoclip:supoclip_password@127.0.0.1:5432/supoclip}} REDIS_HOST=$${REDIS_HOST:-127.0.0.1} REDIS_PORT=$${REDIS_PORT:-6379}
2
+ FRONTEND_TEST_ENV = DATABASE_URL=$${TEST_DATABASE_URL:-$${DATABASE_URL:-postgresql://supoclip:supoclip_password@127.0.0.1:5432/supoclip}} BACKEND_AUTH_SECRET=$${BACKEND_AUTH_SECRET:-supoclip_test_secret} BETTER_AUTH_SECRET=$${BETTER_AUTH_SECRET:-supoclip_better_auth_test_secret} NEXT_PUBLIC_SELF_HOST=true
3
+
4
+ .PHONY: test check test-backend test-frontend test-e2e test-ci
5
+
6
+ test: test-backend test-frontend
7
+
8
+ test-backend:
9
+ cd backend && uv sync --frozen --all-groups
10
+ cd backend && $(BACKEND_TEST_ENV) .venv/bin/pytest
11
+
12
+ test-frontend:
13
+ cd frontend && pnpm install --frozen-lockfile
14
+ cd frontend && $(FRONTEND_TEST_ENV) pnpm run test:coverage
15
+
16
+ test-e2e:
17
+ cd frontend && pnpm install --frozen-lockfile
18
+ cd frontend && $(FRONTEND_TEST_ENV) pnpm exec playwright install --with-deps
19
+ cd frontend && $(FRONTEND_TEST_ENV) pnpm run test:e2e
20
+
21
+ check:
22
+ cd frontend && pnpm run lint && pnpm run typecheck
23
+
24
+ test-ci: check test-backend test-frontend test-e2e
QUICKSTART.md ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SupoClip Quick Start Guide
2
+
3
+ Run SupoClip with Docker in just one command!
4
+
5
+ ## Prerequisites
6
+
7
+ 1. **Docker Desktop** installed and running
8
+ 2. **API Keys** (get these from the providers):
9
+ - [AssemblyAI API Key](https://www.assemblyai.com/) (required for transcription)
10
+ - At least one AI provider:
11
+ - [OpenAI API Key](https://platform.openai.com/api-keys) (recommended)
12
+ - [Google AI API Key](https://makersuite.google.com/app/apikey)
13
+ - [Anthropic API Key](https://console.anthropic.com/)
14
+ - [Ollama](https://ollama.com/) (local/self-hosted, no API key required for local)
15
+
16
+ ## Quick Start (Single Command)
17
+
18
+ ```bash
19
+ ./start.sh
20
+ ```
21
+
22
+ That's it! The script will:
23
+ - Check prerequisites
24
+ - Build Docker images
25
+ - Start all services
26
+ - Show you where to access the app
27
+
28
+ ## First Time Setup
29
+
30
+ ### 1. Configure Environment Variables
31
+
32
+ Edit the `.env` file in the project root and add your API keys:
33
+
34
+ ```bash
35
+ # Required for video transcription
36
+ ASSEMBLY_AI_API_KEY=your_assemblyai_key_here
37
+
38
+ # Choose one AI provider for clip selection
39
+ OPENAI_API_KEY=your_openai_key_here
40
+
41
+ # Configure which AI model to use
42
+ LLM=openai:gpt-4
43
+
44
+ # OR use Ollama locally
45
+ # LLM=ollama:gpt-oss:20b
46
+ # OLLAMA_BASE_URL=http://localhost:11434/v1
47
+
48
+ # Optional: Amazon SES for subscription lifecycle emails
49
+ # Required if you want hosted billing emails when SELF_HOST=false
50
+ # AWS_REGION=us-east-1
51
+ # AWS_ACCESS_KEY_ID=your_aws_access_key_id
52
+ # AWS_SECRET_ACCESS_KEY=your_aws_secret_access_key
53
+ # SES_FROM_EMAIL="SupoClip <onboarding@example.com>"
54
+ ```
55
+
56
+ ### 2. Start SupoClip
57
+
58
+ ```bash
59
+ ./start.sh
60
+ ```
61
+
62
+ ### 3. Access the Application
63
+
64
+ - **Frontend**: http://localhost:3107
65
+ - **Backend API**: http://localhost:8000
66
+ - **API Documentation**: http://localhost:8000/docs
67
+
68
+ These URLs assume the copied `.env.example`, which sets `FRONTEND_PORT=3107`.
69
+ Existing `.env` files without that setting keep Docker host port `3001`.
70
+ Preserve your existing port when using a production reverse proxy.
71
+
72
+ ## Manual Docker Commands
73
+
74
+ If you prefer to use Docker commands directly:
75
+
76
+ ```bash
77
+ # Start all services
78
+ docker-compose up -d --build
79
+
80
+ # View logs
81
+ docker-compose logs -f
82
+
83
+ # Stop all services
84
+ docker-compose down
85
+
86
+ # Rebuild after code changes
87
+ docker-compose up -d --build
88
+ ```
89
+
90
+ ## Environment Configuration
91
+
92
+ ### Required Variables
93
+
94
+ | Variable | Description | Where to Get |
95
+ |----------|-------------|--------------|
96
+ | `ASSEMBLY_AI_API_KEY` | Speech-to-text transcription | https://www.assemblyai.com/ |
97
+ | `LLM` | AI model identifier | e.g., `openai:gpt-5.2` or `ollama:gpt-oss:20b` |
98
+
99
+ ### Optional Variables
100
+
101
+ | Variable | Default | Description |
102
+ |----------|---------|-------------|
103
+ | `WHISPER_MODEL_SIZE` | `medium` | Whisper model size (tiny/base/small/medium/large) |
104
+ | `BETTER_AUTH_SECRET` | dev secret | Auth secret (change in production!) |
105
+ | `GOOGLE_API_KEY` | - | For Google Gemini models |
106
+ | `ANTHROPIC_API_KEY` | - | For Claude models |
107
+ | `OPENROUTER_API_KEY` | - | For `openrouter:*` models |
108
+ | `OLLAMA_BASE_URL` | `http://localhost:11434/v1` | For local/self-hosted Ollama endpoint |
109
+ | `OLLAMA_API_KEY` | - | Optional, required for Ollama Cloud |
110
+ | `AWS_REGION` | `us-east-1` | Optional in self-host mode, required for hosted billing emails |
111
+ | `AWS_ACCESS_KEY_ID` | - | Optional in self-host mode, required for hosted billing emails |
112
+ | `AWS_SECRET_ACCESS_KEY` | - | Optional in self-host mode, required for hosted billing emails |
113
+ | `SES_FROM_EMAIL` | `SupoClip <onboarding@example.com>` | Verified sender for backend subscription emails |
114
+
115
+ ### Hosted Billing Email Setup
116
+
117
+ If you enable hosted monetization with `SELF_HOST=false`, set these as well:
118
+
119
+ | Variable | Description |
120
+ |----------|-------------|
121
+ | `BACKEND_AUTH_SECRET` | Shared secret used by frontend API routes to call the backend |
122
+ | `STRIPE_SECRET_KEY` | Stripe server-side API key |
123
+ | `STRIPE_WEBHOOK_SECRET` | Stripe webhook signing secret |
124
+ | `STRIPE_PRO_PRICE_ID` | Stripe price ID for the $9.99/month Pro subscription |
125
+ | `STRIPE_SCALE_PRICE_ID` | Stripe price ID for the $24.99/month Creator subscription |
126
+ | `STRIPE_PRO_ANNUAL_PRICE_ID` | Stripe price ID for the $99.90/year Pro subscription |
127
+ | `STRIPE_SCALE_ANNUAL_PRICE_ID` | Stripe price ID for the $249.90/year Creator subscription |
128
+ | `STRIPE_PRICE_ID` | Legacy fallback Stripe price ID for the Pro subscription |
129
+ | `PRO_PLAN_MINUTE_LIMIT` | Pro monthly allowance in minutes of source video, usually `600` |
130
+ | `SCALE_PLAN_MINUTE_LIMIT` | Creator monthly allowance in minutes of source video, usually `1500` |
131
+ | `AWS_REGION` | AWS region used for Amazon SES, default `us-east-1` |
132
+ | `AWS_ACCESS_KEY_ID` | AWS access key ID used to send subscription emails via Amazon SES |
133
+ | `AWS_SECRET_ACCESS_KEY` | AWS secret access key used to send subscription emails via Amazon SES |
134
+ | `SES_FROM_EMAIL` | Verified sender address used for subscription emails |
135
+
136
+ The billing flow sends:
137
+
138
+ - A thank-you email after `checkout.session.completed`
139
+ - A cancellation email after `customer.subscription.deleted`
140
+
141
+ ## Supported AI Models
142
+
143
+ ### OpenAI (Recommended)
144
+ ```bash
145
+ LLM=openai:gpt-4
146
+ LLM=openai:gpt-4-turbo
147
+ LLM=openai:gpt-3.5-turbo
148
+ ```
149
+
150
+ ### Anthropic
151
+ ```bash
152
+ LLM=anthropic:claude-3-5-sonnet-20241022
153
+ LLM=anthropic:claude-3-opus
154
+ LLM=anthropic:claude-3-haiku
155
+ ```
156
+
157
+ ### Google
158
+ ```bash
159
+ LLM=google-gla:gemini-3-flash-preview
160
+ LLM=google-gla:gemini-3-pro-preview
161
+ ```
162
+
163
+ ### Ollama
164
+ ```bash
165
+ LLM=ollama:gpt-oss:20b
166
+ OLLAMA_BASE_URL=http://localhost:11434/v1
167
+ ```
168
+
169
+ ## Troubleshooting
170
+
171
+ ### Services not starting?
172
+
173
+ 1. **Check Docker is running**:
174
+ ```bash
175
+ docker info
176
+ ```
177
+
178
+ 2. **View service logs**:
179
+ ```bash
180
+ docker-compose logs -f
181
+ ```
182
+
183
+ 3. **Check service health**:
184
+ ```bash
185
+ docker-compose ps
186
+ ```
187
+
188
+ ### API Keys not working?
189
+
190
+ 1. Verify keys are set in `.env` file
191
+ 2. Ensure no extra spaces around the `=` sign
192
+ 3. Restart services after changing `.env`:
193
+ ```bash
194
+ docker-compose down
195
+ docker-compose up -d
196
+ ```
197
+
198
+ ### Database issues?
199
+
200
+ Reset the database:
201
+ ```bash
202
+ docker-compose down -v # WARNING: This deletes all data!
203
+ docker-compose up -d
204
+ ```
205
+
206
+ ## Architecture
207
+
208
+ SupoClip runs 4 Docker containers:
209
+
210
+ 1. **Frontend** (Next.js 15) - Port 3107
211
+ 2. **Backend** (FastAPI + Python) - Port 8000
212
+ 3. **PostgreSQL** - Port 5432
213
+ 4. **Redis** - Port 6379
214
+
215
+ All services are connected via a Docker network and start automatically with proper health checks.
216
+
217
+ ## What Happens When You Run `./start.sh`?
218
+
219
+ 1. Checks if `.env` file exists with required API keys
220
+ 2. Verifies Docker is running
221
+ 3. Builds Docker images (first time: ~5-10 minutes)
222
+ 4. Starts PostgreSQL and waits for it to be healthy
223
+ 5. Starts Redis cache
224
+ 6. Starts backend API server
225
+ 7. Starts frontend web server
226
+ 8. Displays URLs for accessing the application
227
+
228
+ ## Production Deployment
229
+
230
+ For production use:
231
+
232
+ 1. Change `BETTER_AUTH_SECRET` to a secure random string
233
+ 2. Use strong database passwords
234
+ 3. Enable HTTPS with a reverse proxy (nginx/Caddy)
235
+ 4. Set up persistent volumes for data
236
+ 5. Configure backup strategies
237
+
238
+ ## Next Steps
239
+
240
+ - Read the full documentation in `CLAUDE.md`
241
+ - Check out the API docs at http://localhost:8000/docs
242
+ - View example clips in the frontend
243
+ - Customize fonts by adding TTF files to `backend/fonts/`
244
+ - Add transition effects by adding MP4 files to `backend/transitions/`
245
+
246
+ ## Getting Help
247
+
248
+ - Check logs: `docker-compose logs -f`
249
+ - View API documentation: http://localhost:8000/docs
250
+ - Report issues: Create a GitHub issue with logs and error messages
README.md CHANGED
@@ -1,4 +1,146 @@
1
  ---
2
- title: Vector
3
  sdk: docker
 
 
 
 
4
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: SupoClip
3
  sdk: docker
4
+ app_port: 7860
5
+ suggested_hardware: cpu-basic
6
+ startup_duration_timeout: 30m
7
+ short_description: Personal video clipping with hosted AI and CPU rendering
8
  ---
9
+
10
+ ## Hugging Face Docker Space
11
+
12
+ This checkout includes a CPU-only, single-container Space deployment. No local
13
+ Docker install is required to upload it to Hugging Face. See the
14
+ [Space setup guide](docs/hugging-face-spaces.md) for upload files, owner-login
15
+ Secrets, NVIDIA configuration, and optional bucket guidance.
16
+
17
+ The Space is owner-only by default and uses temporary local storage. Download
18
+ clips you want to keep: accounts, saved settings, and files can disappear on a
19
+ rebuild or restart. A 48-hour inactivity policy is not a storage guarantee.
20
+
21
+ <p align="center">
22
+ <a href="https://www.supoclip.com">
23
+ <img src="assets/banner.jpg" alt="SupoClip dashboard with video input, caption controls, and recent clips" width="100%" />
24
+ </a>
25
+ </p>
26
+
27
+ <h3 align="center">Fuck OpusClip.</h3>
28
+
29
+ <p align="center">
30
+ ... because good video clips shouldn't come with ugly watermarks or platform lock-in.
31
+ </p>
32
+
33
+ <p align="center">
34
+ <a href="LICENSE"><img src="https://img.shields.io/badge/license-AGPL--3.0-blue.svg" alt="License: AGPL-3.0" /></a>
35
+ <a href="https://www.supoclip.com"><img src="https://img.shields.io/badge/hosted-supoclip.com-black.svg" alt="Hosted at supoclip.com" /></a>
36
+ <a href="docs/README.md"><img src="https://img.shields.io/badge/docs-docs%2F-green.svg" alt="Documentation" /></a>
37
+ </p>
38
+
39
+ <p align="center">
40
+ <a href="https://apps.apple.com/us/app/supoclip/id6784760040">
41
+ <img src="frontend/public/app-store-badge.svg" alt="Download SupoClip on the App Store" height="40" />
42
+ </a>
43
+ &nbsp;
44
+ <a href="https://www.producthunt.com/products/supoclip?embed=true&utm_source=badge-featured&utm_medium=badge&utm_campaign=badge-supoclip" target="_blank" rel="noopener noreferrer">
45
+ <img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=1276786&theme=dark" alt="SupoClip on Product Hunt" height="40" />
46
+ </a>
47
+ </p>
48
+
49
+ ---
50
+
51
+ SupoClip is an open-source, AI-powered video clipping tool. Give it a long video — a podcast, a talk, a stream VOD — and it finds the most viral-worthy moments, scores them, and renders them as vertical 9:16 clips with face-centered cropping, word-synced subtitles, hook titles, and optional B-roll. Run it yourself, customize it, inspect it — or use the hosted version and skip the setup.
52
+
53
+ **See it first:** [watch real clips SupoClip generated](https://www.supoclip.com/demo) from a long-form interview, or follow the [self-hosting tutorial](https://www.supoclip.com/blog/self-host-supoclip-docker) to run it on your own machine.
54
+
55
+ ## Ways to Use SupoClip
56
+
57
+ | Option | Details |
58
+ |---|---|
59
+ | **Hosted web app** | [www.supoclip.com](https://www.supoclip.com) — no infrastructure to run |
60
+ | **iOS app** | [SupoClip on the App Store](https://apps.apple.com/us/app/supoclip/id6784760040) — the same hosted pipeline, from your iPhone |
61
+ | **Self-host** | Docker Compose setup below, or the step-by-step [self-hosting tutorial](https://www.supoclip.com/blog/self-host-supoclip-docker) — AGPL-3.0, unlimited usage on your own hardware |
62
+ | **MCP server** | [`mcp/`](mcp/) — use SupoClip from Claude, Cursor, and other MCP clients |
63
+ | **REST API** | API keys from `/settings/api-keys` authenticate the backend directly — see the [API reference](docs/api-reference.md) |
64
+
65
+ ## Why SupoClip Exists
66
+
67
+ OpusClip is genuinely good at what it does — AI clip selection, accurate captions, virality scoring. But your usage is metered by plan, some exports carry platform branding, and your content and workflows live on their servers under their terms.
68
+
69
+ SupoClip gives you the same core pipeline without the leash:
70
+
71
+ - **Self-hostable** — run it on your own hardware, process as much as it can handle
72
+ - **No watermarks** — your content stays yours
73
+ - **Open source** — AGPL-3.0, full transparency, fork and extend it however you like
74
+ - **Hosted option** — when you'd rather not manage servers, the cloud version is there
75
+
76
+ ## Features
77
+
78
+ - **YouTube, Twitch, Kick & uploads** — paste a YouTube video, a Twitch VOD or clip, or a Kick VOD or clip, or upload your own file (live streams are not supported). Twitch and Kick download providers and the optional Apify fallbacks are set in [docs/configuration.md](docs/configuration.md#twitch-and-kick-imports)
79
+
80
+ - **AI clip selection** — an LLM (Gemini, GPT, Claude, or a local Ollama model) picks the 3–7 most clip-worthy segments from the transcript
81
+ - **Virality scoring** — every clip gets hook, engagement, value, and shareability scores
82
+ - **Smart vertical cropping** — face detection keeps the speaker centered in the 9:16 frame
83
+ - **Word-synced subtitles** — AssemblyAI word-level timestamps, custom fonts, caption templates with animation styles
84
+ - **Hook titles** — an AI-written headline burned into the top of each clip's opening seconds
85
+ - **B-roll & transitions** — optional Pexels stock footage overlays and transition effects
86
+ - **Built-in editor** — trim, split, and merge clips, then export with platform presets (TikTok, Reels, Shorts)
87
+ - **Direct publishing** — connect your own YouTube, TikTok and Instagram accounts, then post or schedule clips from the task page
88
+ - **Performance loop** — views, likes, comments and shares flow back from each platform and steer future clip selection toward what works for your audience
89
+ - **Real-time progress** — live pipeline updates streamed to the browser while your video processes
90
+
91
+ ## Quick Start
92
+
93
+ You need Docker, an [AssemblyAI](https://www.assemblyai.com/) API key for transcription, and one LLM provider key (Google, OpenAI, Anthropic, or a local Ollama).
94
+
95
+ ```bash
96
+ git clone https://github.com/FujiwaraChoki/supoclip.git
97
+ cd supoclip
98
+ ```
99
+
100
+ Create a `.env` in the root with your keys:
101
+
102
+ ```env
103
+ ASSEMBLY_AI_API_KEY=your_assemblyai_api_key
104
+ LLM=google-gla:gemini-3-flash-preview
105
+ GOOGLE_API_KEY=your_google_api_key
106
+ ```
107
+
108
+ Then start everything:
109
+
110
+ ```bash
111
+ docker-compose up -d
112
+ ```
113
+
114
+ First startup takes a few minutes; watch it with `docker-compose logs -f`. Once healthy, open [http://localhost:3107](http://localhost:3107), create an account, and start clipping. The backend API lives at [http://localhost:8000](http://localhost:8000) with interactive docs at `/docs`.
115
+
116
+ The template sets `FRONTEND_PORT=3107`. Existing deployments without this setting keep port `3001`; preserve that port if your production reverse proxy uses it. See the [setup guide](docs/setup.md) for custom ports and public URLs.
117
+
118
+ To run fully local with Whisper and Ollama (including the Docker networking Ollama needs), see the [self-hosting tutorial](https://www.supoclip.com/blog/self-host-supoclip-docker#local). To use a different LLM provider or configure the optional pieces (B-roll, analytics, emails, YouTube metadata), see the [configuration guide](docs/configuration.md). If something misbehaves, the [troubleshooting guide](docs/troubleshooting.md) covers the common failure modes.
119
+
120
+ ## Documentation
121
+
122
+ Everything beyond this page lives in [`docs/`](docs/README.md):
123
+
124
+ | Guide | What it covers |
125
+ |---|---|
126
+ | [Setup](docs/setup.md) | Docker-first install, local development, first-run checklist |
127
+ | [Configuration](docs/configuration.md) | Every environment variable, operating modes, provider options |
128
+ | [App Guide](docs/app-guide.md) | Screens, workflows, admin features, hosted vs self-host |
129
+ | [Architecture](docs/architecture.md) | How the frontend, API, worker, queue, and pipeline fit together |
130
+ | [API Reference](docs/api-reference.md) | Backend endpoints, API keys, admin and billing routes |
131
+ | [Development](docs/development.md) | Running locally without Docker, testing, contributing workflow |
132
+ | [Troubleshooting](docs/troubleshooting.md) | Fixes for the common ways things go wrong |
133
+
134
+ ## Development & Testing
135
+
136
+ The stack runs locally without Docker too — see [development](docs/development.md) for the backend (`uv` + FastAPI + ARQ worker) and frontend (Next.js + pnpm) commands. The test suite spans pytest, Vitest, and Playwright, all reachable from the repo root:
137
+
138
+ ```bash
139
+ make test
140
+ ```
141
+
142
+ ## License
143
+
144
+ SupoClip is released under the [AGPL-3.0 License](LICENSE).
145
+
146
+ Contributions are accepted under the terms in [CONTRIBUTING.md](CONTRIBUTING.md), including a license grant that allows the project owner to sublicense and relicense contributed code.
assets/banner.jpg ADDED
assets/blender/announcement/README.md ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Announcement renders
2
+
3
+ Seamless 5 s loops (120 frames at 24 fps, 1600×800) for feature-tour announcements,
4
+ rendered with Cycles on the GPU. Every motion is driven by the loop phase
5
+ `(frame - 1) / FRAMES`, so the last frame flows into the first.
6
+
7
+ | Script | Status |
8
+ |---|---|
9
+ | `prism-wall.py` | **In use**: the workflows announcement (`frontend/public/tours/workflows.*`). A wall of glass prisms turning in a wave, slicing a five-colour field into shards. |
10
+ | `silk-cascade.py` | Kept for a future announcement (`renders/silk-cascade.*`). Hundreds of satin ribbons wrung through one knot, leaving as five colour bands. |
11
+ | `liquid-chrome.py` | Kept for a future announcement (`renders/liquid-chrome.*`). A rolling sea of oil-slick chrome under neon light. |
12
+
13
+ The finished files in `renders/` aren't served. Copy one into `frontend/public/tours/` to use it.
14
+
15
+ ## Rendering
16
+
17
+ ```bash
18
+ blender -b -P assets/blender/announcement/<name>.py -- OUT_DIR [SAMPLES] [FRAMES_SPEC] [RES_PERCENT]
19
+ ```
20
+
21
+ `CYCLES_DEVICE=CPU` renders on the CPU (handy for test stills). Then encode, two-pass
22
+ constrained bitrate keeps the fine detail under ~1.5 MB:
23
+
24
+ ```bash
25
+ ffmpeg -framerate 24 -i OUT_DIR/frame_%04d.png -c:v libvpx-vp9 -b:v 1750k -pass 1 -an -f null /dev/null
26
+ ffmpeg -framerate 24 -i OUT_DIR/frame_%04d.png -c:v libvpx-vp9 -b:v 1750k -pass 2 -an out.webm
27
+ ffmpeg -framerate 24 -i OUT_DIR/frame_%04d.png -c:v libx264 -b:v 2200k -pass 1 -an -f null /dev/null
28
+ ffmpeg -framerate 24 -i OUT_DIR/frame_%04d.png -c:v libx264 -b:v 2200k -pass 2 -pix_fmt yuv420p -movflags +faststart -an out.mp4
29
+ ffmpeg -i OUT_DIR/frame_0001.png -quality 60 out.webp
30
+ ```
assets/blender/announcement/liquid-chrome.py ADDED
@@ -0,0 +1,256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Liquid Chrome: a sea of molten, oil-slick chrome seen up close. From a single
2
+ pulsing source at the left edge, rings of liquid spread out and break into five
3
+ fanned ridges that roll across the frame. The metal carries a living thin film,
4
+ so every crest shimmers through the spectrum while it mirrors a cage of
5
+ saturated light strips. One source, rolling out as five.
6
+
7
+ The surface is a numpy heightfield rebuilt each frame from waves whose phases
8
+ advance by whole cycles per loop (t = (frame - 1) / FRAMES), and the film noise
9
+ is translated around a circle, so frame FRAMES + 1 equals frame 1.
10
+
11
+ blender -b -P liquid-chrome.py -- OUT_DIR [SAMPLES] [FRAMES_SPEC] [RES_PERCENT]
12
+ """
13
+
14
+ import math
15
+ import os
16
+ import sys
17
+
18
+ import bpy
19
+ import numpy as np
20
+
21
+ argv = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
22
+ OUT = argv[0] if argv else "/tmp/liquid-chrome"
23
+ SAMPLES = int(argv[1]) if len(argv) > 1 else 128
24
+ SPEC = argv[2] if len(argv) > 2 else "all"
25
+ RES = int(argv[3]) if len(argv) > 3 else 100
26
+ FRAMES = 120
27
+ TAU = math.tau
28
+
29
+ os.makedirs(OUT, exist_ok=True)
30
+ bpy.ops.wm.read_factory_settings(use_empty=True)
31
+ scene = bpy.context.scene
32
+
33
+
34
+ def parse_frames(spec):
35
+ if spec == "all":
36
+ return list(range(1, FRAMES + 1))
37
+ if "-" in spec:
38
+ a, b = spec.split("-")
39
+ return list(range(int(a), int(b) + 1))
40
+ return [int(x) for x in spec.split(",")]
41
+
42
+
43
+ # ---------------------------------------------------------------- heightfield
44
+ NX, NY = 700, 380
45
+ xs = np.linspace(-11.0, 11.0, NX)
46
+ ys = np.linspace(-4.5, 9.5, NY)
47
+ X, Y = np.meshgrid(xs, ys, indexing="xy")
48
+ SRC = np.array([-7.2, 0.4])
49
+ DX, DY = X - SRC[0], Y - SRC[1]
50
+ R = np.sqrt(DX ** 2 + DY ** 2)
51
+ TH = np.arctan2(DY, DX)
52
+ FAN = np.radians(np.array([-44, -22, 0, 22, 44]))
53
+
54
+
55
+ def height(t):
56
+ # ring waves leaving the source: 3 crests per loop travel outward
57
+ ring = 0.14 * np.sin(TAU * (R / 3.4 - 2 * t)) * np.exp(-R / 9.0) * (1 - np.exp(-(R / 1.2) ** 2))
58
+ # five ridges fanning out; along each ridge a train of swells rolls outward
59
+ fan = np.zeros_like(R)
60
+ for i, a in enumerate(FAN):
61
+ dth = np.angle(np.exp(1j * (TH - a)))
62
+ lateral = np.exp(-(dth * R / (0.75 + 0.10 * R)) ** 2)
63
+ swell = 0.5 + 0.5 * np.sin(TAU * (R / 4.2 - t) + i * 0.9)
64
+ fan += lateral * (0.25 + 0.75 * swell ** 2) * (0.85 * (1 - np.exp(-(R / 2.5) ** 2)))
65
+ # the source: a liquid dome that breathes twice per loop
66
+ dome = 1.25 * np.exp(-(R / 1.15) ** 2) * (1.0 + 0.18 * np.sin(TAU * 2 * t))
67
+ # slow cross-swell so the whole sea moves
68
+ swell = 0.16 * np.sin(TAU * (X / 7.0 + Y / 11.0 - t)) + 0.10 * np.sin(TAU * (Y / 5.0 - X / 13.0 + t) + 1.3)
69
+ return ring + fan + dome + swell
70
+
71
+
72
+ verts_xy = np.stack([X.ravel(), Y.ravel()], 1)
73
+ faces = []
74
+ idx = np.arange(NX * NY).reshape(NY, NX)
75
+ a = idx[:-1, :-1].ravel()
76
+ b = idx[:-1, 1:].ravel()
77
+ c = idx[1:, 1:].ravel()
78
+ d = idx[1:, :-1].ravel()
79
+ faces = np.stack([a, b, c, d], 1)
80
+ mesh = bpy.data.meshes.new("sea")
81
+ mesh.vertices.add(NX * NY)
82
+ mesh.loops.add(len(faces) * 4)
83
+ mesh.polygons.add(len(faces))
84
+ mesh.loops.foreach_set("vertex_index", faces.ravel().astype(np.int32))
85
+ mesh.polygons.foreach_set("loop_start", np.arange(0, len(faces) * 4, 4, dtype=np.int32))
86
+ mesh.polygons.foreach_set("loop_total", np.full(len(faces), 4, dtype=np.int32))
87
+
88
+
89
+ def update(t):
90
+ z = height(t)
91
+ co = np.stack([X.ravel(), Y.ravel(), z.ravel()], 1).astype(np.float32)
92
+ mesh.vertices.foreach_set("co", co.ravel())
93
+ mesh.update()
94
+
95
+
96
+ update(0.0)
97
+ mesh.validate()
98
+ mesh.shade_smooth()
99
+ sea = bpy.data.objects.new("sea", mesh)
100
+ scene.collection.objects.link(sea)
101
+
102
+ # ---------------------------------------------------------------- iridescent chrome
103
+ mat = bpy.data.materials.new("chrome")
104
+ nt = mat.node_tree
105
+ nt.nodes.clear()
106
+ out = nt.nodes.new("ShaderNodeOutputMaterial")
107
+ metal = nt.nodes.new("ShaderNodeBsdfMetallic")
108
+ metal.inputs["Base Color"].default_value = (0.95, 0.93, 0.97, 1)
109
+ metal.inputs["Edge Tint"].default_value = (1.0, 0.9, 1.0, 1)
110
+ metal.inputs["Roughness"].default_value = 0.05
111
+ tex = nt.nodes.new("ShaderNodeTexCoord")
112
+ offset = nt.nodes.new("ShaderNodeCombineXYZ")
113
+ offset.name = "OFFSET"
114
+ addv = nt.nodes.new("ShaderNodeVectorMath"); addv.operation = "ADD"
115
+ nt.links.new(tex.outputs["Object"], addv.inputs[0])
116
+ nt.links.new(offset.outputs[0], addv.inputs[1])
117
+ noise = nt.nodes.new("ShaderNodeTexNoise")
118
+ noise.inputs["Scale"].default_value = 0.22
119
+ noise.inputs["Detail"].default_value = 2.0
120
+ noise.inputs["Distortion"].default_value = 0.8
121
+ nt.links.new(addv.outputs[0], noise.inputs["Vector"])
122
+ film = nt.nodes.new("ShaderNodeMapRange")
123
+ film.inputs["From Min"].default_value = 0.3
124
+ film.inputs["From Max"].default_value = 0.7
125
+ film.inputs["To Min"].default_value = 250.0
126
+ film.inputs["To Max"].default_value = 750.0
127
+ nt.links.new(noise.outputs["Fac"], film.inputs["Value"])
128
+ nt.links.new(film.outputs["Result"], metal.inputs["Thin Film Thickness"])
129
+ metal.inputs["Thin Film IOR"].default_value = 1.5
130
+ nt.links.new(metal.outputs[0], out.inputs[0])
131
+ mesh.materials.append(mat)
132
+
133
+ # ---------------------------------------------------------------- light cage
134
+ COLORS = [
135
+ (1.00, 0.22, 0.01),
136
+ (1.00, 0.01, 0.32),
137
+ (0.50, 0.03, 1.00),
138
+ (0.01, 0.30, 1.00),
139
+ (0.00, 0.85, 0.55),
140
+ (1.00, 0.75, 0.10),
141
+ ]
142
+
143
+
144
+ def emissive(name, color, strength):
145
+ m = bpy.data.materials.new(name)
146
+ t = m.node_tree
147
+ t.nodes.clear()
148
+ o = t.nodes.new("ShaderNodeOutputMaterial")
149
+ e = t.nodes.new("ShaderNodeEmission")
150
+ e.inputs[0].default_value = (*color, 1)
151
+ e.inputs[1].default_value = strength
152
+ t.links.new(e.outputs[0], o.inputs[0])
153
+ return m
154
+
155
+
156
+ # long bars arching over the sea, like a tunnel of coloured tubes
157
+ for i in range(11):
158
+ yy = -10 + i * 3.1
159
+ col = COLORS[i % len(COLORS)]
160
+ bpy.ops.mesh.primitive_cylinder_add(radius=0.55, depth=60, location=(0, yy, 9.0 + 1.5 * math.sin(i)))
161
+ bar = bpy.context.active_object
162
+ bar.rotation_euler = (0, math.radians(90), math.radians(8 * math.sin(i * 1.7)))
163
+ bar.data.materials.append(emissive(f"bar{i}", col, 3.0))
164
+ # a cross set for richer crossings
165
+ for i in range(5):
166
+ xx = -16 + i * 8.0
167
+ col = COLORS[(i + 3) % len(COLORS)]
168
+ bpy.ops.mesh.primitive_cylinder_add(radius=0.6, depth=60, location=(xx, 4, 11.0))
169
+ bar = bpy.context.active_object
170
+ bar.rotation_euler = (math.radians(90), 0, 0)
171
+ bar.data.materials.append(emissive(f"cross{i}", col, 2.5))
172
+
173
+ world = bpy.data.worlds.new("w")
174
+ scene.world = world
175
+ wn = world.node_tree
176
+ wn.nodes.clear()
177
+ wo = wn.nodes.new("ShaderNodeOutputWorld")
178
+ bg = wn.nodes.new("ShaderNodeBackground")
179
+ tc = wn.nodes.new("ShaderNodeTexCoord")
180
+ sepw = wn.nodes.new("ShaderNodeSeparateXYZ")
181
+ wr = wn.nodes.new("ShaderNodeValToRGB")
182
+ wn.links.new(tc.outputs["Generated"], sepw.inputs[0])
183
+ wn.links.new(sepw.outputs["X"], wr.inputs[0])
184
+ wr.color_ramp.elements[0].color = (0.05, 0.0, 0.08, 1)
185
+ wr.color_ramp.elements[1].color = (0.0, 0.02, 0.09, 1)
186
+ wn.links.new(wr.outputs[0], bg.inputs[0])
187
+ bg.inputs[1].default_value = 1.0
188
+ wn.links.new(bg.outputs[0], wo.inputs[0])
189
+
190
+ # ---------------------------------------------------------------- camera
191
+ cam_data = bpy.data.cameras.new("cam")
192
+ cam_data.lens = 30
193
+ cam_data.dof.use_dof = True
194
+ cam_data.dof.aperture_fstop = 4.0
195
+ cam = bpy.data.objects.new("cam", cam_data)
196
+ cam.location = (-1.0, -6.5, 5.2)
197
+ scene.collection.objects.link(cam)
198
+ look = bpy.data.objects.new("look", None)
199
+ look.location = (-1.2, 1.2, 0.2)
200
+ scene.collection.objects.link(look)
201
+ tcn = cam.constraints.new("TRACK_TO")
202
+ tcn.target = look
203
+ tcn.track_axis = "TRACK_NEGATIVE_Z"
204
+ tcn.up_axis = "UP_Y"
205
+ cam_data.dof.focus_object = look
206
+ scene.camera = cam
207
+
208
+ # ---------------------------------------------------------------- render
209
+ scene.render.engine = "CYCLES"
210
+ scene.render.resolution_x = 1600
211
+ scene.render.resolution_y = 800
212
+ scene.render.resolution_percentage = RES
213
+ scene.render.image_settings.file_format = "PNG"
214
+ scene.render.use_persistent_data = True
215
+ scene.view_settings.view_transform = "Khronos PBR Neutral"
216
+ scene.cycles.samples = SAMPLES
217
+ scene.cycles.use_denoising = True
218
+ scene.cycles.max_bounces = 8
219
+ scene.cycles.glossy_bounces = 8
220
+ scene.cycles.seed = 5
221
+ scene.frame_start, scene.frame_end = 1, FRAMES
222
+
223
+ prefs = bpy.context.preferences.addons["cycles"].preferences
224
+ prefs.compute_device_type = "OPTIX"
225
+ prefs.get_devices()
226
+ for d in prefs.devices:
227
+ d.use = d.type == "OPTIX"
228
+ scene.cycles.device = "GPU"
229
+ scene.cycles.denoiser = "OPTIX"
230
+ if os.environ.get("CYCLES_DEVICE") == "CPU": # for quick tests while the GPU is busy
231
+ scene.cycles.device = "CPU"
232
+ scene.cycles.denoiser = "OPENIMAGEDENOISE"
233
+
234
+ tree = bpy.data.node_groups.new("comp", "CompositorNodeTree")
235
+ scene.compositing_node_group = tree
236
+ rl = tree.nodes.new("CompositorNodeRLayers")
237
+ glare = tree.nodes.new("CompositorNodeGlare")
238
+ for k, v in (("Type", "Bloom"), ("Threshold", 1.0), ("Strength", 0.5), ("Size", 0.7), ("Quality", "High")):
239
+ try:
240
+ glare.inputs[k].default_value = v
241
+ except (KeyError, TypeError, AttributeError):
242
+ pass
243
+ gout = tree.nodes.new("NodeGroupOutput")
244
+ tree.interface.new_socket("Image", in_out="OUTPUT", socket_type="NodeSocketColor")
245
+ tree.links.new(rl.outputs["Image"], glare.inputs["Image"])
246
+ tree.links.new(glare.outputs[0], gout.inputs[0])
247
+
248
+ offset_node = nt.nodes["OFFSET"]
249
+ for f in parse_frames(SPEC):
250
+ t = ((f - 1) / FRAMES) % 1.0
251
+ scene.frame_set(f)
252
+ update(t)
253
+ offset_node.inputs[0].default_value = 2.0 * math.cos(TAU * t)
254
+ offset_node.inputs[1].default_value = 2.0 * math.sin(TAU * t)
255
+ scene.render.filepath = os.path.join(OUT, f"frame_{f:04d}.png")
256
+ bpy.ops.render.render(write_still=True)
assets/blender/announcement/prism-wall.py ADDED
@@ -0,0 +1,256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Prism Wall: a wall of tall glass prisms stands in front of a luminous field of
2
+ five drifting colours. A wave rolls across the wall and every prism turns a
3
+ third of a turn as it passes, so the light behind is sliced into vertical
4
+ shards, refracted, dispersed and recombined: one picture becoming many vertical
5
+ pieces and folding back into one. Dispersion is faked by adding three glass
6
+ lobes with slightly different IOR (red, green, blue).
7
+
8
+ Each prism turns by exactly 120 degrees per loop (its own symmetry) on an eased
9
+ travelling wave, and the backdrop pattern scrolls by whole periods, all from the
10
+ loop phase t = (frame - 1) / FRAMES, so frame FRAMES + 1 equals frame 1.
11
+
12
+ blender -b -P prism-wall.py -- OUT_DIR [SAMPLES] [FRAMES_SPEC] [RES_PERCENT]
13
+ """
14
+
15
+ import math
16
+ import os
17
+ import sys
18
+
19
+ import bpy
20
+ import numpy as np
21
+
22
+ argv = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
23
+ OUT = argv[0] if argv else "/tmp/prism-wall"
24
+ SAMPLES = int(argv[1]) if len(argv) > 1 else 160
25
+ SPEC = argv[2] if len(argv) > 2 else "all"
26
+ RES = int(argv[3]) if len(argv) > 3 else 100
27
+ FRAMES = 120
28
+ TAU = math.tau
29
+
30
+ os.makedirs(OUT, exist_ok=True)
31
+ bpy.ops.wm.read_factory_settings(use_empty=True)
32
+ scene = bpy.context.scene
33
+
34
+
35
+ def parse_frames(spec):
36
+ if spec == "all":
37
+ return list(range(1, FRAMES + 1))
38
+ if "-" in spec:
39
+ a, b = spec.split("-")
40
+ return list(range(int(a), int(b) + 1))
41
+ return [int(x) for x in spec.split(",")]
42
+
43
+
44
+ # ---------------------------------------------------------------- prism template
45
+ SIDE = 1.25
46
+ CUT = 0.10
47
+ HALF_H = 6.0
48
+ N_RODS = 15
49
+ corners = [np.array([math.cos(a), math.sin(a)]) * SIDE / math.sqrt(3) for a in (math.pi / 2, math.pi / 2 + TAU / 3, math.pi / 2 + 2 * TAU / 3)]
50
+ ring = []
51
+ for i in range(3):
52
+ p, q, r = corners[i - 1], corners[i], corners[(i + 1) % 3]
53
+ ring.append(q + (p - q) * CUT)
54
+ ring.append(q + (r - q) * CUT)
55
+ ring = np.array(ring)
56
+ nr = len(ring)
57
+ # section in XY (y = depth), extruded along Z (up)
58
+ tverts = np.concatenate([np.c_[ring, np.full(nr, -HALF_H)], np.c_[ring, np.full(nr, HALF_H)]])
59
+ tfaces = [tuple(range(nr - 1, -1, -1)), tuple(range(nr, 2 * nr))]
60
+ for i in range(nr):
61
+ j = (i + 1) % nr
62
+ tfaces.append((i, j, nr + j, nr + i))
63
+
64
+ pitch = SIDE * 0.9
65
+ xs = (np.arange(N_RODS) - (N_RODS - 1) / 2) * pitch
66
+ verts_per = len(tverts)
67
+ all_faces = []
68
+ for k in range(N_RODS):
69
+ off = k * verts_per
70
+ all_faces += [tuple(v + off for v in f) for f in tfaces]
71
+ mesh = bpy.data.meshes.new("rods")
72
+ mesh.from_pydata(np.zeros((N_RODS * verts_per, 3)).tolist(), [], all_faces)
73
+ mesh.update()
74
+
75
+
76
+ def update(t):
77
+ # the wave travels left -> right, once per loop; each rod eases through 120 deg
78
+ ph = (t - (xs - xs[0]) / (xs[-1] - xs[0] + pitch) * 1.0) % 1.0
79
+ e = np.clip(ph / 0.45, 0, 1)
80
+ e = e * e * e * (e * (e * 6 - 15) + 10)
81
+ ang = (TAU / 3) * e
82
+ ca, sa = np.cos(ang)[:, None], np.sin(ang)[:, None]
83
+ vx = tverts[None, :, 0] * ca - tverts[None, :, 1] * sa + xs[:, None]
84
+ vy = tverts[None, :, 0] * sa + tverts[None, :, 1] * ca
85
+ vz = np.broadcast_to(tverts[None, :, 2], vx.shape)
86
+ co = np.stack([vx, vy, vz], -1).reshape(-1, 3).astype(np.float32)
87
+ mesh.vertices.foreach_set("co", co.ravel())
88
+ mesh.update()
89
+
90
+
91
+ update(0.0)
92
+ rods = bpy.data.objects.new("rods", mesh)
93
+ scene.collection.objects.link(rods)
94
+
95
+ # ---------------------------------------------------------------- dispersive glass
96
+ mat = bpy.data.materials.new("glass")
97
+ nt = mat.node_tree
98
+ nt.nodes.clear()
99
+ out = nt.nodes.new("ShaderNodeOutputMaterial")
100
+ lobes = []
101
+ for ior, col in ((1.42, (1, 0, 0)), (1.50, (0, 1, 0)), (1.60, (0, 0, 1))):
102
+ g = nt.nodes.new("ShaderNodeBsdfGlass")
103
+ g.inputs["IOR"].default_value = ior
104
+ g.inputs["Roughness"].default_value = 0.0
105
+ g.inputs["Color"].default_value = (*col, 1)
106
+ lobes.append(g)
107
+ a1 = nt.nodes.new("ShaderNodeAddShader")
108
+ a2 = nt.nodes.new("ShaderNodeAddShader")
109
+ nt.links.new(lobes[0].outputs[0], a1.inputs[0])
110
+ nt.links.new(lobes[1].outputs[0], a1.inputs[1])
111
+ nt.links.new(a1.outputs[0], a2.inputs[0])
112
+ nt.links.new(lobes[2].outputs[0], a2.inputs[1])
113
+ nt.links.new(a2.outputs[0], out.inputs[0])
114
+ mesh.materials.append(mat)
115
+
116
+ # ---------------------------------------------------------------- luminous backdrop
117
+ BACK_Y = 3.2
118
+ bm_ = bpy.data.meshes.new("backdrop")
119
+ bm_.from_pydata([(-20, BACK_Y, -12), (20, BACK_Y, -12), (20, BACK_Y, 12), (-20, BACK_Y, 12)], [], [(0, 1, 2, 3)])
120
+ back = bpy.data.objects.new("backdrop", bm_)
121
+ scene.collection.objects.link(back)
122
+ bmat = bpy.data.materials.new("backdrop")
123
+ bn = bmat.node_tree
124
+ bn.nodes.clear()
125
+ bo = bn.nodes.new("ShaderNodeOutputMaterial")
126
+ be = bn.nodes.new("ShaderNodeEmission")
127
+ btc = bn.nodes.new("ShaderNodeTexCoord")
128
+ offs = bn.nodes.new("ShaderNodeCombineXYZ"); offs.name = "OFFSET"
129
+ addv = bn.nodes.new("ShaderNodeVectorMath"); addv.operation = "ADD"
130
+ bn.links.new(btc.outputs["Object"], addv.inputs[0]); bn.links.new(offs.outputs[0], addv.inputs[1])
131
+ # warp the coordinate with soft noise (looping: offset travels on a circle)
132
+ noise = bn.nodes.new("ShaderNodeTexNoise")
133
+ noise.inputs["Scale"].default_value = 0.09
134
+ noise.inputs["Detail"].default_value = 1.0
135
+ bn.links.new(addv.outputs[0], noise.inputs["Vector"])
136
+ sepv = bn.nodes.new("ShaderNodeSeparateXYZ")
137
+ bn.links.new(btc.outputs["Object"], sepv.inputs[0])
138
+ # u = (x * 0.55 + z) / P + 1.4 * noise - t : diagonal bands, scrolled one period per loop
139
+ P = 7.5
140
+ d1 = bn.nodes.new("ShaderNodeMath"); d1.operation = "MULTIPLY_ADD"; d1.inputs[1].default_value = 0.55
141
+ bn.links.new(sepv.outputs["X"], d1.inputs[0]); bn.links.new(sepv.outputs["Z"], d1.inputs[2])
142
+ d2 = bn.nodes.new("ShaderNodeMath"); d2.operation = "DIVIDE"; d2.inputs[1].default_value = P
143
+ bn.links.new(d1.outputs[0], d2.inputs[0])
144
+ nmul = bn.nodes.new("ShaderNodeMath"); nmul.operation = "MULTIPLY_ADD"
145
+ nmul.inputs[1].default_value = 1.1
146
+ bn.links.new(noise.outputs["Fac"], nmul.inputs[0]); bn.links.new(d2.outputs[0], nmul.inputs[2])
147
+ phase = bn.nodes.new("ShaderNodeValue"); phase.name = "PHASE"
148
+ sb = bn.nodes.new("ShaderNodeMath"); sb.operation = "SUBTRACT"
149
+ bn.links.new(nmul.outputs[0], sb.inputs[0]); bn.links.new(phase.outputs[0], sb.inputs[1])
150
+ fr = bn.nodes.new("ShaderNodeMath"); fr.operation = "FRACT"
151
+ bn.links.new(sb.outputs[0], fr.inputs[0])
152
+ ramp = bn.nodes.new("ShaderNodeValToRGB")
153
+ ramp.color_ramp.interpolation = "EASE"
154
+ cols = [(1.0, 0.32, 0.0), (1.0, 0.02, 0.32), (0.45, 0.02, 1.0), (0.0, 0.32, 1.0), (0.0, 0.85, 0.55)]
155
+ els = ramp.color_ramp.elements
156
+ els[0].position = 0.0; els[0].color = (*cols[0], 1)
157
+ els[1].position = 1.0; els[1].color = (*cols[0], 1)
158
+ for i in range(1, 5):
159
+ e = els.new(i * 0.2); e.color = (*cols[i], 1)
160
+ bn.links.new(fr.outputs[0], ramp.inputs[0])
161
+ be.inputs["Strength"].default_value = 1.6
162
+ bn.links.new(ramp.outputs[0], be.inputs["Color"])
163
+ bn.links.new(be.outputs[0], bo.inputs[0])
164
+ bm_.materials.append(bmat)
165
+
166
+ # a few bright, thin light bars far behind, seen through the gaps & smeared by the prisms
167
+ for i, (x, c) in enumerate([(-4.5, (1, 0.9, 0.8)), (0.7, (1, 0.9, 0.8)), (5.2, (1, 0.9, 0.8))]):
168
+ bpy.ops.mesh.primitive_cylinder_add(radius=0.06, depth=30, location=(x, BACK_Y - 0.05, 0))
169
+ bar = bpy.context.active_object
170
+ bar.rotation_euler = (0, math.radians(35), 0)
171
+ m = bpy.data.materials.new(f"bar{i}")
172
+ mt = m.node_tree
173
+ mt.nodes.clear()
174
+ mo = mt.nodes.new("ShaderNodeOutputMaterial")
175
+ me = mt.nodes.new("ShaderNodeEmission")
176
+ me.inputs[0].default_value = (*c, 1)
177
+ me.inputs[1].default_value = 30.0
178
+ mt.links.new(me.outputs[0], mo.inputs[0])
179
+ bar.data.materials.append(m)
180
+
181
+ world = bpy.data.worlds.new("w")
182
+ scene.world = world
183
+ wn = world.node_tree
184
+ wn.nodes.clear()
185
+ wo = wn.nodes.new("ShaderNodeOutputWorld")
186
+ bg = wn.nodes.new("ShaderNodeBackground")
187
+ bg.inputs[0].default_value = (0.75, 0.1, 0.6, 1)
188
+ bg.inputs[1].default_value = 0.6
189
+ wn.links.new(bg.outputs[0], wo.inputs[0])
190
+
191
+ # ---------------------------------------------------------------- camera
192
+ cam_data = bpy.data.cameras.new("cam")
193
+ cam_data.lens = 35
194
+ cam_data.dof.use_dof = True
195
+ cam_data.dof.aperture_fstop = 5.6
196
+ cam = bpy.data.objects.new("cam", cam_data)
197
+ cam.location = (5.2, -7.6, -1.2)
198
+ cam.rotation_euler = (math.radians(90 + 6), 0, math.radians(30))
199
+ scene.collection.objects.link(cam)
200
+ cam_data.dof.focus_distance = 8.6
201
+ cam_data.dof.aperture_fstop = 2.8
202
+ scene.camera = cam
203
+
204
+ # ---------------------------------------------------------------- render
205
+ scene.render.engine = "CYCLES"
206
+ scene.render.resolution_x = 1600
207
+ scene.render.resolution_y = 800
208
+ scene.render.resolution_percentage = RES
209
+ scene.render.image_settings.file_format = "PNG"
210
+ scene.render.use_persistent_data = True
211
+ scene.view_settings.view_transform = "AgX"
212
+ scene.view_settings.look = "AgX - Punchy"
213
+ scene.cycles.samples = SAMPLES
214
+ scene.cycles.use_denoising = True
215
+ scene.cycles.max_bounces = 16
216
+ scene.cycles.transmission_bounces = 16
217
+ scene.cycles.glossy_bounces = 8
218
+ scene.cycles.seed = 9
219
+ scene.frame_start, scene.frame_end = 1, FRAMES
220
+
221
+ prefs = bpy.context.preferences.addons["cycles"].preferences
222
+ prefs.compute_device_type = "OPTIX"
223
+ prefs.get_devices()
224
+ for d in prefs.devices:
225
+ d.use = d.type == "OPTIX"
226
+ scene.cycles.device = "GPU"
227
+ scene.cycles.denoiser = "OPTIX"
228
+ if os.environ.get("CYCLES_DEVICE") == "CPU": # for quick tests while the GPU is busy
229
+ scene.cycles.device = "CPU"
230
+ scene.cycles.denoiser = "OPENIMAGEDENOISE"
231
+
232
+ tree = bpy.data.node_groups.new("comp", "CompositorNodeTree")
233
+ scene.compositing_node_group = tree
234
+ rl = tree.nodes.new("CompositorNodeRLayers")
235
+ glare = tree.nodes.new("CompositorNodeGlare")
236
+ for k, v in (("Type", "Bloom"), ("Threshold", 1.0), ("Strength", 0.5), ("Size", 0.65), ("Quality", "High")):
237
+ try:
238
+ glare.inputs[k].default_value = v
239
+ except (KeyError, TypeError, AttributeError):
240
+ pass
241
+ gout = tree.nodes.new("NodeGroupOutput")
242
+ tree.interface.new_socket("Image", in_out="OUTPUT", socket_type="NodeSocketColor")
243
+ tree.links.new(rl.outputs["Image"], glare.inputs["Image"])
244
+ tree.links.new(glare.outputs[0], gout.inputs[0])
245
+
246
+ phase_node = bn.nodes["PHASE"]
247
+ offset_node = bn.nodes["OFFSET"]
248
+ for f in parse_frames(SPEC):
249
+ t = ((f - 1) / FRAMES) % 1.0
250
+ scene.frame_set(f)
251
+ update(t)
252
+ phase_node.outputs[0].default_value = t
253
+ offset_node.inputs[0].default_value = 3.0 * math.cos(TAU * t)
254
+ offset_node.inputs[2].default_value = 3.0 * math.sin(TAU * t)
255
+ scene.render.filepath = os.path.join(OUT, f"frame_{f:04d}.png")
256
+ bpy.ops.render.render(write_still=True)
assets/blender/announcement/renders/liquid-chrome.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2b613fa01e133f5bc2a0d3b7c993481623ce01b512cd3481b087f66dc90e5603
3
+ size 1355524
assets/blender/announcement/renders/liquid-chrome.webm ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:17e640dfffc1a249a2dc6452b683981e82a4c8d44c9a0248653fa01af32eab27
3
+ size 1182192
assets/blender/announcement/renders/liquid-chrome.webp ADDED
assets/blender/announcement/renders/silk-cascade.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4de0a2afd8214349245853c8cf1120066d2d3df5dc7016bc2d8ad08f40011888
3
+ size 1439105
assets/blender/announcement/renders/silk-cascade.webm ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3cac1569402eb62e2e6b1e2093ec33bad68c5c66101643ec9494efa715fd925c
3
+ size 1124440
assets/blender/announcement/renders/silk-cascade.webp ADDED
assets/blender/announcement/silk-cascade.py ADDED
@@ -0,0 +1,376 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Silk Cascade: a tangle of satin ribbons in every colour pours in from the left,
2
+ is wrung through a single twisting knot, and leaves on the right sorted into five
3
+ broad, waving bands of pure colour. One video, five kinds of clip.
4
+
5
+ Everything is built with numpy and rebuilt every frame from cyclic functions of
6
+ the loop phase t = (frame - 1) / FRAMES, so frame FRAMES + 1 equals frame 1.
7
+
8
+ blender -b -P silk-cascade.py -- OUT_DIR [SAMPLES] [FRAMES_SPEC] [RES_PERCENT]
9
+
10
+ FRAMES_SPEC is "all" (default), "a-b" or "a,b,c".
11
+ """
12
+
13
+ import math
14
+ import os
15
+ import sys
16
+
17
+ import bpy
18
+ import numpy as np
19
+
20
+ argv = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
21
+ OUT = argv[0] if argv else "/tmp/silk-cascade"
22
+ SAMPLES = int(argv[1]) if len(argv) > 1 else 96
23
+ SPEC = argv[2] if len(argv) > 2 else "all"
24
+ RES = int(argv[3]) if len(argv) > 3 else 100
25
+ FRAMES = 120
26
+ TAU = math.tau
27
+
28
+ os.makedirs(OUT, exist_ok=True)
29
+ bpy.ops.wm.read_factory_settings(use_empty=True)
30
+ scene = bpy.context.scene
31
+ rng = np.random.default_rng(7)
32
+
33
+
34
+ def parse_frames(spec):
35
+ if spec == "all":
36
+ return list(range(1, FRAMES + 1))
37
+ if "-" in spec:
38
+ a, b = spec.split("-")
39
+ return list(range(int(a), int(b) + 1))
40
+ return [int(x) for x in spec.split(",")]
41
+
42
+
43
+ def smoothstep(a, b, x):
44
+ t = np.clip((x - a) / (b - a), 0.0, 1.0)
45
+ return t * t * (3 - 2 * t)
46
+
47
+
48
+ # ---------------------------------------------------------------- palette
49
+ # Five workflow colours (linear-ish sRGB), deep and saturated.
50
+ BANDS = np.array([
51
+ (1.00, 0.30, 0.02), # tangerine
52
+ (0.95, 0.02, 0.28), # crimson-magenta
53
+ (0.45, 0.04, 0.95), # violet
54
+ (0.00, 0.35, 1.00), # cobalt
55
+ (0.00, 0.80, 0.55), # jade
56
+ ])
57
+
58
+
59
+ def srgb_to_lin(c):
60
+ c = np.asarray(c, dtype=float)
61
+ return np.where(c <= 0.04045, c / 12.92, ((c + 0.055) / 1.055) ** 2.4)
62
+
63
+
64
+ # ---------------------------------------------------------------- ribbons
65
+ class RibbonField:
66
+ """N ribbons sampled at S points along x; topology fixed, coordinates per frame."""
67
+
68
+ def __init__(self, name, n, samples, x0, x1, width, layer, knot=True):
69
+ self.knot = knot
70
+ self.n, self.s = n, samples
71
+ self.x = np.linspace(x0, x1, samples)
72
+ self.width = width
73
+ self.layer = layer
74
+ self.band = np.arange(n) % 5
75
+ rng.shuffle(self.band)
76
+ # left: random interleaved heights; right: sorted bands
77
+ self.yl = rng.uniform(-2.6, 2.6, n)
78
+ order = np.argsort(self.band + rng.uniform(0, 0.999, n))
79
+ rank = np.empty(n)
80
+ rank[order] = np.arange(n)
81
+ self.yr = (rank / (n - 1) - 0.5) * 5.4 + (self.band - 2) * 0.10
82
+ self.zl = rng.uniform(-0.6, 0.6, n) + layer
83
+ self.zr = (self.band - 2) * 0.12 * np.sign(rng.uniform(-1, 1, n)) + rng.uniform(-0.25, 0.25, n) + layer
84
+ self.theta = rng.uniform(0, TAU, n)
85
+ self.rad = np.sqrt(rng.uniform(0.0, 1.0, n)) * 0.42
86
+ self.phase = rng.uniform(0, TAU, n)
87
+ self.twist0 = rng.uniform(0, TAU, n)
88
+ self.twist_rate = rng.choice([-2, -1, 1, 2], n)
89
+ self.rand = rng.uniform(0, 1, n)
90
+ self.left_col = rng.integers(0, 5, n)
91
+
92
+ verts = n * samples * 2
93
+ faces = []
94
+ for i in range(n):
95
+ base = i * samples * 2
96
+ for j in range(samples - 1):
97
+ a = base + j * 2
98
+ faces.append((a, a + 2, a + 3, a + 1))
99
+ self.mesh = bpy.data.meshes.new(name)
100
+ self.mesh.vertices.add(verts)
101
+ self.mesh.loops.add(len(faces) * 4)
102
+ self.mesh.polygons.add(len(faces))
103
+ f = np.array(faces, dtype=np.int32)
104
+ self.mesh.loops.foreach_set("vertex_index", f.ravel())
105
+ self.mesh.polygons.foreach_set("loop_start", np.arange(0, len(faces) * 4, 4, dtype=np.int32))
106
+ self.mesh.polygons.foreach_set("loop_total", np.full(len(faces), 4, dtype=np.int32))
107
+ self.update(0.0)
108
+ self.mesh.update()
109
+ self.mesh.validate()
110
+ self.mesh.shade_smooth()
111
+
112
+ # UV: u along length, v across
113
+ u = np.tile(np.linspace(0, 1, samples).repeat(2), n)
114
+ v = np.tile(np.array([0.0, 1.0]), n * samples)
115
+ vuv = np.stack([u, v], 1)
116
+ uv = self.mesh.uv_layers.new(name="UVMap")
117
+ uv.data.foreach_set("uv", vuv[f.ravel()].ravel())
118
+
119
+ # per-vertex colour: mixed palette on the left, band colour on the right
120
+ xs = np.tile(self.x.repeat(2), n)
121
+ s = smoothstep(-1.4, 0.9, xs)
122
+ lc = BANDS[np.repeat(self.left_col, samples * 2)]
123
+ rc = BANDS[np.repeat(self.band, samples * 2)]
124
+ col = lc * (1 - s[:, None]) + rc * s[:, None]
125
+ # a hot, pale core inside the knot
126
+ knot = np.exp(-((xs + 0.25) / 0.55) ** 2)
127
+ col = col * (1 - 0.3 * knot[:, None]) + np.array([1.0, 0.75, 0.5]) * 0.3 * knot[:, None]
128
+ rgba = np.concatenate([col, np.ones((len(col), 1))], 1).astype(np.float32)
129
+ ca = self.mesh.color_attributes.new("col", "FLOAT_COLOR", "POINT")
130
+ ca.data.foreach_set("color", rgba.ravel())
131
+ ra = self.mesh.attributes.new("rand", "FLOAT", "POINT")
132
+ ra.data.foreach_set("value", np.repeat(self.rand, samples * 2).astype(np.float32))
133
+
134
+ self.obj = bpy.data.objects.new(name, self.mesh)
135
+ scene.collection.objects.link(self.obj)
136
+
137
+ def centerline(self, t):
138
+ x = self.x[None, :]
139
+ n = self.n
140
+ ph = self.phase[:, None]
141
+ k = -0.25 # knot position
142
+ s = smoothstep(k - 2.2, k + 2.2, x)
143
+ w = np.exp(-((x - k) / 1.05) ** 2) * (1.0 if self.knot else 0.0)
144
+ # flowing waves, travelling left -> right, integer cycles per loop
145
+ wave_l = 0.38 * np.sin(TAU * (x / 3.1 - t) + ph) * (1 - s)
146
+ wave_r = (0.30 + 0.10 * (x - k).clip(0)) * np.sin(TAU * (x / 3.6 - t) + 0.8 * self.band[:, None]) * s
147
+ y_far = self.yl[:, None] * (1 - s) + self.yr[:, None] * s + wave_l + wave_r * (1 - w)
148
+ z_far = self.zl[:, None] * (1 - s) + self.zr[:, None] * s
149
+ z_far = z_far + 0.35 * np.sin(TAU * (x / 2.7 - t) + 1.7 * ph) * (1 - w)
150
+ # the knot: a rotating twisted cable
151
+ ang = self.theta[:, None] + 2.2 * (x - k) + TAU * t
152
+ yk = self.rad[:, None] * np.cos(ang) + 0.05 * np.sin(TAU * t)
153
+ zk = self.rad[:, None] * np.sin(ang) + self.layer
154
+ y = y_far * (1 - w) + yk * w
155
+ z = z_far * (1 - w) + zk * w
156
+ xx = np.broadcast_to(x, (n, self.s))
157
+ return np.stack([xx, y, z], -1)
158
+
159
+ def update(self, t):
160
+ c = self.centerline(t)
161
+ tan = np.gradient(c, axis=1)
162
+ tan /= np.linalg.norm(tan, axis=-1, keepdims=True)
163
+ ref = np.array([0.0, 0.0, 1.0])
164
+ b1 = np.cross(tan, ref)
165
+ b1 /= np.linalg.norm(b1, axis=-1, keepdims=True) + 1e-9
166
+ b2 = np.cross(tan, b1)
167
+ x = self.x[None, :]
168
+ phi = self.twist0[:, None] + self.twist_rate[:, None] * (0.55 * x) + 0.35 * np.sin(TAU * t + self.phase[:, None])
169
+ wdir = b1 * np.cos(phi)[..., None] + b2 * np.sin(phi)[..., None]
170
+ k = -0.25
171
+ width = self.width * (1.0 - 0.45 * np.exp(-((x - k) / 0.9) ** 2))
172
+ half = 0.5 * width[..., None] * wdir
173
+ a = c - half
174
+ b = c + half
175
+ co = np.stack([a, b], 2).reshape(-1, 3).astype(np.float32)
176
+ self.mesh.vertices.foreach_set("co", co.ravel())
177
+ self.mesh.update()
178
+
179
+
180
+ front = RibbonField("silk", 170, 260, -6.5, 6.5, 0.16, 0.0)
181
+ back = RibbonField("silk_back", 90, 160, -7.5, 7.5, 0.42, -2.6, knot=False)
182
+ back.obj.scale = (1.25, 1.25, 1.0)
183
+
184
+
185
+ # ---------------------------------------------------------------- material
186
+ def silk_material(name, emission_gain):
187
+ m = bpy.data.materials.new(name)
188
+ nt = m.node_tree
189
+ nt.nodes.clear()
190
+ out = nt.nodes.new("ShaderNodeOutputMaterial")
191
+ p = nt.nodes.new("ShaderNodeBsdfPrincipled")
192
+ attr = nt.nodes.new("ShaderNodeAttribute")
193
+ attr.attribute_name = "col"
194
+ rnd = nt.nodes.new("ShaderNodeAttribute")
195
+ rnd.attribute_name = "rand"
196
+ uvn = nt.nodes.new("ShaderNodeUVMap")
197
+ uvn.uv_map = "UVMap"
198
+ sep = nt.nodes.new("ShaderNodeSeparateXYZ")
199
+ nt.links.new(uvn.outputs["UV"], sep.inputs[0])
200
+ tangent = nt.nodes.new("ShaderNodeTangent")
201
+ tangent.direction_type = "UV_MAP"
202
+ tangent.uv_map = "UVMap"
203
+
204
+ # light pulses running along each ribbon: fract(u*K + rand - t)
205
+ phase = nt.nodes.new("ShaderNodeValue")
206
+ phase.name = "PHASE"
207
+ mul = nt.nodes.new("ShaderNodeMath"); mul.operation = "MULTIPLY"; mul.inputs[1].default_value = 3.0
208
+ nt.links.new(sep.outputs["X"], mul.inputs[0])
209
+ add = nt.nodes.new("ShaderNodeMath"); add.operation = "ADD"
210
+ nt.links.new(mul.outputs[0], add.inputs[0]); nt.links.new(rnd.outputs["Fac"], add.inputs[1])
211
+ sub = nt.nodes.new("ShaderNodeMath"); sub.operation = "SUBTRACT"
212
+ nt.links.new(add.outputs[0], sub.inputs[0]); nt.links.new(phase.outputs[0], sub.inputs[1])
213
+ fr = nt.nodes.new("ShaderNodeMath"); fr.operation = "FRACT"
214
+ nt.links.new(sub.outputs[0], fr.inputs[0])
215
+ # sharp comet: pow(fract, 18)
216
+ pw = nt.nodes.new("ShaderNodeMath"); pw.operation = "POWER"; pw.inputs[1].default_value = 22.0
217
+ nt.links.new(fr.outputs[0], pw.inputs[0])
218
+ gain = nt.nodes.new("ShaderNodeMath"); gain.operation = "MULTIPLY"; gain.inputs[1].default_value = emission_gain
219
+ nt.links.new(pw.outputs[0], gain.inputs[0])
220
+
221
+ # brighten colour a touch towards the edges of the ribbon (woven sheen)
222
+ nt.links.new(attr.outputs["Color"], p.inputs["Base Color"])
223
+ nt.links.new(attr.outputs["Color"], p.inputs["Emission Color"])
224
+ nt.links.new(gain.outputs[0], p.inputs["Emission Strength"])
225
+ p.inputs["Roughness"].default_value = 0.32
226
+ p.inputs["Anisotropic"].default_value = 0.85
227
+ nt.links.new(tangent.outputs[0], p.inputs["Tangent"])
228
+ p.inputs["Sheen Weight"].default_value = 0.5
229
+ p.inputs["Sheen Roughness"].default_value = 0.35
230
+ nt.links.new(attr.outputs["Color"], p.inputs["Sheen Tint"])
231
+ p.inputs["Coat Weight"].default_value = 0.25
232
+ p.inputs["Coat Roughness"].default_value = 0.12
233
+ p.inputs["Specular IOR Level"].default_value = 0.6
234
+ nt.links.new(p.outputs[0], out.inputs[0])
235
+ return m, phase
236
+
237
+
238
+ silk_mat, silk_phase = silk_material("silk", 5.0)
239
+ back_mat, back_phase = silk_material("silk_back", 1.5)
240
+ front.obj.data.materials.append(silk_mat)
241
+ back.obj.data.materials.append(back_mat)
242
+
243
+ # ---------------------------------------------------------------- world + lights
244
+ world = bpy.data.worlds.new("w")
245
+ scene.world = world
246
+ wn = world.node_tree
247
+ wn.nodes.clear()
248
+ wo = wn.nodes.new("ShaderNodeOutputWorld")
249
+ bg = wn.nodes.new("ShaderNodeBackground")
250
+ tc = wn.nodes.new("ShaderNodeTexCoord")
251
+ sep = wn.nodes.new("ShaderNodeSeparateXYZ")
252
+ ramp = wn.nodes.new("ShaderNodeValToRGB")
253
+ wn.links.new(tc.outputs["Window"], sep.inputs[0])
254
+ wn.links.new(sep.outputs["Y"], ramp.inputs[0])
255
+ ramp.color_ramp.elements[0].color = (0.05, 0.01, 0.12, 1)
256
+ ramp.color_ramp.elements[1].color = (0.20, 0.02, 0.18, 1)
257
+ wn.links.new(ramp.outputs[0], bg.inputs[0])
258
+ bg.inputs[1].default_value = 1.0
259
+ wn.links.new(bg.outputs[0], wo.inputs[0])
260
+
261
+
262
+ def area(name, loc, rot, size, color, energy):
263
+ d = bpy.data.lights.new(name, "AREA")
264
+ d.size = size
265
+ d.color = color
266
+ d.energy = energy
267
+ o = bpy.data.objects.new(name, d)
268
+ o.location = loc
269
+ o.rotation_euler = rot
270
+ scene.collection.objects.link(o)
271
+ return o
272
+
273
+
274
+ area("key", (-2.0, 3.5, 6.0), (math.radians(-30), math.radians(-15), 0), 6.0, (1.0, 0.95, 0.9), 700)
275
+ area("rimL", (-6.0, -3.0, 3.0), (math.radians(60), math.radians(-60), 0), 4.0, (1.0, 0.45, 0.2), 900)
276
+ area("rimR", (6.5, 3.0, 2.5), (math.radians(-55), math.radians(65), 0), 4.0, (0.3, 0.55, 1.0), 1000)
277
+ area("fill", (0.0, -4.0, 5.0), (math.radians(40), 0, 0), 8.0, (0.9, 0.5, 1.0), 200)
278
+
279
+ core = bpy.data.lights.new("core", "POINT")
280
+ core.energy = 260
281
+ core.color = (1.0, 0.62, 0.3)
282
+ core.shadow_soft_size = 0.3
283
+ core_o = bpy.data.objects.new("core", core)
284
+ core_o.location = (-0.25, 0.0, 0.9)
285
+ scene.collection.objects.link(core_o)
286
+
287
+ # glowing backdrop behind everything so nothing reads as void
288
+ bd_mesh = bpy.data.meshes.new("backdrop")
289
+ bd_mesh.from_pydata([(-14, -8, -6), (14, -8, -6), (14, 8, -6), (-14, 8, -6)], [], [(0, 1, 2, 3)])
290
+ bd = bpy.data.objects.new("backdrop", bd_mesh)
291
+ scene.collection.objects.link(bd)
292
+ bm = bpy.data.materials.new("backdrop")
293
+ bnt = bm.node_tree
294
+ bnt.nodes.clear()
295
+ bo = bnt.nodes.new("ShaderNodeOutputMaterial")
296
+ be = bnt.nodes.new("ShaderNodeEmission")
297
+ btc = bnt.nodes.new("ShaderNodeTexCoord")
298
+ bsep = bnt.nodes.new("ShaderNodeSeparateXYZ")
299
+ bramp = bnt.nodes.new("ShaderNodeValToRGB")
300
+ bnt.links.new(btc.outputs["Object"], bsep.inputs[0])
301
+ bmath = bnt.nodes.new("ShaderNodeMath"); bmath.operation = "MULTIPLY_ADD"
302
+ bmath.inputs[1].default_value = 1 / 28.0; bmath.inputs[2].default_value = 0.5
303
+ bnt.links.new(bsep.outputs["X"], bmath.inputs[0])
304
+ bnt.links.new(bmath.outputs[0], bramp.inputs[0])
305
+ els = bramp.color_ramp.elements
306
+ els[0].position = 0.25; els[0].color = (0.30, 0.03, 0.12, 1)
307
+ els[1].position = 0.75; els[1].color = (0.03, 0.06, 0.30, 1)
308
+ e = els.new(0.5); e.color = (0.25, 0.02, 0.35, 1)
309
+ bnt.links.new(bramp.outputs[0], be.inputs[0])
310
+ be.inputs[1].default_value = 1.0
311
+ bnt.links.new(be.outputs[0], bo.inputs[0])
312
+ bd_mesh.materials.append(bm)
313
+
314
+ # ---------------------------------------------------------------- camera
315
+ cam_data = bpy.data.cameras.new("cam")
316
+ cam_data.lens = 40
317
+ cam_data.sensor_width = 36
318
+ cam_data.dof.use_dof = True
319
+ cam_data.dof.focus_distance = 9.2
320
+ cam_data.dof.aperture_fstop = 2.4
321
+ cam = bpy.data.objects.new("cam", cam_data)
322
+ cam.location = (0.4, -2.2, 8.9)
323
+ cam.rotation_euler = (math.radians(14), math.radians(0), math.radians(0))
324
+ scene.collection.objects.link(cam)
325
+ scene.camera = cam
326
+
327
+ # ---------------------------------------------------------------- render
328
+ scene.render.engine = "CYCLES"
329
+ scene.render.resolution_x = 1600
330
+ scene.render.resolution_y = 800
331
+ scene.render.resolution_percentage = RES
332
+ scene.render.image_settings.file_format = "PNG"
333
+ scene.render.use_persistent_data = True
334
+ scene.view_settings.view_transform = "AgX"
335
+ scene.view_settings.look = "AgX - Punchy"
336
+ scene.view_settings.exposure = 0.0
337
+ scene.cycles.samples = SAMPLES
338
+ scene.cycles.use_denoising = True
339
+ scene.cycles.max_bounces = 6
340
+ scene.cycles.seed = 1
341
+ scene.frame_start, scene.frame_end = 1, FRAMES
342
+
343
+ prefs = bpy.context.preferences.addons["cycles"].preferences
344
+ prefs.compute_device_type = "OPTIX"
345
+ prefs.get_devices()
346
+ for d in prefs.devices:
347
+ d.use = d.type == "OPTIX"
348
+ scene.cycles.device = "GPU"
349
+ scene.cycles.denoiser = "OPTIX"
350
+ if os.environ.get("CYCLES_DEVICE") == "CPU": # for quick tests while the GPU is busy
351
+ scene.cycles.device = "CPU"
352
+ scene.cycles.denoiser = "OPENIMAGEDENOISE"
353
+
354
+ tree = bpy.data.node_groups.new("comp", "CompositorNodeTree")
355
+ scene.compositing_node_group = tree
356
+ rl = tree.nodes.new("CompositorNodeRLayers")
357
+ glare = tree.nodes.new("CompositorNodeGlare")
358
+ for k, v in (("Type", "Bloom"), ("Threshold", 1.0), ("Strength", 0.6), ("Size", 0.6), ("Quality", "High")):
359
+ try:
360
+ glare.inputs[k].default_value = v
361
+ except (KeyError, TypeError, AttributeError):
362
+ pass
363
+ gout = tree.nodes.new("NodeGroupOutput")
364
+ tree.interface.new_socket("Image", in_out="OUTPUT", socket_type="NodeSocketColor")
365
+ tree.links.new(rl.outputs["Image"], glare.inputs["Image"])
366
+ tree.links.new(glare.outputs[0], gout.inputs[0])
367
+
368
+ for f in parse_frames(SPEC):
369
+ t = ((f - 1) / FRAMES) % 1.0
370
+ scene.frame_set(f)
371
+ front.update(t)
372
+ back.update(t)
373
+ silk_phase.outputs[0].default_value = t * 2.0 # 2 pulse cycles per loop
374
+ back_phase.outputs[0].default_value = t
375
+ scene.render.filepath = os.path.join(OUT, f"frame_{f:04d}.png")
376
+ bpy.ops.render.render(write_still=True)
backend/.dockerignore ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ env/
8
+ venv/
9
+ .venv/
10
+ .env
11
+ .env.local
12
+
13
+ # IDE
14
+ .vscode/
15
+ .idea/
16
+ *.swp
17
+ *.swo
18
+
19
+ # OS
20
+ .DS_Store
21
+ .DS_Store?
22
+ ._*
23
+ .Spotlight-V100
24
+ .Trashes
25
+ ehthumbs.db
26
+ Thumbs.db
27
+
28
+ # Project specific
29
+ uploads/
30
+ logs/
31
+ *.log
32
+
33
+ # Git
34
+ .git/
35
+ .gitignore
36
+
37
+ # Documentation
38
+ README.md
39
+ *.md
backend/.env.example ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # The model size of OpenAI Whisper (see https://github.com/openai/whisper#available-models-and-languages)
2
+ # Used when TRANSCRIPTION_PROVIDER=whisper
3
+ WHISPER_MODEL_SIZE=medium
4
+
5
+ # Transcription provider: assemblyai (default), whisper, or youtube_captions
6
+ # - assemblyai: cloud API, best accuracy with speaker diarization (requires ASSEMBLY_AI_API_KEY)
7
+ # - whisper: local transcription, no API key needed
8
+ # - youtube_captions: extract from YouTube captions (YouTube-sourced only)
9
+ TRANSCRIPTION_PROVIDER=assemblyai
10
+ # Optional AssemblyAI model override across every processing mode.
11
+ # universal-2 retains word timings and speaker diarization at lower cost.
12
+ ASSEMBLY_AI_SPEECH_MODEL=
13
+
14
+ # LLM Providers
15
+ OPENAI_API_KEY=
16
+ GOOGLE_API_KEY=
17
+ YOUTUBE_DATA_API_KEY=
18
+ ANTHROPIC_API_KEY=
19
+ OPENROUTER_API_KEY=
20
+ # NVIDIA hosted trial key. Select LLM=nvidia:minimaxai/minimax-m3.1-flash.
21
+ NVIDIA_API_KEY=
22
+ # Optional. Defaults to http://localhost:11434/v1 for local backend runs,
23
+ # or http://host.docker.internal:11434/v1 inside Docker.
24
+ OLLAMA_BASE_URL=
25
+ OLLAMA_API_KEY=
26
+
27
+ # The AI Model to use throughout the app
28
+ LLM=google-gla:gemini-3-flash-preview
29
+ # Optional separate reranker; empty inherits LLM. Also configurable in Admin.
30
+ RERANK_LLM=
31
+
32
+ # Optional editor-only model; default is claude-sonnet-5-5.
33
+ # AI_EDIT_MODEL=ollama:qwen3.8:27b
34
+ # AI_EDIT_DAILY_LIMIT=150
35
+
36
+ # Prevent tasks from sitting in queued forever if worker is down
37
+ QUEUED_TASK_TIMEOUT_SECONDS=180
38
+
39
+ # YouTube metadata lookup provider: `yt_dlp` or `youtube_data_api`
40
+ YOUTUBE_METADATA_PROVIDER=yt_dlp
41
+ # Task-creation YouTube length check, in seconds (default 30, cap 180).
42
+ YOUTUBE_PREFLIGHT_TIMEOUT_SECONDS=30
43
+
44
+ # Processing defaults
45
+ DEFAULT_PROCESSING_MODE=fast
46
+ FAST_MODE_MAX_CLIPS=4
47
+ FAST_MODE_TRANSCRIPT_MODEL=nano
48
+
49
+ # Good for speed optimizations
50
+ COMPOSE_BAKE=true
51
+
52
+ # DB
53
+ POSTGRES_DB=supoclip
54
+ POSTGRES_USER=supoclip
55
+ POSTGRES_PASSWORD=supoclip_password
56
+
57
+ ASSEMBLY_AI_API_KEY=
58
+
59
+ # Discord webhook URLs (each posts to a separate channel)
60
+ DISCORD_FEEDBACK_WEBHOOK_URL=
61
+ DISCORD_SALES_WEBHOOK_URL=
62
+
63
+ # Monetization (only enabled when SELF_HOST=false)
64
+ SELF_HOST=true
65
+ BACKEND_AUTH_SECRET=change_me_backend_auth_secret
66
+ APP_SETTINGS_ENCRYPTION_KEY=change_me_settings_encryption_secret
67
+ ALLOW_UNSIGNED_BACKEND_AUTH=false
68
+ AUTH_SIGNATURE_TTL_SECONDS=300
69
+ CORS_ORIGINS=http://localhost:3000,http://sp.localhost:3000,http://supoclip.localhost:3000
70
+ # Hosted mode requires a paid subscription. Monthly allowance in minutes of
71
+ # source video (0 = unlimited).
72
+ PRO_PLAN_MINUTE_LIMIT=600
73
+ SCALE_PLAN_MINUTE_LIMIT=1500
74
+
75
+ # Durable media: local for self-hosting, s3 for private object storage.
76
+ # IAM roles/default AWS credentials work when dedicated media keys are blank.
77
+ MEDIA_STORAGE=local
78
+ MEDIA_S3_BUCKET=
79
+ MEDIA_S3_PREFIX=media
80
+ MEDIA_S3_REGION=eu-central-1
81
+ MEDIA_S3_ENDPOINT=
82
+ MEDIA_S3_ACCESS_KEY_ID=
83
+ MEDIA_S3_SECRET_ACCESS_KEY=
84
+ MEDIA_S3_SESSION_TOKEN=
85
+ # Optional independent S3-compatible mirror (for example Cloudflare R2).
86
+ # Enable failover only after existing media has been copied and verified.
87
+ MEDIA_FALLBACK_BUCKET=
88
+ MEDIA_FALLBACK_ENDPOINT=
89
+ MEDIA_FALLBACK_REGION=auto
90
+ MEDIA_FALLBACK_ACCESS_KEY_ID=
91
+ MEDIA_FALLBACK_SECRET_ACCESS_KEY=
92
+ MEDIA_FAILOVER_ENABLED=false
93
+ MEDIA_URL_TTL_SECONDS=900
94
+ MEDIA_CACHE_TTL_SECONDS=86400
95
+ MEDIA_ORPHAN_GRACE_SECONDS=86400
96
+ MEDIA_UPLOAD_CONCURRENCY=3
97
+ MEDIA_UPLOAD_DAILY_LIMIT=20
backend/.pytest_cache/.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ # Created by pytest automatically.
2
+ *
backend/.pytest_cache/CACHEDIR.TAG ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ Signature: 8a477f597d28d172789f06886806bc55
2
+ # This file is a cache directory tag created by pytest.
3
+ # For information about cache directory tags, see:
4
+ # https://bford.info/cachedir/spec.html
backend/.pytest_cache/README.md ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ # pytest cache directory #
2
+
3
+ This directory contains data from the pytest's cache plugin,
4
+ which provides the `--lf` and `--ff` options, as well as the `cache` fixture.
5
+
6
+ **Do not** commit this to version control.
7
+
8
+ See [the docs](https://docs.pytest.org/en/stable/how-to/cache.html) for more information.
backend/.pytest_cache/v/cache/lastfailed ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "tests/unit/test_workflow_llm.py": true
3
+ }
backend/.pytest_cache/v/cache/nodeids ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ "tests/unit/test_ai_prompt.py::test_analysis_forwards_instructions_to_every_window_and_the_rerank[Focus on the bank]",
3
+ "tests/unit/test_ai_prompt.py::test_analysis_forwards_instructions_to_every_window_and_the_rerank[None]",
4
+ "tests/unit/test_ai_prompt.py::test_build_transcript_analysis_prompt_requires_transcript_fidelity",
5
+ "tests/unit/test_ai_prompt.py::test_clip_selection_prompts_never_ask_for_broll",
6
+ "tests/unit/test_ai_prompt.py::test_instructions_cannot_close_their_fence",
7
+ "tests/unit/test_ai_prompt.py::test_instructions_go_into_the_user_prompt_just_before_the_transcript",
8
+ "tests/unit/test_ai_prompt.py::test_llm_validation_rejects_unsupported_or_incomplete_model_names",
9
+ "tests/unit/test_ai_prompt.py::test_ollama_llm_builds_native_ollama_model",
10
+ "tests/unit/test_ai_prompt.py::test_parse_transcript_timestamp_supports_minute_and_hour_formats",
11
+ "tests/unit/test_ai_prompt.py::test_prompts_without_instructions_are_byte_identical_to_before_workflows",
12
+ "tests/unit/test_ai_prompt.py::test_rerank_prompt_ends_with_the_instructions",
13
+ "tests/unit/test_ai_prompt.py::test_system_prompt_enforces_grounding_rules",
14
+ "tests/unit/test_ai_prompt.py::test_transcript_segment_normalizes_percent_relevance_score",
15
+ "tests/unit/test_ai_prompt.py::test_transcript_span_helpers_repair_near_miss_durations",
16
+ "tests/unit/test_hf_runtime.py::test_bootstrap_finishes_before_public_listener",
17
+ "tests/unit/test_hf_runtime.py::test_dead_child_is_not_treated_as_a_working_app",
18
+ "tests/unit/test_hf_runtime.py::test_explicit_secrets_and_rotation_guard",
19
+ "tests/unit/test_hf_runtime.py::test_ffmpeg_every_input_has_decoder_cap_for_crossfade",
20
+ "tests/unit/test_hf_runtime.py::test_ffmpeg_limits_both_input_and_output_without_changing_codec_or_stdin",
21
+ "tests/unit/test_hf_runtime.py::test_ffmpeg_per_stream_thread_overrides_are_bounded",
22
+ "tests/unit/test_hf_runtime.py::test_ffmpeg_queries_are_untouched[arguments0]",
23
+ "tests/unit/test_hf_runtime.py::test_ffmpeg_queries_are_untouched[arguments1]",
24
+ "tests/unit/test_hf_runtime.py::test_ffmpeg_queries_are_untouched[arguments2]",
25
+ "tests/unit/test_hf_runtime.py::test_ffmpeg_rejects_unbounded_thread_counts[-1]",
26
+ "tests/unit/test_hf_runtime.py::test_ffmpeg_rejects_unbounded_thread_counts[0]",
27
+ "tests/unit/test_hf_runtime.py::test_ffmpeg_rejects_unbounded_thread_counts[3]",
28
+ "tests/unit/test_hf_runtime.py::test_generated_secrets_are_distinct_and_reused",
29
+ "tests/unit/test_hf_runtime.py::test_process_environments_use_one_local_database_with_distinct_drivers",
30
+ "tests/unit/test_hf_runtime.py::test_proxy_keeps_auth_uploads_and_sse_on_next",
31
+ "tests/unit/test_hf_runtime.py::test_public_origin[env0-https://owner-space.hf.space]",
32
+ "tests/unit/test_hf_runtime.py::test_public_origin[env1-https://owner-space.hf.space]",
33
+ "tests/unit/test_hf_runtime.py::test_public_origin[env2-http://localhost:7860]",
34
+ "tests/unit/test_hf_runtime.py::test_public_origin[env3-http://127.0.0.1:7860]",
35
+ "tests/unit/test_hf_runtime.py::test_public_origin_rejects_unsafe_values[env0]",
36
+ "tests/unit/test_hf_runtime.py::test_public_origin_rejects_unsafe_values[env10]",
37
+ "tests/unit/test_hf_runtime.py::test_public_origin_rejects_unsafe_values[env1]",
38
+ "tests/unit/test_hf_runtime.py::test_public_origin_rejects_unsafe_values[env2]",
39
+ "tests/unit/test_hf_runtime.py::test_public_origin_rejects_unsafe_values[env3]",
40
+ "tests/unit/test_hf_runtime.py::test_public_origin_rejects_unsafe_values[env4]",
41
+ "tests/unit/test_hf_runtime.py::test_public_origin_rejects_unsafe_values[env5]",
42
+ "tests/unit/test_hf_runtime.py::test_public_origin_rejects_unsafe_values[env6]",
43
+ "tests/unit/test_hf_runtime.py::test_public_origin_rejects_unsafe_values[env7]",
44
+ "tests/unit/test_hf_runtime.py::test_public_origin_rejects_unsafe_values[env8]",
45
+ "tests/unit/test_hf_runtime.py::test_public_origin_rejects_unsafe_values[env9]",
46
+ "tests/unit/test_hf_runtime.py::test_service_failures_do_not_leak_command_arguments_or_stderr",
47
+ "tests/unit/test_hf_runtime.py::test_short_or_corrupt_secrets_do_not_get_silently_replaced",
48
+ "tests/unit/test_hf_runtime.py::test_shutdown_signals_all_process_groups_and_kills_stuck_children",
49
+ "tests/unit/test_hf_runtime.py::test_space_build_uses_locked_cpu_dependencies_and_only_public_port",
50
+ "tests/unit/test_hf_runtime.py::test_three_hour_limit_is_consumed_by_backend_config",
51
+ "tests/unit/test_nvidia_analysis.py::test_admin_catalog_exposes_nvidia_without_returning_keys",
52
+ "tests/unit/test_nvidia_analysis.py::test_admin_endpoint_rejects_malformed_nvidia_reranker_before_save",
53
+ "tests/unit/test_nvidia_analysis.py::test_admin_patch_accepts_model_and_key_together_and_encrypts_them",
54
+ "tests/unit/test_nvidia_analysis.py::test_admin_still_requires_admin_access",
55
+ "tests/unit/test_nvidia_analysis.py::test_custom_nvidia_model_is_not_replaced",
56
+ "tests/unit/test_nvidia_analysis.py::test_default_model_and_reranker_follow_nvidia_key",
57
+ "tests/unit/test_nvidia_analysis.py::test_invalid_ids_fail_before_network[nvidia:/model]",
58
+ "tests/unit/test_nvidia_analysis.py::test_invalid_ids_fail_before_network[nvidia:]",
59
+ "tests/unit/test_nvidia_analysis.py::test_invalid_ids_fail_before_network[nvidia:minimax]",
60
+ "tests/unit/test_nvidia_analysis.py::test_invalid_ids_fail_before_network[nvidia:vendor/]",
61
+ "tests/unit/test_nvidia_analysis.py::test_invalid_ids_fail_before_network[nvidia:vendor/model with spaces]",
62
+ "tests/unit/test_nvidia_analysis.py::test_key_rotation_rebuilds_every_cached_ai_agent[get_broll_agent]",
63
+ "tests/unit/test_nvidia_analysis.py::test_key_rotation_rebuilds_every_cached_ai_agent[get_rerank_agent]",
64
+ "tests/unit/test_nvidia_analysis.py::test_key_rotation_rebuilds_every_cached_ai_agent[get_transcript_agent]",
65
+ "tests/unit/test_nvidia_analysis.py::test_missing_key_is_reported_before_network",
66
+ "tests/unit/test_nvidia_analysis.py::test_real_sdk_uses_nvidia_key_endpoint_and_validated_tool_output[CandidateRanking-expected1]",
67
+ "tests/unit/test_nvidia_analysis.py::test_real_sdk_uses_nvidia_key_endpoint_and_validated_tool_output[TranscriptAnalysis-expected0]",
68
+ "tests/unit/test_nvidia_analysis.py::test_saved_key_and_reranker_respect_existing_environment_priority",
69
+ "tests/unit/test_nvidia_analysis.py::test_workflow_planners_use_nvidia_and_refresh_after_key_rotation",
70
+ "tests/unit/test_openrouter_analysis.py::test_admin_key_status_is_masked",
71
+ "tests/unit/test_openrouter_analysis.py::test_agent_cache_refreshes_after_key_or_fallback_change",
72
+ "tests/unit/test_openrouter_analysis.py::test_invalid_model_ids_fail_before_request",
73
+ "tests/unit/test_openrouter_analysis.py::test_missing_key_fails_before_request",
74
+ "tests/unit/test_openrouter_analysis.py::test_native_schema_request_and_both_model_responses[anthropic/claude-sonnet-5.5]",
75
+ "tests/unit/test_openrouter_analysis.py::test_native_schema_request_and_both_model_responses[openai/gpt-6-luna]"
76
+ ]
backend/.python-version ADDED
@@ -0,0 +1 @@
 
 
1
+ 3.11
backend/Dockerfile ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use Python 3.11 slim image
2
+ FROM python:3.11.17-slim-trixie
3
+
4
+ # Install system dependencies including ffmpeg and unzip (for deno).
5
+ # Noto provides fallback glyphs for multilingual captions (including Hindi)
6
+ # and colour emoji. libass/fontconfig selects them when a chosen font lacks glyphs.
7
+ RUN apt-get update && apt-get install -y \
8
+ ffmpeg \
9
+ tesseract-ocr \
10
+ tesseract-ocr-eng \
11
+ curl \
12
+ unzip \
13
+ fonts-noto-core \
14
+ fonts-noto-cjk \
15
+ fonts-noto-color-emoji \
16
+ fontconfig \
17
+ && fc-cache -f \
18
+ && rm -rf /var/lib/apt/lists/*
19
+
20
+ # Install deno (required by yt-dlp for YouTube JS challenge solving)
21
+ RUN curl -fsSL https://deno.land/install.sh | sh
22
+ ENV DENO_DIR=/root/.deno
23
+ ENV PATH="/root/.deno/bin:${PATH}"
24
+
25
+ # Install uv package manager
26
+ RUN pip install uv
27
+
28
+ # Set working directory
29
+ WORKDIR /app
30
+
31
+ # Copy pyproject.toml and uv.lock for dependency installation
32
+ COPY pyproject.toml uv.lock* ./
33
+
34
+ # New self-hosted setups can select CPU wheels without changing legacy builds.
35
+ ARG BACKEND_CPU_ONLY=false
36
+ RUN uv venv .venv && \
37
+ if [ "$BACKEND_CPU_ONLY" = "true" ]; then \
38
+ uv sync --frozen --extra cpu; \
39
+ else \
40
+ uv sync --frozen --extra cuda; \
41
+ fi
42
+
43
+ # yt-dlp and its PO-token plugin are installed from uv.lock above.
44
+
45
+ # Copy source code
46
+ COPY src/ ./src/
47
+
48
+ # Copy fonts and transitions directories
49
+ COPY fonts/ ./fonts/
50
+ COPY transitions/ ./transitions/
51
+
52
+ # Create necessary directories for video processing
53
+ RUN mkdir -p /app/uploads /app/clips /app/logs /tmp
54
+
55
+ # Expose the port FastAPI will run on
56
+ EXPOSE 8000
57
+
58
+ # Activate virtual environment and start the application
59
+ CMD [".venv/bin/uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000"]
backend/README.md ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Backend Docs
2
+
3
+ ## Requirements
4
+
5
+ Ensure you have `ffmpeg` installed.
6
+
7
+ ```
8
+ # MacOS
9
+ brew install ffmpeg
10
+
11
+ # Linux (Ubuntu)
12
+ sudo apt update -y && sudo apt install install ffmpeg -y
13
+
14
+ # Windows (Chocolatey https://chocolatey.org/)
15
+ choco install ffmpeg
16
+ ```
17
+
18
+ You must also have `uv` package manager installed.
19
+
20
+ 1. Create a virtual environment
21
+
22
+ ```
23
+ uv venv .venv
24
+ source .venv/bin/activate
25
+ ```
26
+
27
+ ## Running Tests
28
+
29
+ The backend test suite uses `pytest` and is organized into:
30
+
31
+ - `tests/unit` for fast unit coverage around helpers and services
32
+ - `tests/integration` for FastAPI, database, and queue-backed API checks
33
+ - legacy `unittest`-style tests, which still run under `pytest`
34
+
35
+ Install dependencies:
36
+
37
+ ```bash
38
+ uv sync --all-groups
39
+ ```
40
+
41
+ Run the backend suite:
42
+
43
+ ```bash
44
+ DATABASE_URL=postgresql+asyncpg://localhost:5432/supoclip \
45
+ TEST_DATABASE_URL=postgresql+asyncpg://localhost:5432/supoclip \
46
+ REDIS_HOST=127.0.0.1 \
47
+ REDIS_PORT=6379 \
48
+ .venv/bin/pytest
49
+ ```
50
+
51
+ Notes:
52
+
53
+ - `TEST_DATABASE_URL` should point at a disposable local test database.
54
+ - Redis is only required for the integration paths that validate queue and health behavior.
55
+ - Coverage thresholds are enforced in `pyproject.toml` during the test run.
56
+ - For repo-level entrypoints, use `make test-backend` or `make test-ci` from the repository root.
57
+
58
+ ## Email Configuration
59
+
60
+ The backend now sends subscription lifecycle emails through Amazon SES.
61
+
62
+ Set these env vars when using hosted billing:
63
+
64
+ ```
65
+ AWS_REGION=us-east-1
66
+ AWS_ACCESS_KEY_ID=your_aws_access_key_id
67
+ AWS_SECRET_ACCESS_KEY=your_aws_secret_access_key
68
+ SES_FROM_EMAIL="SupoClip <onboarding@example.com>"
69
+ ```
70
+
71
+ Notes:
72
+
73
+ - `SES_FROM_EMAIL` must be a verified identity/domain in Amazon SES.
74
+ - The thank-you email is triggered after a successful Stripe checkout.
75
+ - The cancellation email is triggered after Stripe subscription deletion.
76
+ - Password reset links ("Forgot password?" on sign-in) are sent via `POST /account/password-reset-email`, which only accepts the frontend's signed session headers. Without SES configured, reset requests succeed silently but no email is sent.
77
+
78
+ ## YouTube Downloads
79
+
80
+ YouTube downloads use `yt-dlp` by default so self-hosted and free deployments do not need Apify.
81
+
82
+ ```env
83
+ YOUTUBE_DOWNLOAD_PROVIDER=yt_dlp
84
+ ```
85
+
86
+ Set `YOUTUBE_DOWNLOAD_PROVIDER=apify` only when you want to use the paid Apify actor as the primary downloader:
87
+
88
+ ```env
89
+ YOUTUBE_DOWNLOAD_PROVIDER=apify
90
+ APIFY_API_TOKEN=your_apify_token
91
+ # Select your own worker explicitly; match its input contract.
92
+ APIFY_YOUTUBE_DOWNLOADER_ACTOR=your-account/your-worker
93
+ APIFY_YOUTUBE_INPUT_ADAPTER=start_urls
94
+ APIFY_YOUTUBE_DEFAULT_QUALITY=1080
95
+ APIFY_RUN_TIMEOUT_SECONDS=900
96
+ ```
97
+
98
+ Notes:
99
+
100
+ - `yt_dlp` is the free default and does not require `APIFY_API_TOKEN`.
101
+ - If `yt-dlp` fails and both `APIFY_API_TOKEN` and an explicit worker are configured, the backend can try Apify as a fallback.
102
+ - If Apify is selected but unavailable or fails, the backend falls back to `yt-dlp`.
103
+ - `APIFY_RUN_TIMEOUT_SECONDS` caps the Apify actor run time before SupoClip gives up.
104
+ - `APIFY_EXPENSIVE_FALLBACKS` defaults to off, so only the primary actor runs. Set it to `true` to allow the configured fallback actors.
105
+ - `YOUTUBE_PROXY_URL` inserts a residential-proxy yt-dlp attempt ahead of that chain and switches jobs to audio-then-sections. Video is capped at 1080p either way. Setup is in [docs/youtube-download.md](../docs/youtube-download.md).
106
+
107
+ For an ordered verified provider pool and private S3 delivery, configure
108
+ `APIFY_YOUTUBE_PROVIDERS` and the related private settings documented in
109
+ [configuration](../docs/configuration.md). Legacy input adapters are `start_urls`,
110
+ `progressive`, and `kv_videos`; use the contract expected by your chosen worker.
111
+
112
+ ## YouTube Metadata Provider
113
+
114
+ Metadata lookup is configurable separately from downloads.
115
+
116
+ Set these env vars to use the official YouTube Data API v3 for title, duration, channel, thumbnail, and view-count preflight:
117
+
118
+ ```env
119
+ YOUTUBE_METADATA_PROVIDER=youtube_data_api
120
+ YOUTUBE_DATA_API_KEY=your_youtube_data_api_key
121
+ ```
122
+
123
+ Notes:
124
+
125
+ - `YOUTUBE_METADATA_PROVIDER=yt_dlp` preserves the previous metadata behavior.
126
+ - If `YOUTUBE_DATA_API_KEY` is not set, the backend will try `GOOGLE_API_KEY` for YouTube metadata requests.
127
+ - The selected metadata provider is the primary path only; the backend automatically falls back to the other provider if the first one fails.
128
+ - `videos.list` costs 1 quota unit per request in the YouTube Data API.
129
+ - The public API does not expose some `yt-dlp`-specific metadata fields like `format_id`, `resolution`, `fps`, or file size.
130
+ - Enable the YouTube Data API v3 for your Google Cloud project before using this mode.
backend/REFACTORING_GUIDE.md ADDED
@@ -0,0 +1,330 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ > Historical migration notes. The migration is complete: `src.main:app` is now canonical and `src.main_refactored:app` is a compatibility alias. See [architecture](../docs/architecture.md) for the current layout.
2
+
3
+ # Backend Refactoring Guide
4
+
5
+ ## 🎯 What Changed
6
+
7
+ The backend has been completely refactored from a monolithic structure to a proper layered architecture with:
8
+
9
+ ### Architecture Improvements
10
+
11
+ **Before:**
12
+ - 650+ lines in main.py
13
+ - Blocking sync operations (video processing, downloads) in async context
14
+ - `asyncio.create_task()` for background jobs (lost on restart)
15
+ - No progress tracking
16
+ - Multiple database sessions per request
17
+ - No separation of concerns
18
+
19
+ **After:**
20
+ - **Layered Architecture**: routes → services → repositories
21
+ - **Async Job Queue**: arq (Redis-based) with persistent jobs
22
+ - **Separate Worker Process**: Video processing runs independently
23
+ - **Thread Pool**: Blocking operations don't block the event loop
24
+ - **Real-time Progress**: SSE (Server-Sent Events) + Redis pub/sub
25
+ - **Granular Status**: queued → downloading → transcribing → analyzing → generating_clips → completed
26
+
27
+ ### New Directory Structure
28
+
29
+ ```
30
+ backend/src/
31
+ ├── api/routes/
32
+ │ ├── tasks.py # Task endpoints + SSE
33
+ │ └── media.py # Fonts, transitions, uploads
34
+ ├── services/
35
+ │ ├── video_service.py # Video processing logic
36
+ │ └── task_service.py # Task orchestration
37
+ ├── repositories/
38
+ │ ├── task_repository.py # Task DB operations
39
+ │ ├── clip_repository.py # Clip DB operations
40
+ │ └── source_repository.py
41
+ ├── workers/
42
+ │ ├── tasks.py # arq worker functions
43
+ │ ├── job_queue.py # Queue management
44
+ │ └── progress.py # Progress tracking
45
+ ├── utils/
46
+ │ └── async_helpers.py # Async wrappers
47
+ ├── main_refactored.py # New clean entry point
48
+ └── worker_main.py # Worker process entry
49
+ ```
50
+
51
+ ## 🚀 Deployment Steps
52
+
53
+ ### Step 1: Apply Database Migration
54
+
55
+ The refactoring adds `progress` and `progress_message` fields to the tasks table.
56
+
57
+ ```bash
58
+ # Apply migration to existing database
59
+ docker exec -i supoclip-postgres psql -U postgres -d supoclip < backend/migrations/001_add_progress_fields.sql
60
+ ```
61
+
62
+ For fresh installs, the updated `init.sql` already includes these fields.
63
+
64
+ ### Step 2: Install New Dependencies
65
+
66
+ ```bash
67
+ cd backend
68
+
69
+ # Install arq and redis
70
+ uv sync
71
+
72
+ # Or manually:
73
+ uv pip install arq>=0.26.0 redis>=5.0.0
74
+ ```
75
+
76
+ ### Step 3: Update Docker Configuration
77
+
78
+ #### Option A: Update Dockerfile
79
+
80
+ The Dockerfile will automatically pick up new dependencies from `pyproject.toml`:
81
+
82
+ ```bash
83
+ docker-compose build backend
84
+ ```
85
+
86
+ #### Option B: Add Worker Service (Recommended)
87
+
88
+ Edit `docker-compose.yml` to add a separate worker service:
89
+
90
+ ```yaml
91
+ services:
92
+ supoclip-worker:
93
+ build: ./backend
94
+ command: [".venv/bin/arq", "src.workers.tasks.WorkerSettings"]
95
+ environment:
96
+ - DATABASE_URL=postgresql://postgres:postgres@postgres:5432/supoclip
97
+ - REDIS_HOST=redis
98
+ - REDIS_PORT=6379
99
+ - ASSEMBLY_AI_API_KEY=${ASSEMBLY_AI_API_KEY}
100
+ - LLM=${LLM}
101
+ - GOOGLE_API_KEY=${GOOGLE_API_KEY}
102
+ - TEMP_DIR=/tmp
103
+ volumes:
104
+ - ./backend:/app
105
+ - /tmp:/tmp
106
+ depends_on:
107
+ - postgres
108
+ - redis
109
+ restart: unless-stopped
110
+ ```
111
+
112
+ ### Step 4: Switch to Refactored Main
113
+
114
+ Update `Dockerfile` CMD or docker-compose command:
115
+
116
+ ```dockerfile
117
+ # Change from:
118
+ CMD [".venv/bin/uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000"]
119
+
120
+ # To:
121
+ CMD [".venv/bin/uvicorn", "src.main_refactored:app", "--host", "0.0.0.0", "--port", "8000"]
122
+ ```
123
+
124
+ Or in `docker-compose.yml`:
125
+
126
+ ```yaml
127
+ supoclip-backend:
128
+ command: [".venv/bin/uvicorn", "src.main_refactored:app", "--host", "0.0.0.0", "--port", "8000"]
129
+ ```
130
+
131
+ ### Step 5: Restart Services
132
+
133
+ ```bash
134
+ docker-compose down
135
+ docker-compose up -d --build
136
+ ```
137
+
138
+ ## 🧪 Testing the Refactored System
139
+
140
+ ### 1. Check Health Endpoints
141
+
142
+ ```bash
143
+ # Basic health
144
+ curl http://localhost:8000/health
145
+
146
+ # Database health
147
+ curl http://localhost:8000/health/db
148
+
149
+ # Redis health (new!)
150
+ curl http://localhost:8000/health/redis
151
+ ```
152
+
153
+ ### 2. Create a Task
154
+
155
+ ```bash
156
+ curl -X POST http://localhost:8000/tasks/ \
157
+ -H "Content-Type: application/json" \
158
+ -H "user_id: YOUR_USER_ID" \
159
+ -d '{
160
+ "source": {
161
+ "url": "https://www.youtube.com/watch?v=VIDEO_ID"
162
+ },
163
+ "font_options": {
164
+ "font_family": "TikTokSans-Regular",
165
+ "font_size": 24,
166
+ "font_color": "#FFFFFF"
167
+ }
168
+ }'
169
+ ```
170
+
171
+ Response:
172
+ ```json
173
+ {
174
+ "task_id": "uuid-here",
175
+ "job_id": "job-uuid",
176
+ "message": "Task created and queued for processing"
177
+ }
178
+ ```
179
+
180
+ ### 3. Watch Real-time Progress (SSE)
181
+
182
+ ```bash
183
+ curl -N http://localhost:8000/tasks/{task_id}/progress
184
+ ```
185
+
186
+ You'll see streaming events like:
187
+ ```
188
+ event: status
189
+ data: {"task_id":"...","status":"queued","progress":0,"message":""}
190
+
191
+ event: progress
192
+ data: {"task_id":"...","status":"processing","progress":10,"message":"Downloading video..."}
193
+
194
+ event: progress
195
+ data: {"task_id":"...","status":"processing","progress":30,"message":"Generating transcript..."}
196
+
197
+ ... etc ...
198
+
199
+ event: close
200
+ data: {"status":"completed"}
201
+ ```
202
+
203
+ ### 4. Get Task Details
204
+
205
+ ```bash
206
+ curl http://localhost:8000/tasks/{task_id}
207
+ ```
208
+
209
+ ### 5. Get Clips
210
+
211
+ ```bash
212
+ curl http://localhost:8000/tasks/{task_id}/clips
213
+ ```
214
+
215
+ ## 📊 Monitoring Workers
216
+
217
+ ### View Worker Logs
218
+
219
+ ```bash
220
+ # If using separate worker service:
221
+ docker-compose logs -f supoclip-worker
222
+
223
+ # Or check Redis queue status:
224
+ docker exec -it supoclip-redis redis-cli
225
+ > KEYS arq:*
226
+ > LLEN arq:queue
227
+ ```
228
+
229
+ ### Check Job Status
230
+
231
+ The arq queue stores job status in Redis. You can inspect with:
232
+
233
+ ```bash
234
+ docker exec -it supoclip-redis redis-cli
235
+ > KEYS arq:job:*
236
+ > GET arq:job:{job_id}
237
+ ```
238
+
239
+ ## 🔄 Rollback Plan
240
+
241
+ If issues arise, you can rollback:
242
+
243
+ ### Option 1: Switch Back to Old Main
244
+
245
+ ```yaml
246
+ # docker-compose.yml
247
+ supoclip-backend:
248
+ command: [".venv/bin/uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000"]
249
+ ```
250
+
251
+ ### Option 2: Keep Both Running
252
+
253
+ You can run both versions simultaneously on different ports for gradual migration:
254
+
255
+ - Old: `src.main:app` on port 8000
256
+ - New: `src.main_refactored:app` on port 8001
257
+
258
+ ## 🎯 Performance Improvements
259
+
260
+ ### Before Refactoring:
261
+ - ❌ Task page took 60+ seconds to show title
262
+ - ❌ Blocking operations stalled the entire server
263
+ - ❌ No progress visibility
264
+ - ❌ Jobs lost on restart
265
+
266
+ ### After Refactoring:
267
+ - ✅ Instant task creation (< 100ms)
268
+ - ✅ Real-time progress updates
269
+ - ✅ Non-blocking API (video processing in workers)
270
+ - ✅ Persistent jobs survive restarts
271
+ - ✅ Horizontal scaling (add more workers)
272
+
273
+ ## 🐛 Troubleshooting
274
+
275
+ ### "Connection refused" to Redis
276
+
277
+ Check Redis is running:
278
+ ```bash
279
+ docker-compose ps redis
280
+ docker-compose logs redis
281
+ ```
282
+
283
+ ### Worker not processing jobs
284
+
285
+ 1. Check worker is running:
286
+ ```bash
287
+ docker-compose ps supoclip-worker
288
+ docker-compose logs supoclip-worker
289
+ ```
290
+
291
+ 2. Check Redis connection:
292
+ ```bash
293
+ docker exec supoclip-backend .venv/bin/python -c "import redis; r=redis.Redis(host='redis'); print(r.ping())"
294
+ ```
295
+
296
+ ### Database migration errors
297
+
298
+ If the migration fails, run it manually:
299
+ ```sql
300
+ ALTER TABLE tasks ADD COLUMN IF NOT EXISTS progress INTEGER DEFAULT 0;
301
+ ALTER TABLE tasks ADD COLUMN IF NOT EXISTS progress_message TEXT;
302
+ ```
303
+
304
+ ## 📝 Next Steps
305
+
306
+ 1. **Update Frontend**: Consume SSE endpoint instead of polling
307
+ 2. **Monitoring**: Add Prometheus metrics for job queue
308
+ 3. **Scaling**: Deploy multiple worker instances for parallel processing
309
+ 4. **Caching**: Add Redis caching for frequently accessed data
310
+ 5. **Rate Limiting**: Protect API with rate limits
311
+
312
+ ## 🔗 API Changes
313
+
314
+ ### New Endpoints
315
+
316
+ - `POST /tasks/` - Create task (replaces `/start-with-progress`)
317
+ - `GET /tasks/{task_id}/progress` - SSE endpoint for real-time updates
318
+
319
+ ### Deprecated Endpoints
320
+
321
+ - `POST /start` - Use `/tasks/` instead
322
+ - `POST /start-with-progress` - Use `/tasks/` instead
323
+
324
+ ### Unchanged Endpoints
325
+
326
+ - `GET /tasks/{task_id}` - Still works
327
+ - `GET /tasks/{task_id}/clips` - Still works
328
+ - `GET /fonts` - Still works
329
+ - `GET /transitions` - Still works
330
+ - `POST /upload` - Still works
backend/bin/start.sh ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Make sure pwd ends with backend
2
+ if [ "$(basename "$PWD")" != "backend" ]; then
3
+ echo "Error: Please run this script from the backend directory"
4
+ exit 1
5
+ fi
6
+
7
+ # Make sure .venv exists
8
+ if [ ! -d ".venv" ]; then
9
+ echo "Error: .venv directory not found"
10
+ exit 1
11
+ fi
12
+
13
+ # Activate the virtual environment
14
+ source .venv/bin/activate
15
+
16
+ # Start the application
17
+ uvicorn src.main:app --host 0.0.0.0 --port 8000 --reload
backend/fonts/Anton-Regular.ttf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a4ba3a92350ebb031da0cb47630ac49eb265082ca1bc0450442f4a83ab947cab
3
+ size 170812
backend/fonts/ArchivoBlack-Regular.ttf ADDED
Binary file (91 kB). View file
 
backend/fonts/Bangers-Regular.ttf ADDED
Binary file (93.1 kB). View file
 
backend/fonts/BarlowCondensed-Bold.ttf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e476562ec9c1e16cf16475895b511f08c804f438cc9a9f80a44ea50a0eeb5b65
3
+ size 109912
backend/fonts/BebasNeue-Regular.ttf ADDED
Binary file (61.4 kB). View file
 
backend/fonts/DMSans.ttf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8cd08d97e89c24d0aa92edd2f0f4c8ee6195eee9b7c9f154865a58b02f0c1c0d
3
+ size 240164
backend/fonts/Inter.ttf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:29160a80ff49ddcab2c97711247e08b1fab27a484a329ce8b813d820dc559031
3
+ size 876576
backend/fonts/LeagueSpartan.ttf ADDED
Binary file (95.1 kB). View file
 
backend/fonts/Montserrat-Variable-wght.ttf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0f7b311b2f3279e4eef9b2f968bcdbab6e28f4daeb1f049f4f278a902bcd82f7
3
+ size 744936
backend/fonts/NunitoSans.ttf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f934d7142fb4784bf828da485b7dcbd90c0c80d514e9d49a5da0ed3a1ae2491d
3
+ size 571240
backend/fonts/OpenSans.ttf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:36643644f318a812aab2d2ed3bb98f8cf0872527f835fe9398d95fe6b9adb878
3
+ size 532636
backend/fonts/Oswald-Variable-wght.ttf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5b38c246e255a12f5712d640d56bcced0472466fc68983d2d0410ec0457c2817
3
+ size 172088
backend/fonts/Poppins-ExtraBold.ttf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f2ab17c1a63a0ecc12c2461848fc8a469395e3cd2d641803e889c643d9f958e1
3
+ size 154836