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.
18 KiB
ReelForge — Deployment Guide (fresh machine, ≤30 min)
This guide takes a clean machine to a running ReelForge stack — API, Celery worker, Celery beat, and Redis — plus an applied Neon schema and a first rendered job. It also covers deploying the Next.js web app to Cloudflare Pages and the Expo mobile client via EAS, and wiring Sentry.
ReelForge is a parallel UGC-avatar pipeline layered on MoneyPrinterTurbo (MPT).
The canonical pipeline is script → tts → {avatar ∥ captions} → compose → upload.
| Component | Path / entry point | Runtime |
|---|---|---|
| API | app.asgi:app (uvicorn) → /api/v1 |
Docker api service, :8080 |
| Worker | celery -A app.workers.celery_app worker -Q celery,render |
Docker worker service |
| Beat | celery -A app.workers.celery_app beat |
Docker beat service |
| Broker/backend | Redis 7 | Docker redis service, :6379 |
| Database | Neon / Postgres (Alembic) | external (Neon) |
| Object storage | Cloudflare R2 (S3-compatible) | external (R2) |
| Web | web/ (Next.js 15) |
Cloudflare Workers (OpenNext) |
| Mobile | mobile/ (Expo SDK 51) |
EAS build / submit |
The full, authoritative key list lives in
CONFIG.md; this guide maps each account to the env var/config key you must set and cross-references that document.
0. Prerequisites (~3 min)
You only need Docker for the backend — the image (Dockerfile) bakes in
FFmpeg and the compose file bundles Redis.
| Tool | Why | Check |
|---|---|---|
| Docker + Compose v2 | Runs api/worker/beat/redis | docker compose version |
| Node ≥ 18.18 | Builds web/ (Cloudflare Workers / OpenNext) and mobile/ (Expo/EAS) |
node -v |
uv (optional) |
Local non-Docker runs; make targets prefer it |
uv --version |
| libass FFmpeg (local runs only) | Burned karaoke captions require an --enable-libass build |
ffmpeg -buildconf | grep libass |
Captions & FFmpeg.
stage_composeburns karaoke captions with theass/subtitlesfilter, which needs an FFmpeg built with libass. The Docker image installs Debian'sffmpeg(libass-enabled), so the Docker path needs nothing extra. Only a local, non-Docker worker requires you to install a libass FFmpeg yourself. Verify inside the container with:docker compose -f docker-compose.reelforge.yml exec api ffmpeg -buildconf.
1. Create the external accounts (~10 min)
Five accounts are required to render an end-to-end job. Everything else (RunPod avatar tier, Stripe/Iyzico/Creem/Polar billing, Sentry) is optional.
| Service | Create | Env var(s) → CONFIG.md section |
|---|---|---|
| Anthropic (console.anthropic.com) | API key — Claude script generation via litellm | ANTHROPIC_API_KEY → [anthropic] |
| ElevenLabs (elevenlabs.io) | API key — TTS /with-timestamps (the pipeline's single timing authority) |
ELEVENLABS_API_KEY → [elevenlabs] |
| HeyGen (app.heygen.com/settings?nav=API) | API key (v2, X-Api-Key) — audio-driven talking-head avatar |
HEYGEN_API_KEY → [heygen] |
| Cloudflare R2 (dash.cloudflare.com → R2) | Bucket + S3 API token (Access Key ID/Secret); note Account ID; enable a public/custom-domain base URL | R2_ACCOUNT_ID, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY, R2_BUCKET, R2_PUBLIC_BASE_URL → [r2] |
| Neon (neon.tech) | Serverless Postgres project → connection string | NEON_DATABASE_URL → [neon] |
Optional:
| Service | Purpose | Env var(s) |
|---|---|---|
| RunPod (runpod.io) | LatentSync avatar tier (alt. to HeyGen) | RUNPOD_ENDPOINT_ID, RUNPOD_API_KEY → [runpod] |
| Stripe / Iyzico / Creem / Polar | Credit purchases | STRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRET, STRIPE_PRICE_STARTER, STRIPE_PRICE_PRO, … → [stripe]/[iyzico]/[creem]/[polar] |
| Sentry (sentry.io) | Error/perf monitoring (§5) | SENTRY_DSN, SENTRY_ENVIRONMENT → [sentry] |
| Clerk (clerk.com) | Web auth (email + Google) | web NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY, CLERK_SECRET_KEY |
Neon connection string (psycopg v3 driver for SQLAlchemy 2.0):
postgresql+psycopg://USER:PASSWORD@HOST/DBNAME?sslmode=require
No stock footage. ReelForge composites over your uploaded screen recording only; the MPT Pexels/Pixabay/Coverr path is bypassed, so no
PEXELS_API_KEYS/PIXABAY_API_KEYSare needed.
2. Configure the repo (~5 min)
Two files. Non-secret app config lives in config.toml; secrets go in
.env.reelforge, which app/config/config.py reads as overrides (env wins
over config.toml). docker-compose.reelforge.yml loads the env file into the
api and worker services via env_file:.
# 1. App config (non-secret)
cp config.example.toml config.toml
# 2. Secrets (NEVER commit this file)
cp .env.reelforge.example .env.reelforge
$EDITOR .env.reelforge
Minimum config.toml settings for ReelForge (see CONFIG.md for the full list):
[app]
llm_provider = "litellm"
litellm_model_name = "anthropic/claude-sonnet-5"
enable_redis = true # Celery reuses the [app] redis_* keys
[elevenlabs]
word_timestamps = true # route TTS through /with-timestamps
[r2]
public_base_url = "https://<your-public-r2-domain>"
.env.reelforge — fill the five required credentials (secrets stay out of
config.toml):
ANTHROPIC_API_KEY=sk-ant-...
ELEVENLABS_API_KEY=...
HEYGEN_API_KEY=...
R2_ACCOUNT_ID=...
R2_ACCESS_KEY_ID=...
R2_SECRET_ACCESS_KEY=...
R2_BUCKET=reelforge
R2_PUBLIC_BASE_URL=https://cdn.example.com
NEON_DATABASE_URL=postgresql+psycopg://USER:PASS@HOST/db?sslmode=require
# Redis host is pinned to the `redis` service by the compose file:
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_DB=0
CORS_ALLOWED_ORIGINS=https://app.example.com # exact comma-separated HTTPS origins
# Optional legacy artifact route; keep disabled unless an operator explicitly needs it:
REELFORGE_EXPOSE_LEGACY_TASKS=false
The worker entrypoint (
docker/worker-entrypoint.sh) fails fast ifNEON_DATABASE_URLor anyR2_*var is missing, and waits for Redis before starting — so a misconfigured secret surfaces immediately inlogs workerrather than mid-render.
3. Start the backend stack (~5 min)
# Builds the image (FFmpeg baked in) and starts redis + api + worker + beat.
make -f Makefile.reelforge up
# equivalently:
# docker compose -f docker-compose.reelforge.yml up -d --build
Services (all bound to 127.0.0.1 only):
| Service | Container | Address | Role |
|---|---|---|---|
redis |
reelforge-redis |
127.0.0.1:6379 |
Celery broker + result backend + MPT task state |
api |
reelforge-api |
127.0.0.1:8080 |
FastAPI (uvicorn app.asgi:app), routes under /api/v1 |
worker |
reelforge-worker |
— | Celery worker, celery + render queues, --concurrency=2 |
beat |
reelforge-beat |
— | Celery beat scheduler (scheduled publishing) |
The heavy stages (
stage_avatar_task,stage_compose_task) are routed to therenderqueue incelery_app.py; the single worker services bothcelery(light) andrender(heavy).
Apply the Neon schema
Run migrations once as an explicit step (the worker deliberately does not
run them, to avoid concurrent alembic upgrade head races):
make -f Makefile.reelforge migrate # alembic upgrade head
migrations/env.py resolves the DB URL from config.neon.database_url, falling
back to $NEON_DATABASE_URL — no secret lives in alembic.ini. This applies the
full ReelForge schema (jobs, job_events, workspaces/members, credits, scheduled
publishes, notifications, user voices, saved ideas, …).
Sanity checks
docker compose -f docker-compose.reelforge.yml ps # all healthy/up
docker compose -f docker-compose.reelforge.yml logs -f worker
curl -s http://127.0.0.1:8080/docs > /dev/null && echo "API up"
curl -fsS http://127.0.0.1:8080/healthz # process liveness
curl -fsS http://127.0.0.1:8080/readyz # DB + Redis + R2
/healthz is dependency-free and suitable for a process liveness probe.
/readyz returns 503 until Neon, Redis, and the configured R2 bucket are all
reachable; use it to keep a new replica out of load balancing during rollout.
For the live 10-video golden run, write one JSON/JSONL row per completed job
with a numeric duration_s, then calculate the latency distribution with
make -f Makefile.reelforge bench RESULTS=/path/to/golden-results.json.
4. Scheduled publishing (Celery beat)
The beat service runs the periodic scheduler. Its single job, defined in
celery_app.py (beat_schedule → reelforge-process-due-publishes), fires
process_due_publishes_task every 60 s. That task claims every pending
row in the scheduled-publish table whose UTC time has arrived and publishes it
via app.services.scheduler.process_due_publishes; the actual work runs on the
worker.
Run exactly one beat process. Scaling
beat> 1 would enqueue each schedule once per replica. The due-runner is idempotent (claimed rows are not re-claimed), so a duplicate tick is safe, but duplicate schedulers are not. Keepbeatat a single container.
Schedules are created/listed/cancelled through the API (app/controllers/v1/schedule.py):
POST /api/v1/schedule, GET /api/v1/schedule, DELETE /api/v1/schedule/{id}.
5. Sentry (optional)
Sentry is wired but NO-OP by default. init_sentry("api") runs at API
startup (app/asgi.py) and init_sentry("worker") at worker bootstrap
(app/workers/celery_app.py); both no-op and log "sentry disabled" when the DSN
is empty, so no key is required to ship.
Enable it by setting [sentry] in config.toml or the env vars (which take
precedence):
[sentry]
dsn = "https://<key>@<org>.ingest.sentry.io/<project>"
environment = "production"
traces_sample_rate = 0.0 # 0.0 = errors only; up to 1.0 for tracing
# env override (highest precedence)
SENTRY_DSN=https://<key>@<org>.ingest.sentry.io/<project>
SENTRY_ENVIRONMENT=production
The FastAPI and Celery integrations are attached automatically when present, and
every event is tagged with component=api/component=worker. Init is guarded
against double-registration and never raises — monitoring can't break startup.
6. Deploy the web app to Cloudflare Workers (OpenNext)
web/ is a Next.js 15 (App Router) + React 19 app that talks to /api/v1 and
uses Clerk for auth. It deploys to Cloudflare Workers via
@opennextjs/cloudflare (the successor to
the now-deprecated @cloudflare/next-on-pages).
cd web
npm install
cp .env.example .env.local # fill in the values below
npm run dev # http://localhost:3000 (local check)
Environment variables (set the same ones in the Pages project settings):
| Var | Purpose |
|---|---|
NEXT_PUBLIC_API_BASE |
Backend v1 base URL, incl. /api/v1 (e.g. https://api.example.com/api/v1) |
NEXT_PUBLIC_APP_API_KEY |
Public x-api-key fallback when no Clerk JWT is sent (browser-visible; scope it) |
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY |
Clerk publishable key (browser-safe) |
CLERK_SECRET_KEY |
Clerk secret key (server-only) |
Build + deploy the Worker via @opennextjs/cloudflare:
npm run cf:build # opennextjs-cloudflare build -> .open-next/worker.js (+ .open-next/assets)
npm run cf:preview # optional: run the built Worker locally in workerd
npm run cf:deploy # opennextjs-cloudflare deploy (needs Cloudflare account credentials)
- Worker entry / assets:
.open-next/worker.jsand.open-next/assets(theASSETSbinding) — both declared inweb/wrangler.jsonc. - Public env vars live in
wrangler.jsoncvars. Secrets must NOT be committed — setCLERK_SECRET_KEYas a Worker secret:npx wrangler secret put CLERK_SECRET_KEY. - Unlike
next-on-pages, OpenNext runs the Next.js Node server on Workers, so route handlers do not needexport const runtime = "edge". - Pinned to
@opennextjs/cloudflare@1.20.2(highest release whosenextpeer>=15.5.21 <16matches the installed Next15.5.23; bump Next to>=15.5.24before moving to>=1.20.3). - On the API, add your Worker origin to
CORS_ALLOWED_ORIGINS(comma-separated).
7. Deploy mobile via EAS
mobile/ is an Expo SDK 51 (expo-router) thin client hitting the same /api/v1
endpoints; users authenticate with their own ReelForge API key
(expo-secure-store). Config lives in mobile/app.json
(slug reelforge-mobile, bundle IDs com.reelforge.mobile).
cd mobile
npm install
cp .env.example .env # set EXPO_PUBLIC_API_BASE
| Var | Purpose |
|---|---|
EXPO_PUBLIC_API_BASE |
Backend base URL incl. /api/v1 (use your LAN IP on a physical device, not localhost) |
EXPO_PUBLIC_APP_API_KEY |
Optional non-secret x-api-key fallback (inlined into the bundle) |
Build & submit with EAS. The repo ships app.json but no eas.json, so
generate one first, then build/submit:
npm install -g eas-cli
eas login
eas build:configure # creates eas.json (dev/preview/production profiles)
eas build --platform all # cloud build (iOS + Android)
eas submit --platform ios # → App Store Connect
eas submit --platform android # → Google Play
For OTA JS updates use eas update (requires expo-updates; add it if you want
over-the-air releases).
EXPO_PUBLIC_*values are inlined at build time — never put real secrets in them. The authenticated credential is the per-user API key entered on the sign-in screen.
Quickstart (copy-paste)
Backend, from the repo root — assumes Docker is running and accounts exist:
# 1. Config + secrets
cp config.example.toml config.toml
cp .env.reelforge.example .env.reelforge
$EDITOR .env.reelforge # ANTHROPIC_/ELEVENLABS_/HEYGEN_/R2_*/NEON_DATABASE_URL
# 2. Bring up redis + api + worker + beat
make -f Makefile.reelforge up
# 3. Apply the Neon schema (one-shot)
make -f Makefile.reelforge migrate
# 4. Verify
docker compose -f docker-compose.reelforge.yml ps
curl -s http://127.0.0.1:8080/docs > /dev/null && echo "API up"
First job (curl)
The API lives under /api/v1, uses the MPT response envelope
({status, data?, message?}), and authenticates with an x-api-key header.
API=http://127.0.0.1:8080/api/v1
KEY=<your-api-key>
# Browse available avatars + voices
curl -s -H "x-api-key: $KEY" "$API/avatars" | jq .
curl -s -H "x-api-key: $KEY" "$API/voices" | jq .
# Create a job (voice_name uses elevenlabs:<voice_id>; empty platforms = skip upload)
curl -s -X POST "$API/jobs" \
-H "x-api-key: $KEY" \
-H "Content-Type: application/json" \
-d '{
"params": {
"video_subject": "why our note-taking app saves you an hour a day",
"voice_name": "elevenlabs:21m00Tcm4TlvDq8ikWAM",
"avatar_id": "<heygen_avatar_id>",
"avatar_provider": "heygen",
"layout": "pip",
"aspect": "9:16",
"language": "auto",
"target_duration_s": 30,
"platforms": []
}
}' | jq .
# Poll until terminal (data: {job_id, state, progress, stages, result_url?})
JOB=<job_id_from_above>
curl -s -H "x-api-key: $KEY" "$API/jobs/$JOB" | jq .
# Re-enqueue from the failed stage, if any
curl -s -X POST -H "x-api-key: $KEY" "$API/jobs/$JOB/retry" | jq .
When state reaches complete, result_url is a presigned R2 GET URL for the
final 1080×1920 MP4.
Upload the screen recording first. ReelForge composites over your recording. Presign an upload (
POST /api/v1/presign),PUTthe file to the returned URL, and pass the returned object key asparams.screen_recording_key. Theweb/andmobile/clients wrap this aspresignAndUpload().
Troubleshooting
| Symptom | Fix |
|---|---|
| Worker exits immediately | Missing core-infra secret. docker compose -f docker-compose.reelforge.yml logs worker — the entrypoint prints which of NEON_DATABASE_URL / R2_* is unset. |
connection refused to Redis |
Ensure the redis service is healthy; inside Docker REDIS_HOST must be redis (set for you in the compose file). |
| Captions not burned | Image FFmpeg must be libass-enabled. Verify: docker compose -f docker-compose.reelforge.yml exec api ffmpeg -buildconf. |
Job stuck in script/tts |
Check ANTHROPIC_API_KEY / ELEVENLABS_API_KEY and [app] llm_provider = "litellm". |
| Scheduled reels never publish | Confirm the single beat container is up (ps) and the worker is consuming; look for process_due_publishes_task in logs worker. |
402 on POST /jobs |
User has insufficient credits (billing). |
| Web build/deploy fails | Run npm run cf:build (OpenNext → .open-next/worker.js); ensure all NEXT_PUBLIC_* vars are in wrangler.jsonc vars and CLERK_SECRET_KEY is set via wrangler secret put. |
| Migration errors | Confirm NEON_DATABASE_URL uses the postgresql+psycopg://…?sslmode=require form. |
Reference
docker-compose.reelforge.yml— service definitions (redis/api/worker/beat)Dockerfile— base image + FFmpegMakefile.reelforge—up,down,logs,migrate,api,worker,test,golden.env.reelforge.example— secret env templateapp/workers/celery_app.py— queues, routing, beat schedule, Sentry initdocker/worker-entrypoint.sh— fail-fast secret validation + Redis waitmigrations/— Alembic schema (env.pyresolves the Neon URL)CONFIG.md— full config/env key referenceINTEGRATION_CONTRACT.md— module/API contractREADME.md— fresh-machine quickstart