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
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.
192 lines
7.8 KiB
Markdown
192 lines
7.8 KiB
Markdown
# ReelForge API — Deploy Runbook (unblock Menivor mobile)
|
|
|
|
The Menivor mobile app cannot ship because its Release build has no public API
|
|
URL and falls back to `http://localhost:8080/api/v1`. This runbook stands up the
|
|
ReelForge API tier at a real URL (`https://api.menivor.com`) so the store build
|
|
can reach `/api/v1`, and shows the one mobile-side change required.
|
|
|
|
`apps/api/docker-compose.yml` is self-contained: it runs the FastAPI tier plus
|
|
Postgres, Redis, and MinIO, all configured from `apps/api/.env`. No secrets are
|
|
committed — start from `.env.example`.
|
|
|
|
---
|
|
|
|
## 1. Local run (verify before deploying)
|
|
|
|
```sh
|
|
cd apps/api
|
|
cp .env.example .env
|
|
# minimum edit: set a real 32+ char device secret
|
|
# REELFORGE_DEVICE_AUTH_SECRET=$(openssl rand -hex 32)
|
|
docker compose up --build # or: docker-compose up --build
|
|
```
|
|
|
|
The one-shot `migrate` service runs `alembic upgrade head` automatically before
|
|
the API/worker start, so the first request never hits an unmigrated schema. (No
|
|
manual migration step is needed.)
|
|
|
|
Verify the API is live (liveness probe, always 200 once the process serves):
|
|
|
|
```sh
|
|
curl -i http://127.0.0.1:8080/healthz # -> 200 {"status":"ok"}
|
|
curl -i http://127.0.0.1:8080/docs # -> 200 (OpenAPI UI)
|
|
```
|
|
|
|
Full readiness (`/readyz`) additionally checks DB, Redis, R2, and a Celery
|
|
generation-queue consumer. With real R2 configured the `r2` check is green; the
|
|
`worker` check still reports `down` on this single-box stack because it looks
|
|
for a consumer on the GPU `generation` queue (the bundled worker serves
|
|
`celery,render` only) — this is expected and does **not** stop the mobile app:
|
|
device sessions, uploads, captions_only jobs, previews and billing metadata all
|
|
work end-to-end.
|
|
|
|
---
|
|
|
|
## 2. Deploy on the Oracle box (Ubuntu + Docker, behind Caddy)
|
|
|
|
Prereqs: Docker + Docker Compose plugin, a DNS `A` record for
|
|
`api.menivor.com` -> the box IP, and Caddy already running as the reverse proxy.
|
|
|
|
```sh
|
|
# on the box
|
|
git clone <this repo> videogen && cd videogen/apps/api
|
|
cp .env.example .env
|
|
$EDITOR .env # set REELFORGE_DEVICE_AUTH_SECRET + any
|
|
# provider/billing keys you want enabled
|
|
docker compose up -d --build
|
|
docker compose ps # api should be (healthy)
|
|
```
|
|
|
|
Front it with Caddy (`/etc/caddy/Caddyfile`) — Caddy terminates TLS and gives
|
|
you HTTPS automatically:
|
|
|
|
```
|
|
api.menivor.com {
|
|
reverse_proxy 127.0.0.1:8080
|
|
}
|
|
```
|
|
|
|
```sh
|
|
sudo systemctl reload caddy
|
|
curl -i https://api.menivor.com/healthz # -> 200 from the public URL
|
|
curl -i https://api.menivor.com/api/v1/catalog/caption-styles
|
|
```
|
|
|
|
Notes for production hardening (owner-supplied values in `.env`):
|
|
- **Public storage = Cloudflare R2 (LIVE since 2026-09-15).** `R2_*` in `.env`
|
|
points at the real `videogen` bucket
|
|
(`R2_S3_ENDPOINT=https://<account>.r2.cloudflarestorage.com`,
|
|
`R2_PUBLIC_BASE_URL=https://pub-16e801d8a85d4dc1bfee5bc5240040b4.r2.dev` — the
|
|
bucket's r2.dev managed domain, enabled). Presigned PUT/GET URLs are public
|
|
HTTPS R2 URLs, so device uploads and preview playback work from any client
|
|
through `https://api.menivor.com`; result/preview URLs are 7-day presigned
|
|
GETs (no public-bucket dependency). A `PUT/GET/HEAD *` CORS rule is applied on
|
|
the bucket. The compose MinIO stays defined for offline dev only and is out of
|
|
the hot path; its root credentials are decoupled from `R2_*`
|
|
(`MINIO_ROOT_USER`/`MINIO_ROOT_PASSWORD`, default `reelforge`/
|
|
`reelforge-local-secret`) so real R2 secrets never enter that container.
|
|
Jobs rendered before the switch have their media stranded in the local MinIO
|
|
volume (`reelforge-minio-data`); their old preview URLs 404 against R2, which
|
|
is acceptable — new jobs are unaffected.
|
|
NOTE: the S3 credential currently in `.env` is the account-scoped R2 API
|
|
token shared with CalDesk (`calori-ai/.env`). It verifies and has full R/W on
|
|
`videogen`; for isolation, mint a dedicated bucket-scoped token in the CF
|
|
dashboard (R2 → Manage API Tokens → Object Read & Write on `videogen`) and
|
|
swap it in.
|
|
- The worker persists Whisper/Hugging Face model downloads in the
|
|
`reelforge-model-cache` volume (`/root/.cache`), so caption models survive
|
|
container recreates.
|
|
- Add `ANTHROPIC_API_KEY`, `ELEVENLABS_API_KEY`, `HEYGEN_API_KEY` to enable
|
|
script/TTS/avatar generation.
|
|
- Only flip `REELFORGE_LAUNCH_MODE=public` + `REELFORGE_PUBLIC_LAUNCH_APPROVED=true`
|
|
after every required production key is set (startup preflight enforces this).
|
|
- For GPU B-roll/render generation, also run the CUDA generation worker from the
|
|
repo-root `docker-compose.reelforge.yml` (`api-generation-worker` service).
|
|
|
|
---
|
|
|
|
## 3. The ONE mobile change: point Expo at the public API
|
|
|
|
Edit `apps/mobile/eas.json` and add `EXPO_PUBLIC_API_BASE` to the production
|
|
build `env` block (the app defaults to `http://localhost:8080/api/v1` when it is
|
|
unset — see `apps/mobile/src/shared/api/client.ts`):
|
|
|
|
```json
|
|
"production": {
|
|
"distribution": "store",
|
|
"environment": "production",
|
|
"autoIncrement": true,
|
|
"ios": {
|
|
"resourceClass": "m-medium",
|
|
"image": "latest"
|
|
},
|
|
"android": {
|
|
"buildType": "app-bundle"
|
|
},
|
|
"env": {
|
|
"NODE_ENV": "production",
|
|
"EXPO_PUBLIC_API_BASE": "https://api.menivor.com/api/v1",
|
|
"EXPO_PUBLIC_REVENUECAT_IOS_API_KEY": "appl_pwrUJDdSPjeQVcigLWWuxTeOgXs",
|
|
"EXPO_PUBLIC_SUPABASE_URL": "https://psqkkdjzgptfcqpxuxki.supabase.co",
|
|
"EXPO_PUBLIC_SUPABASE_ANON_KEY": "sb_publishable_0K9kMcqwb6NUt2_p-WaaNQ_wAlwGv-J"
|
|
},
|
|
"channel": "production"
|
|
},
|
|
```
|
|
|
|
Then rebuild the store binary:
|
|
|
|
```sh
|
|
cd apps/mobile
|
|
eas build --platform ios --profile production
|
|
```
|
|
|
|
The Release build now calls `https://api.menivor.com/api/v1/...` instead of
|
|
localhost, so `createDeviceSession` and the rest of the `/api/v1` surface work
|
|
on a real device.
|
|
|
|
---
|
|
|
|
## 4. AI video via Replicate — spend protection (owner-approved 2026-09-15)
|
|
|
|
The AI-video path (`POST /api/v1/generation/broll/generate`) spends REAL money
|
|
on Replicate (hosted Wan 2.2). It is enabled by setting, in `apps/api/.env`:
|
|
|
|
```sh
|
|
BROLL_GEN_PROVIDER=replicate
|
|
REPLICATE_API_TOKEN=r8_... # never commit / never log
|
|
AI_VIDEO_CREDIT_COST=3 # credits debited per AI render
|
|
AI_VIDEO_DAILY_CAP=20 # global cap: renders per UTC day, all users
|
|
AI_VIDEO_USER_DAILY_CAP=2 # per-account cap: renders per UTC day
|
|
# optional model overrides (defaults are the cheapest/fastest official Wan):
|
|
# REPLICATE_WAN_T2V_MODEL=wan-video/wan-2.2-t2v-fast
|
|
# REPLICATE_WAN_I2V_MODEL=wan-video/wan-2.2-i2v-fast
|
|
```
|
|
|
|
How the caps behave (all enforced server-side, before any debit/enqueue):
|
|
|
|
* Each AI render debits `AI_VIDEO_CREDIT_COST` (3) credits atomically with job
|
|
creation; a failed generation is auto-refunded.
|
|
* Per-user and global caps are Redis `INCR` counters keyed by UTC day
|
|
(`reelforge:aivideo:cap:{user:<id>|global}:YYYYMMDD`, 2-day TTL). Over-cap
|
|
requests get a clean 429 ("at capacity today") and consume nothing.
|
|
* Caps FAIL CLOSED: if Redis cannot confirm capacity the render is refused
|
|
(503) instead of risking uncapped provider spend.
|
|
* The free `captions_only` reel path (`POST /jobs`) is NOT affected by these
|
|
caps.
|
|
|
|
Cost estimate: `wan-video/wan-2.2-t2v-fast` / `-i2v-fast` are billed per output
|
|
second (~$0.05-0.06/s) → a default 5s render (81 frames @16fps) costs roughly
|
|
**$0.25-0.30**. At the shipped caps the worst-case burn is ~$6/day.
|
|
|
|
> **IMPORTANT:** these product caps are the second line of defense. Also set a
|
|
> hard monthly spend limit in the Replicate dashboard (replicate.com → Account
|
|
> → Billing → Spend limit) so a bug can never outspend the budget.
|
|
|
|
The worker must consume the `generation` queue (already in
|
|
`docker-compose.yml`: `-Q celery,render,generation`). Ship backend changes with:
|
|
|
|
```sh
|
|
cd apps/api && docker compose up -d --build api worker
|
|
```
|