videogen/docs/reelforge/FEATURES.md
caelum0x d56639a594
Some checks are pending
build-images / api (push) Waiting to run
build-images / worker-gpu (push) Waiting to run
build-images / web (push) Waiting to run
codeql / Analyze (javascript-typescript) (push) Waiting to run
codeql / Analyze (python) (push) Waiting to run
perf / API hot-path micro-smoke (budgeted) (push) Waiting to run
perf / Desktop engine crates (release build check) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Waiting to run
vision2026-ci / API phase modules (ruff + pytest) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Waiting to run
vision2026-ci / Python SDK resource tests (push) Waiting to run
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Waiting to run
vision2026-ci / Alembic upgrade + drift check (push) Waiting to run
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Waiting to run
Menivor — open source release (MIT), free to use and fork
Paid, hosted product at menivor.com, now retired as a company project.
Fresh squashed history of the cleaned working tree (secret-scanned,
no .env, no customer data, no outreach logs). Built on
MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
2026-12-04 02:10:26 +03:00

177 lines
26 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ReelForge — Feature Catalog
> **Point-in-time catalog:** this narrative predates the current API expansion.
> Use [`CURRENT_STATE.md`](./CURRENT_STATE.md) for authoritative counts and gate
> results; retain this document for feature intent and historical context.
ReelForge turns a screen recording (plus an optional prompt) into a viral-style vertical UGC video: an AI avatar presenter (lip-synced), a hook-first script (TR/EN and more), CapCut-style karaoke captions, and a 1080×1920 MP4 — with a full SaaS layer (credits, multi-provider billing, teams, scheduling, growth surfaces) around it.
Every feature below is verified against the code. The API exposes **109 endpoints across 22 routers**, all mounted under `/api/v1` (see `app/router.py`, which registers the `video`, `llm`, `jobs`, `studio`, `billing`, `catalog`, `me`, `voices`, `ideas`, `notifications`, `schedule`, `covers`, `workspaces`, `brand`, `social`, `api_keys`, `analytics`, `marketplace`, `performance`, `connections`, `share`, and `creators` routers). Auth is per-user: a caller is resolved to a `User` row either by a Clerk `Bearer` JWT or by SHA-256 of the `x-api-key` header (`app/domains/reels/router.py::_resolve_user`) — where the `x-api-key` may be the static app key or a user-minted personal key, the latter carrying its own per-key rate limit + monthly quota (see **Programmatic API**). Responses use the shared MPT envelope `utils.get_response(status, data, message)`; errors are raised as `HttpException`. Forward-looking roadmap and next-phase architecture for these surfaces live in `docs/reelforge/ROADMAP_V2.md`, `docs/reelforge/ARCHITECTURE_NEXT.md` and `docs/reelforge/RESEARCH_COMPETITORS_OSS.md`.
---
## Core pipeline
The render pipeline runs as a Celery chain of six stages (`app/workers/pipeline.py::build_chain` / `start_pipeline`), each stage implemented in `app/services/reelforge.py` and parameterised by the immutable `ReelForgeParams` dataclass. A job is created + credit-debited atomically, then enqueued.
| Stage | Function (`app/services/reelforge.py`) | Purpose |
|---|---|---|
| script | `stage_script` | Generate the UGC script |
| tts | `stage_tts` (+ `_stage_tts_byov`) | Voice the script + word timings |
| avatar | `stage_avatar` | Lip-synced talking head |
| captions | `stage_captions` | Karaoke `.ass` subtitles |
| compose | `stage_compose` | Single-pass FFmpeg composition |
| upload | `stage_upload` | Finalize + optional cross-post |
**Script.** `stage_script` builds a hook-first UGC script from the job's `video_subject`/prompt, target language and duration, using the native-language "UGC creator" personas and few-shot hook templates in `app/services/script/ugc.py` (backed by `resource/hooks/{tr,en}.yaml`). A caller may instead pass a manual `video_script`, or (in dubbing) `translate_source_script` to re-translate an existing script. The finalized narration is persisted to `Job.script`. Entry point: `POST /api/v1/jobs`.
**TTS.** `stage_tts` sends the script to ElevenLabs `eleven_multilingual_v2` via the `/with-timestamps` endpoint (`app/services/tts/elevenlabs_timestamps.py`), producing narration audio plus character/word-level timestamps that are the single source of truth for both captions and avatar-duration validation. The audio is stored to R2.
**Avatar.** `stage_avatar` drives a talking-head provider behind the `TalkingHeadProvider` protocol (`app/services/avatar/base.py`). Tier A is HeyGen v2 (`app/services/avatar/heygen.py`) fed the ElevenLabs audio (HeyGen never does its own TTS, so timing never diverges); Tier B is self-hosted LatentSync on RunPod (`app/services/avatar/latentsync_runpod.py`). Provider + avatar are chosen via `params.avatar_provider` / `params.avatar_id`.
**Captions.** `stage_captions` groups the TTS word timings into 1–3-word groups and emits an ASS karaoke subtitle file with `\k` tags (`app/services/captions/ass_karaoke.py`, word grouping in `app/services/captions/words.py`), burned in later via FFmpeg libass. The look is chosen by `params.caption_style` (see Creator Studio → caption presets).
**Compose.** `stage_compose` calls the pure-FFmpeg single-pass graph builder (`app/services/compose/compose_ffmpeg.py`) to scale/crop the screen recording to 1080×1920, overlay the avatar in the selected layout (`pip` | `hook_intro` | `split`), burn captions, mix/duck audio, and apply optional watermark, background music and B-roll. Layouts are validated at the API boundary against `compose_ffmpeg._LAYOUTS` before any credit is spent.
**Publish.** `stage_upload` uploads the final MP4 to R2 and, when `params.platforms` is non-empty, cross-posts via `app/services/publish.py` → `app/services/upload_post.py` (Upload-Post), honouring the `tos_disclosure` AI/synthetic-media flag and `youtube_privacy_status`. Job status is read via `GET /api/v1/jobs/{id}` (presigned `result_url`), history via `GET /api/v1/jobs`, and a failed job can be re-enqueued from its failed stage via `POST /api/v1/jobs/{id}/retry`. Client uploads (the screen recording, logos, samples) are presigned via `POST /api/v1/uploads/presign`.
> Note: the legacy MoneyPrinterTurbo endpoints (`POST /api/v1/videos|subtitle|audio`, `/api/v1/tasks`, stream/download in `app/controllers/v1/video.py`, and the script/terms/social helpers in `app/controllers/v1/llm.py`) remain in the fork but are not part of the ReelForge avatar pipeline.
---
## Monetization
**Credits.** 1 credit = 1 rendered video. Balances are an append-only ledger (`CreditLedger`, `sum(delta)`), managed by `CreditRepository`. Job creation debits `N × cost` credits in the same committed transaction that creates the job rows (402 on insufficient balance); a failed enqueue is reconciled with a refund (`app/domains/reels/router.py::create_job` / `_reconcile_failed_enqueue`). New users receive a one-time signup grant (`SIGNUP_GRANT = 3`, `app/services/billing/plans.py`). Balance + job count are read via `GET /api/v1/me`.
**Plans.** Three locked plans defined in `app/services/billing/plans.py`: **Free** (3 credits, signup grant, not sold), **Starter** (30 credits, ~$49) and **Pro** (120 credits, ~$149). Credit counts are locked; USD prices and provider price/product ids are config-overridable. Public catalog: `GET /api/v1/billing/plans`.
**Payment providers (4).** Checkout is provider-agnostic (`POST /api/v1/billing/checkout` → `{checkout_url}`) across **Stripe**, **iyzico** (TR local cards), **Creem** and **Polar**, each with a dedicated client (`app/services/billing/{stripe_client,iyzico_client,creem_client,polar_client}.py`) orchestrated by `app/services/billing/service.py`. Only providers with configured secrets are offered (`GET /api/v1/billing/providers`). Credits are granted only on verified webhook confirmation — `POST /api/v1/billing/webhook/{stripe,creem,polar}` (signature-verified, idempotent via Redis-SETNX) and `POST /api/v1/billing/webhook/iyzico` (server-to-server token exchange). Controller: `app/controllers/v1/billing.py`.
---
## Creator Studio
**Caption presets.** Four ready-made karaoke styles live in `app/services/captions/presets.py`: `karaoke_yellow` (default), `karaoke_green`, `clean_white`, `bold_violet`, each an immutable `KaraokeStyle`. Selectable per job via `params.caption_style` and browsable via `GET /api/v1/catalog/caption-styles` (`app/controllers/v1/catalog.py`).
**Music library.** A local royalty-free track library (`resource/songs/`) is scanned and served by `app/services/music.py::list_music` (id, name, filename, probed duration). A track is attached to a job via `music_id`; `stage_compose` sidechain-ducks it under the narration. Catalog: `GET /api/v1/catalog/music`.
**AI music.** Instead of a library track, a job can pass `music_prompt` (+ optional `bgm_provider`) to generate a custom background track via ElevenLabs Music (`app/services/elevenlabs_music.py`) or Sonilo (`app/services/sonilo.py`), dispatched through `app/services/bgm_ai.py::generate_ai_bgm`. Only providers whose keys are configured (`is_enabled()`) are offered: `GET /api/v1/catalog/music-generators` returns each `{id, name, max_prompt_length}`.
**Re-run with tweaks.** `POST /api/v1/jobs/{id}/rerun` clones a source job's stored params, applies sparse overrides (`avatar_id`, `voice_id`, `layout`, `caption_style`, `music_id`, `language`), and enqueues a brand-new job (fresh credit debit) — an immutable copy-and-tweak, never a mutation of the source (`app/domains/reels/router.py::rerun_job`).
**Previews.** Every finished render produces best-effort studio derivatives — a poster JPEG (`poster_key`) and a short teaser MP4 (`preview_key`) — via `app/services/preview.py` (`generate_poster` / `generate_preview_clip`), spliced in by `reelforge._generate_derivatives` during compose. A derivative failure never fails the job; `poster_key` is surfaced on job/batch reads.
**Cover generator.** `POST /api/v1/jobs/{id}/cover` renders a 1080×1920 JPG thumbnail (Pillow, `app/services/cover.py`) using a chosen style (default `classic`) and a headline (caller-supplied, else the script hook or `video_subject`), over the job's poster frame or a style gradient. The cover is uploaded to R2, persisted on `Job.cover_key`, and returned as a presigned URL; regenerating overwrites it. Styles: `GET /api/v1/catalog/cover-styles`. Controller: `app/controllers/v1/covers.py`.
**Brand watermark.** A per-user `UserBrand` singleton (logo `logo_key` + corner `position` + `opacity` + `enabled`) is read/updated via `GET`/`PUT /api/v1/me/brand` (`app/controllers/v1/brand.py`) and overlaid by `stage_compose` on every reel; per-job overrides (`watermark_key`/`_position`/`_opacity`/`_enabled`) are supported. The `logo_key` must be an upload the caller owns (BOLA guard against the `Asset` registry, 403 otherwise); `logo_key=""` clears it.
**Webhooks.** A job may carry a `webhook_url` (+ optional HMAC-SHA256 `webhook_secret`); on completion `reelforge._fire_completion_webhook` posts a signed `{job_id, state, result_key, poster_key, preview_key}` payload via `app/services/webhooks.py::deliver_webhook`, which validates the URL (SSRF guard) and signs the body. Delivery is best-effort and audited as a `JobEvent`.
---
## Voice
**ElevenLabs voices.** A curated multilingual voice catalog is served from `resource/voices.yaml` (normalised to `{id, name, language, gender, description}`), falling back to a live listing from the configured ElevenLabs account (`app/services/voice.py::get_elevenlabs_voices`). A voice is selected per job as `voice_name = "elevenlabs:<voice_id>"`. Endpoint: `GET /api/v1/voices` (`app/domains/reels/router.py`).
**Brand Voice cloning.** A creator turns an uploaded audio sample into a private, reusable ElevenLabs Instant Voice Clone via `POST /api/v1/voices/clone` (mandatory `consent`, sample ownership enforced), backed by `app/services/tts/voice_clone.py` and persisted as a `UserVoice` row. The clone is then usable as any narrator (`elevenlabs:<provider_voice_id>`). List via `GET /api/v1/voices/mine`, delete via `DELETE /api/v1/voices/mine/{voice_id}` (also removes it from ElevenLabs). Controller: `app/controllers/v1/voices.py`.
**Bring Your Own Voiceover (BYOV).** A job may set `voiceover_key` (the R2 key of the creator's own uploaded narration). When present, `stage_tts` skips ElevenLabs entirely (`_stage_tts_byov`): it downloads the audio, transcribes it with faster-whisper (`app/services/transcribe.py`) for the single-authority word timings that drive captions, and re-hosts it so the avatar lip-syncs the same audio. No TTS credit/charge change. The key is ownership-checked via the standard BOLA guard.
---
## Content
**Spark idea engine.** `POST /api/v1/ideas/generate` turns an `app_context` (+ optional `audience`, `count` 1–10, `language`) into ready-to-shoot viral UGC concepts via `app/services/ideas.py::generate_ideas` (LLM-backed, per-user rate-limited). Concepts can be saved (`POST /api/v1/me/ideas`), listed (`GET /api/v1/me/ideas`) and deleted (`DELETE /api/v1/me/ideas/{id}`) as owner-scoped `SavedIdea` rows. Controller: `app/controllers/v1/ideas.py`.
**Templates.** Curated job templates pre-fill a sane UGC configuration (subject hint, prompt scaffold, layout, caption style, language, duration) so a new user goes from empty form to ready reel in one click. Served by `app/services/templates.py::list_templates` via `GET /api/v1/catalog/templates`; a native-hook browser is exposed via `GET /api/v1/catalog/hooks` (`templates.list_hooks` over `resource/hooks/<lang>.yaml`).
**Dubbing.** `POST /api/v1/jobs/{id}/dub` fans a finished reel out into N language-dubbed jobs (up to 12) sharing one `batch_id`. Each new job re-translates the source script into a target language (`app/services/translate.py`) and re-runs the pipeline reusing the source's recording/avatar/voice/layout/caption style. Supported languages: `GET /api/v1/catalog/dub-languages` (`translate.SUPPORTED_DUB_LANGUAGES`). Controller: `app/domains/reels/router.py::dub_job`.
**AI B-roll.** `POST /api/v1/jobs/{id}/broll/suggest` proposes short, relevant stock clips (default source `pexels`) using the job's own subject/script (never client input), via `app/services/broll.py::suggest_broll`; each suggestion is staged under the job's own R2 prefix. A chosen clip is attached as a muted intro/outro (`broll_intro_key`/`broll_outro_key`) and spliced best-effort by `stage_compose` (`_apply_broll`) — it never fails the job. Separately rate-limited (hits a stock provider + the LLM).
**Social caption / hashtags.** `POST /api/v1/jobs/{id}/social` generates platform-tailored post copy `{title, caption, hashtags[]}` for `tiktok` / `instagram` / `youtube_shorts` via `app/services/llm.py::generate_social_metadata`, using the job's own subject/script/language (per-user rate-limited). Platform list: `GET /api/v1/catalog/social-platforms`. Controller: `app/controllers/v1/social.py`.
**Custom photo avatar.** `POST /api/v1/avatars` turns a caller's uploaded selfie (`image_key`, ownership-checked) into a HeyGen *talking-photo* avatar (`provider.create_talking_photo`) and persists it as an owner-scoped `AvatarPreset` (`config.kind = talking_photo`, `is_active=true`) so it appears in `GET /api/v1/avatars` for use in jobs. Controller: `app/controllers/v1/studio.py::create_avatar`; the avatar list (presets + live provider avatars) is `app/domains/reels/router.py::list_avatars`.
---
## Growth
**Referrals.** `GET /api/v1/me/referral` returns the caller's referral code (generated + persisted on first sight) and lifetime stats; `POST /api/v1/me/referral/redeem` redeems another user's code, granting both parties through the append-only credit ledger (self-referral → 400, double-redeem → 409). Service: `app/services/referrals.py`; controller: `app/controllers/v1/me.py`.
**Insights.** `GET /api/v1/me/insights` returns the caller's dashboard analytics — jobs total/by-state, videos generated, credit balance/spent, total cost USD, average render time — aggregated strictly per-user by `app/services/insights.py::user_insights`.
**Creator Analytics.** `GET /api/v1/me/analytics?days=` returns the caller's richer BI dashboard — funnel by job state, cost-over-time, credit burn-rate + live balance, render-time percentiles and usage breakdowns — merged with their most-used templates/hooks (`top_content`), computed strictly per-user (`days` clamped to `1..365`) over the `Job`/`JobEvent`/`CreditLedger` data ReelForge already records. Service: `app/services/analytics.py`; controller: `app/controllers/v1/analytics.py`.
**Saved presets / brand kits.** CRUD over named `{name, config}` presets via `GET`/`POST`/`DELETE /api/v1/me/presets` (`app/controllers/v1/me.py`). A preset may be shared to a workspace (`workspace_id`) so every member sees it; the list returns own presets UNION presets shared to the caller's workspaces, each flagged `shared`. Deletion is creator-only for personal kits, creator-or-workspace-admin for shared kits.
**Notifications.** In-app notifications for lifecycle/growth events (`job_complete`, `job_failed`, `low_credits`, `referral_earned` — `app/services/notifications.py`) are read via `GET /api/v1/me/notifications` (list + live `unread_count`) and `GET /api/v1/me/notifications/unread_count` (cheap bell-badge poll), and cleared via `POST /api/v1/me/notifications/{id}/read` and `POST /api/v1/me/notifications/read_all`. Strictly owner-scoped. Controller: `app/controllers/v1/notifications.py`.
---
## Teams
**Workspaces & roles.** A user creates a workspace (becoming its `owner`) and invites existing teammates by email with role `owner | admin | member`. Routes (`app/controllers/v1/workspaces.py`, service `app/services/workspaces.py`): `POST /api/v1/workspaces`, `GET /api/v1/me/workspaces`, `GET /api/v1/workspaces/{id}/members`, `POST /api/v1/workspaces/{id}/invite` (admin+), `POST /api/v1/workspaces/{id}/members/{user_id}/role` (admin+), `DELETE /api/v1/workspaces/{id}/members/{user_id}` (admin+ or self), `POST /api/v1/workspaces/{id}/leave`. All authorization lives in the service; the owner is protected from removal.
**Shared credit pool.** A workspace has its own shared credit pool. Balance is read via `GET /api/v1/workspaces/{id}/credits` (any member) and topped up via `POST /api/v1/workspaces/{id}/credits/grant` (admin+); purchases can fund the pool by passing `workspace_id` to `POST /api/v1/billing/checkout` (admin-gated). Jobs created/retried/re-run with `workspace_id` debit — and refund to — the SHARED pool via `CreditRepository.workspace_debit` / `workspace_grant`, with membership as the authorization gate (`app/domains/reels/router.py::_resolve_workspace_pool`).
**Shared brand kits.** Saved presets (above) double as shareable brand kits: passing `workspace_id` on `POST /api/v1/me/presets` shares the kit to a team, and `GET /api/v1/me/presets` merges personal + team-shared kits (de-duplicated), reusing the workspace membership/role primitives.
---
## Batch
**Variants.** A single `POST /api/v1/jobs` with `variants: 1..3` fans out N distinct jobs for A/B testing (temperature-varied scripts), all created + debited atomically and sharing one `batch_id`. With `variants > 1` the response carries `job_ids` + `batch_id` (`app/domains/reels/router.py::create_job`, `_MAX_VARIANTS = 3`). Dubbing produces batches the same way.
**Batch review.** `GET /api/v1/batches/{batch_id}` returns every variant of a batch (owner-scoped) in a compact review shape — `{job_id, state, progress}` plus a presigned `result_url` and `poster_key` once each render finishes — so a creator can review variants together (`app/domains/reels/router.py::get_batch`).
---
## Scheduling
**Scheduled publishing.** A creator queues a *finished* reel to auto-publish to `tiktok` / `instagram` / `youtube_shorts` (`app/services/scheduler.py::ALLOWED_PLATFORMS`) at a future UTC time via `POST /api/v1/jobs/{id}/schedule` (404 unknown/foreign job, 409 job not complete, 400 on bad platforms or a past/unparseable `scheduled_at`). Schedules are listed via `GET /api/v1/me/scheduled` (optional `?status=`) and cancelled while still `pending` via `DELETE /api/v1/me/scheduled/{id}` (409 once no longer pending). A background Celery-beat due-runner publishes claimed `ScheduledPublish` rows through `app/services/publish.py`. Controller: `app/controllers/v1/schedule.py`.
---
## Marketplace
**Template Marketplace.** A creator publishes an IMMUTABLE snapshot of a private brand-kit template (owner-scoped by `template_id`) to a shared, public marketplace; any authenticated user can browse/search it, view detail, clone it into their own private templates (bumps `clone_count`), or rate it 1–5 (exactly one upserted rating per user, recomputing `rating_avg`/`rating_count`). Author-only soft-unpublish retains the listing's clones/ratings. Endpoints: `GET /api/v1/marketplace` (filters `query`/`tag`/`language`, `sort`, clamped `limit`/`offset`), `GET /api/v1/marketplace/{id}`, `POST /api/v1/marketplace/publish`, `POST /api/v1/marketplace/{id}/clone`, `POST /api/v1/marketplace/{id}/rate`, `DELETE /api/v1/marketplace/{id}`. Service: `app/services/marketplace.py`; controller: `app/controllers/v1/marketplace.py`.
**Win-score ranking.** The `sort=proven` browse re-ranks the (already-clamped) page by a real-world "win score" derived from the performance of the reels made from each listing's clones (`marketplace.listing_win_scores`), annotating each qualifying listing with a `win_score`. A k-anonymity floor (`WIN_SCORE_PUBLIC_MIN_COHORT`) suppresses the numeric score for listings with too few distinct cloners so a single creator's private metrics can never leak; all other sorts keep their exact shape. Anchor: `app/services/marketplace.py`.
**Remix trees.** Every listing tracks `parent_template_id` (the listing it was remixed from — `None` for an original) and `remix_count`; `GET /api/v1/marketplace/{id}/lineage` walks the ancestor chain up to the root (capped at `LINEAGE_MAX_DEPTH`) and lists the direct, still-published children, while `sort=most_remixed` surfaces the most-forked listings. Anchor: `app/services/marketplace.py::lineage`.
---
## Performance loop
**Hook Performance Loop.** After posting a reel, a creator logs the real-world metrics it earned — `views` / `likes` / `comments` / `shares` / `saves` + `retention_pct` — for their OWN job via `POST /api/v1/jobs/{job_id}/performance` (idempotent upsert; ownership verified before any write → `404`/`403`, out-of-range values → `400`), readable via `GET /api/v1/jobs/{job_id}/performance` and `GET /api/v1/me/performance`. Persists one `JobPerformance` row per job. Service: `app/services/hook_performance.py`; controller: `app/controllers/v1/performance.py`.
**Winning hooks/templates → Spark.** Those outcomes are aggregated per hook and per template into a deterministic win score (`GET /api/v1/me/winning-hooks`, `GET /api/v1/me/winning-templates`) — the signal the Spark idea engine biases toward so it re-suggests the patterns that genuinely convert. Anchor: `app/services/hook_performance.py`.
---
## Programmatic API
**Personal API keys.** A power user mints cryptographically-random personal keys (`POST /api/v1/me/api-keys`, raw secret revealed exactly once — only its SHA-256 digest + a short non-secret `prefix` are stored), lists them (`GET /api/v1/me/api-keys`) and soft-revokes them (`DELETE /api/v1/me/api-keys/{id}`), all strictly owner-scoped with a per-user active-key cap (`reelforge_max_api_keys`). A minted key authenticates as the `x-api-key` header and resolves back to its owning `User` (`app/controllers/v1/base.py::resolve_user_by_api_key`). Controller: `app/controllers/v1/api_keys.py`.
**Per-key quotas + rate limits.** Each resolved personal key is gated by two independent controls before its request proceeds — a per-minute fixed-window rate limit and an atomic monthly request quota — both mapped to a single HTTP `429` on breach (`app/services/apikey_quota.py`, enforced in `app/controllers/v1/base.py`). A NULL `rate_limit_per_min` inherits the plan/config default; a NULL `monthly_quota` means unlimited. Current-month usage + remaining allowance per key: `GET /api/v1/me/api-keys/usage`. Anchor: `app/services/apikey_quota.py`.
---
## Publishing & distribution
**OAuth direct-publish connect.** A creator connects a social platform (TikTok / Instagram / YouTube) via the OAuth authorization-code flow — `GET /api/v1/connections/{provider}/authorize` mints a single-use CSRF `state` and returns the authorize URL; `GET /api/v1/connections/{provider}/callback` consumes the state (replay → `400` before any code exchange), swaps the `code` for tokens, and stores them Fernet-encrypted at rest (`SOCIAL_TOKEN_KEY`, via `app/services/crypto_tokens.py`). Connections are listed TOKEN-FREE via `GET /api/v1/me/connections` (a token is never serialised) and dropped via `DELETE /api/v1/me/connections/{provider}`. `POST /api/v1/jobs/{job_id}/publish/{provider}` posts one of the caller's OWN completed jobs straight to a connected account (403 foreign job, 409 not-connected/not-complete), decrypting the token in-memory for the outbound call only. Service: `app/services/oauth_connect.py`; controller: `app/controllers/v1/connections.py`. The live upload client is intentionally unwired by default (`_upload_client → None` ⇒ clean 503) so the prod-critical publish path never makes an unexpected outbound call; production injects a real `VideoUploadClient` and tests inject a mock.
**Public share pages.** A creator turns one of their OWN completed reels into a public, unguessable, revocable share link (`POST /api/v1/jobs/{job_id}/share`, idempotent — one live link per job) and revokes it (`DELETE /api/v1/me/shares/{token}`, owner-scoped no-op on a foreign/unknown token). `GET /api/v1/public/r/{token}` is the only UNAUTHENTICATED route: it resolves a live token to a strict safe DTO (title + WATERMARKED preview URL + `created_at` + sharer referral code) and counts the view — never the clean `result_key`, the owning `user_id` or any financial. Base URL is `reelforge_share_base_url`; write/view rate limits are config-tunable (`reelforge_share_{write,view}_rate_{limit,window_s}`). Service: `app/services/share.py`; controller: `app/controllers/v1/share.py`.
---
## Community
**Creator profiles.** Each user has a public identity (`handle` / `display_name` / `bio`) editable via `PATCH /api/v1/me/profile` (a taken handle → `409`) and readable UNAUTHENTICATED via `GET /api/v1/creators/{handle_or_id}` (by user id or handle). The profile is a STRICT safe DTO exposing only public reputation aggregates (published templates, clones received, weighted average marketplace rating, follower/following counts) — never credits, email, cost or revenue. Service: `app/services/creators.py`; controller: `app/controllers/v1/creators.py`.
**Follow graph.** A directed, idempotent follow edge (`CreatorFollow`): `POST` / `DELETE /api/v1/creators/{id}/follow` (self-follow → `400`, unknown followee → `404`, double-follow/unfollow a harmless no-op) and `GET /api/v1/me/following` (the safe public profiles the caller follows, bounded to `_MAX_FOLLOWING`). Anchor: `app/services/creators.py`.
**Leaderboards.** `GET /api/v1/creators/leaderboard` (PUBLIC) ranks creators by a documented, deterministic metric — `reputation` (default composite), `followers`, `clones`, `rating`, `published` or `win_score` — with `limit` clamped to `[1, 100]`; the gaming-resistant anchor of the composite reputation score is the downstream `win_score` sourced from the marketplace performance loop. Anchor: `app/services/creators.py::leaderboard`.