This page covers running Brainboot yourself. To use the hosted version, just sign up - no setup needed.
git clone <your-repo> brainboot cd brainboot npm install
1. Create project at supabase.com
2. SQL Editor - run these in order:
supabase-schema.sql (core tenancy + auth)
supabase-schema-v2.sql (email logs, dunning, trials)
supabase-onboarding.sql (users.metadata column)
supabase-brains.sql (brain registry)
supabase-circuits.sql (circuit catalog + scheduled runs)
supabase-cognitive-infrastructure.sql
supabase-moderation.sql (admin moderation queue)
3. Copy keys from Settings > API1. Create products in Stripe Dashboard:
Pro $29/mo (recurring)
Team $99/mo (recurring)
2. (Optional) Create Circuit products if you want paid Circuits:
Content Empire $99/mo
Sales Engine $129/mo
Founder Formation $149 one-time
Or run: npx tsx scripts/setup-launch-pricing.ts
3. Create webhook: yourdomain.com/api/stripe/webhook
Events: customer.subscription.created/updated/deleted, invoice.paid,
invoice.payment_failed
4. Copy webhook signing secret + price IDs into env1. Google Cloud Console > APIs & Services > Credentials 2. Create OAuth Client ID > Web application 3. Add redirect: http://localhost:3000/auth/callback 4. In Supabase: Auth > Providers > Google > paste credentials
cp .env.example .env.local # Fill in all required variables (Supabase, Stripe, AI gateway, app URL) # Optional but recommended for production: Upstash + Sentry
npm run dev # localhost:3000 npx vercel # deploy to production
Run these in the Supabase SQL editor in the order listed below. All migrations are idempotent and safe to re-run.
supabase-schema.sqlUsers, organizations, members, invitations, API keys, usage_log, admin_actions. Run first.
supabase-schema-v2.sqlEmail logs, webhook failures, dunning, trials.
supabase-onboarding.sqlAdds users.metadata JSONB for the onboarding wizard answers.
supabase-brains.sqlBrain registry table (bb_brains) and run history.
supabase-circuits.sqlCircuit catalog (bb_circuits), subscriptions, scheduled runs, run/model-call logs.
supabase-cognitive-infrastructure.sqlContext fabric, reflection runs, telemetry tables.
supabase-moderation.sqlAdmin moderation queue.
supabase-prompts-tier.sql + supabase-prompts-additional.sql + supabase-prompts-batch-3.sqlCurated prompt seed data for the marketplace.
Copy .env.example to .env.local and fill in your values.
NEXT_PUBLIC_SUPABASE_URLYour Supabase project URL. Found in Project Settings > API.
NEXT_PUBLIC_SUPABASE_ANON_KEYSupabase anon/public key for client-side auth.
SUPABASE_SERVICE_ROLE_KEYSupabase service role key for server-side admin operations. Never expose to the client.
STRIPE_SECRET_KEYStripe API secret key. Use test key (sk_test_) for development.
STRIPE_WEBHOOK_SECRETSigning secret for Stripe webhook verification.
STRIPE_PRO_PRICE_IDStripe Price ID for the Pro plan ($29/mo, 1M tokens, all models).
STRIPE_SCALE_PRICE_IDStripe Price ID for the Team plan ($99/mo, 10M tokens shared, all models).
NEXT_PUBLIC_STRIPE_PRO_PRICE_IDSame Pro price ID for client-side upgrade buttons.
NEXT_PUBLIC_STRIPE_SCALE_PRICE_IDSame Team price ID for client-side upgrade buttons.
NEXT_PUBLIC_APP_URLYour app base URL for redirects and callbacks.
AI_GATEWAY_API_KEYVercel AI Gateway key. One key unlocks every model in the catalog (OpenAI, Anthropic, Google, xAI, DeepSeek, Mistral). Get at vercel.com/ai-gateway.
RESEND_API_KEYResend API key. If not set, emails log to console.
EMAIL_FROMSender address. Defaults to "Brainboot <noreply@yourdomain.com>".
EMAIL_REPLY_TOReply-to address. Defaults to "support@yourdomain.com".
UPSTASH_REDIS_REST_URLUpstash Redis REST URL. Enables distributed rate limiting across serverless instances. Without it the app falls back to in-memory rate limiting (per-instance only).
UPSTASH_REDIS_REST_TOKENUpstash Redis REST token, paired with the URL above.
SENTRY_DSNSentry DSN for error tracking. Without it, errors only land in server logs.
NEXT_PUBLIC_SENTRY_DSNSame Sentry DSN for client-side error capture.
LABS_ENABLEDSet to "true" on private Labs deployments to expose /nrfi, /f3, /parlays, /labs, /engines and the related cron jobs. Leave unset on the public Brainboot deployment.
SUPABASE_PATSupabase Personal Access Token. Only required when running scripts/seed-circuits.py or scripts/seed-invariants.py against a project. Generate at supabase.com/dashboard/account/tokens.
Update metadata in src/app/layout.tsx, text in src/components/nav.tsx, logo in src/components/logo.tsx, colors in src/app/globals.css, email branding in src/lib/email.ts.
Edit PLAN_LIMITS and PLAN_PRICES in src/lib/supabase.ts. Update MODEL_ACCESS_BY_PLAN in src/lib/models.ts to change which model tiers each plan can run. Then rerun npx tsx scripts/setup-launch-pricing.ts to provision matching Stripe products and prices.
Append an entry to MODELS in src/lib/models.ts (id from Vercel AI Gateway catalog, tier cheap/standard/flagship, costWeight). It is automatically gated and metered.
Create src/app/api/your-feature/route.ts. Use withAuth() wrapper for automatic auth + rate limiting and consistent error envelope.
Call incrementOrgUsage(orgId, weightedTokens) from any API route after a successful LLM call. Atomic via Supabase RPC, race-safe.
Add to the templates object in src/lib/email.ts. Send with sendEmail({ to, template, data }). All sends log to email_logs.
Set LABS_ENABLED=true in the environment. The middleware (src/middleware.ts) gates all /nrfi, /f3, /parlays, /labs, /engines routes plus the related cron paths. Public Brainboot deployments leave this unset.