AI-powered short‑form video generator. Write a script, generate a voiceover, captions, images, and render a 9:16 video via Remotion Lambda. Auth, data, and quotas are managed with Supabase; subscriptions with Polar; analytics with PostHog.
- Frontend: Next.js 15 (App Router), React 19, TypeScript, Tailwind CSS v4, shadcn/ui
- Auth & DB: Supabase (Auth, Postgres, Storage)
- Video: Remotion 4 + AWS Lambda, S3 for outputs
- AI: ElevenLabs (TTS), DeepInfra (LLM), Whisper/ASR pipeline
- Billing: Polar (Checkout + Customer Portal)
- Analytics: PostHog (client + server)
- Moderation: AWS Rekognition (image content safety)
- Node.js 20+
- AWS account + IAM user with S3/Lambda permissions (for Remotion Lambda)
- Supabase project (URL + anon key + service role key)
- Polar account (access token + webhook secret)
- ElevenLabs API key
- DeepInfra API key
- PostHog project key
npm installCreate a .env.local at the repo root (values are examples/placeholders):
# App
NEXT_PUBLIC_APP_URL=http://localhost:3000
NEXT_PUBLIC_SITE_URL=http://localhost:3000
# Supabase
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key
# Analytics (PostHog)
NEXT_PUBLIC_POSTHOG_KEY=phc_your_key
# Billing (Polar)
POLAR_ACCESS_TOKEN=your_polar_access_token
POLAR_SERVER=sandbox # or production
POLAR_SUCCESS_URL=http://localhost:3000/dashboard/confirmation
POLAR_WEBHOOK_SECRET=whsec_...
# AI
ELEVENLABS_API_KEY=your_elevenlabs_key
DEEPINFRA_API_KEY=your_deepinfra_key
# Optional, used by openai image helper
OPENAI_API_KEY=sk-...
# Remotion Lambda / AWS
# Either set REMOTION_* or standard AWS_* keys
REMOTION_AWS_ACCESS_KEY_ID=AKIA...
REMOTION_AWS_SECRET_ACCESS_KEY=...
# Optional (used by deploy script as fallback)
AWS_ACCESS_KEY_ID=AKIA...
AWS_SECRET_ACCESS_KEY=...
# Cron (for subscription maintenance)
CRON_SECRET=super-secure-random-string
# Optional
FACEBOOK_DOMAIN_VERIFICATION=Notes:
- Do not commit secrets.
.gitignorealready excludes env files. NEXT_PUBLIC_APP_URLis used by server actions that call internal API routes for Lambda rendering.
Use the SQL in supabase/migrations/001_initial_schema.sql to create tables and functions (scripts, videos, subscriptions, usage helpers). You can paste it in the Supabase SQL editor or run it with your preferred tooling.
npm run devVisit http://localhost:3000.
Rendering is done on AWS Lambda via Remotion. Update scripts/config.mjs if needed:
export const REGION = "us-west-1";
export const BUCKET_NAME = "your-remotion-bucket";
export const SITE_NAME = "reelka"; // deployment/site name
export const RAM = 2048;
export const DISK = 2048;
export const TIMEOUT = 800;Then deploy the Lambda function and S3 site:
npm run deployRequirements:
REMOTION_AWS_ACCESS_KEY_IDandREMOTION_AWS_SECRET_ACCESS_KEY(or standard AWS vars) must be set.NEXT_PUBLIC_APP_URLmust point to your running app domain (used by server to call/api/lambda/*).
Local preview with Remotion Studio:
npm run remotionManual render (CLI):
npm run render -- Composition- Subscriptions are handled via Polar checkout and customer portal
- Checkout route:
GET /api/checkout - Portal route:
GET /api/portal?customerId=...
- Checkout route:
- Webhook handler:
POST /api/webhook/polar(setPOLAR_WEBHOOK_SECRET) - Quota/usage tracking stored in
subscriptionstable. Helpers and reset logic are in the SQL migration.
Scheduled quota maintenance:
GET /api/cron/subscription-checkexpects headerAuthorization: Bearer ${CRON_SECRET}- Cancels expired subscriptions and resets monthly quotas when needed
From the editor (/dashboard/videos/editor/[scriptId]):
- Text‑to‑Speech (ElevenLabs):
/api/video/generate-audio - Captions (ASR):
/api/video/generate-captions - Prompt generation (DeepInfra LLM):
/api/video/generate-prompts - Image generation (Stable diffusion/Flux via DeepInfra):
/api/video/generate-images - Image moderation (AWS Rekognition) before render
- Render via Remotion Lambda:
/api/lambda/render, progress/api/lambda/progress, cleanup/api/lambda/delete
Uploads
- Direct, signed S3 uploads for user-provided images:
POST /api/upload/presigned-url
- PostHog is initialized on client and server.
- Set
NEXT_PUBLIC_POSTHOG_KEY(and optionalNEXT_PUBLIC_POSTHOG_HOST). - Feature flags: keep usage minimal and centralized; validate flag values.
app/ # Next.js routes (App Router)
api/ # API routes (checkout/portal, video generation, lambda, cron)
dashboard/ # Authenticated app (scripts, videos, billing)
remotion/ # Remotion Root + Composition
components/ # UI components (shadcn UI, dashboard, editor)
hooks/ # React hooks (local storage, generation pipeline)
scripts/ # Lambda/S3 deploy helpers & config
supabase/ # SQL migrations
types/ # Shared TypeScript types
utils/ # AI, AWS, Supabase, Remotion, PostHog helpers
Key files
app/remotion/Composition.tsx: 9:16 composition, captioning, Ken Burns imagesapp/api/video/*: asset generation endpoints (audio, captions, prompts, images)app/api/lambda/*: Remotion Lambda render/progress/deleteapp/api/webhook/polar/route.ts: Polar webhooksutils/supabase/*: client/server/admin clients, billing helpers, storageutils/aws/*: S3 client + Rekognition moderation
npm run dev # Start Next.js (with Turbopack)
npm run build # Production build
npm run start # Run production server
npm run remotion # Open Remotion Studio locally
npm run render # Render via Remotion CLI (local render)
npm run deploy # Deploy Remotion Lambda function & site (AWS)- App:
NEXT_PUBLIC_APP_URL,NEXT_PUBLIC_SITE_URL - Supabase:
NEXT_PUBLIC_SUPABASE_URL,NEXT_PUBLIC_SUPABASE_ANON_KEY,SUPABASE_SERVICE_ROLE_KEY - PostHog:
NEXT_PUBLIC_POSTHOG_KEY,NEXT_PUBLIC_POSTHOG_HOST - Polar:
POLAR_ACCESS_TOKEN,POLAR_SERVER,POLAR_SUCCESS_URL,POLAR_WEBHOOK_SECRET - AI:
ELEVENLABS_API_KEY,DEEPINFRA_API_KEY, optionalOPENAI_API_KEY - AWS / Remotion:
REMOTION_AWS_ACCESS_KEY_ID,REMOTION_AWS_SECRET_ACCESS_KEY(orAWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY) - Cron:
CRON_SECRET - Optional:
FACEBOOK_DOMAIN_VERIFICATION
Never hardcode or commit secrets. Use .env.local and platform secret managers.
- UI: Uses Tailwind v4 and shadcn/ui. To add components:
npx shadcn@latest add <component>
- Styling: Inter typography, rounded buttons, light/dark themes are preconfigured in
app/globals.css. - Images: Next Image allows specific remote hosts (see
next.config.ts). - Feature flags and custom properties for analytics: keep names consistent and centralized.
- Frontend/API: Deploy on platforms like Vercel. Ensure all env vars are set, especially
NEXT_PUBLIC_APP_URL. - Rendering: Deploy Remotion Lambda (
npm run deploy), confirm the region/bucket/site inscripts/config.mjsand AWS permissions. - Webhooks: Expose
POST /api/webhook/polarand setPOLAR_WEBHOOK_SECRET.
- Missing credentials errors in Lambda endpoints: ensure AWS/Remotion env vars are present on the server.
- Polar webhooks failing: verify
POLAR_WEBHOOK_SECRETand that your endpoint is reachable. - Supabase auth issues: confirm URL/keys and that cookies are allowed in your domain.
- Image generation fails: check
DEEPINFRA_API_KEYand logs. Rekognition rejections will surface as content policy violation errors. - Video stuck in processing: check
/api/lambda/progresslogs and AWS CloudWatch for the Lambda.
MIT — see LICENSE.