Documentation Reference
Run your own deployment
For whoever hosts Opportunora itself. The processes, first install, the environment that matters, workers, Docker, backups, key rotation and the command-line tools.
Most people use a hosted workspace and never read this page. It is for whoever runs the app itself: the web server, the worker, the database, and the environment they read. Everything in the rest of the documentation assumes this part is done.
What runs
| Piece | Command | Does |
|---|---|---|
| Postgres 16 | npm run db:up, or any Postgres |
Holds everything, including every generated site's HTML. |
| The web app | npm run build and npm start |
Serves the screens, the API and the pay pages. |
| At least one worker | npm run worker |
Runs discovery, generation, publishing, editor chat and the payments sweep. |
The web server never does the slow work. A click writes a queued job and returns; a worker claims it. Without a worker, nothing fails — it just never happens. Discovery runs sit queued, generations sit at Starting — handing the job to a worker, publishes never produce an address, editor messages show Still waiting for the editor to start, and invoices never turn overdue.
First install
npm install
cp .env.example .env.local # then fill it in, see below
npm run db:up # Postgres in Docker
npm run db:migrate
npm run dev # http://localhost:3000
npm run worker # a second terminal
npm run db:seed loads a demo workspace and prints its sign-in. It is
development data: it refuses to run against a non-local database unless you
force it, and a real deployment should never carry it.
The environment
.env.example documents every variable. The ones that decide whether the
product works at all:
| Variable | Needed for | Without it |
|---|---|---|
DATABASE_URL |
Everything | Nothing starts. |
APP_URL |
Sign-in redirects, pay links, OAuth callbacks, PayPal webhooks | Production refuses to boot. No trailing slash; it must match what you registered at Google, Microsoft and Stripe exactly. |
AUTH_SECRET |
Google and Microsoft sign-in | The provider buttons fail with Sign-in is not configured on this site. |
CREDENTIAL_ENCRYPTION_KEY |
Connecting Cloudflare, PayPal | Settings refuses to store them: Set an encryption key first. Web and workers must share it. |
| An AI provider key | Real discovery and generation | Discovery returns seeded demo leads and generation uses a fixed template, silently. |
Generate the two secrets with:
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
Keep CREDENTIAL_ENCRYPTION_KEY out of the database and out of database
backups. The split is what stops a leaked dump from being enough to publish to,
and bill, someone else's Cloudflare account.
AI providers
Set one of ANTHROPIC_API_KEY, OPENAI_API_KEY or OPENROUTER_API_KEY. The
vendor and model are infrastructure choices, set in the environment rather than
in the app: DISCOVERY_PROVIDER and DISCOVERY_MODEL for research,
GENERATION_PROVIDER and GENERATION_MODEL for building and editing sites,
which fall back to the discovery ones.
Discovery must be able to search the web. Anthropic and OpenRouter search on
their side; an OpenAI-compatible provider needs SEARXNG_URL,
BRAVE_SEARCH_API_KEY or SERPER_API_KEY. A provider that cannot search counts
as unconfigured, and runs fall back to the demo leads.
Sign-up, email and bot protection
| Variable | What it does |
|---|---|
SIGNUP_MODE |
open or invite-only. Invite-only accepts only people holding a registration invitation. An unrecognised value closes sign-up. |
SIGNUP_CARD_REQUIRED |
true asks every new workspace for a card before it can use the AI, and starts a trial that converts. Needs the billing variables below. Workspaces that exist already aren't affected. |
SIGNUP_MAX_PER_IP_PER_DAY, SIGNUP_MAX_UNVERIFIED_PER_HOUR, SIGNUP_MAX_PROVIDER_TRIALS_PER_HOUR |
Caps on new sign-ups, per address and deployment-wide. Defaults 3, 30, 30. |
DISPOSABLE_EMAIL_DOMAINS |
Extra disposable-mail domains to refuse. |
TURNSTILE_SITE_KEY, TURNSTILE_SECRET_KEY |
Cloudflare Turnstile on password sign-up and forgot-password. Set both or neither: with one, both forms refuse every request. |
RESEND_API_KEY, EMAIL_FROM |
The app's own email. Without them in production, password sign-up and Forgot your password? are off. |
SUPPORT_EMAIL |
Receives Open a ticket and Request a feature. |
OWNER_NOTIFY_EMAIL |
Receives a note on each sign-up, purchase, plan change, cancellation and failed payment. Unset, nothing is sent. |
Optional integrations
| Variable | What it does |
|---|---|
GOOGLE_PLACES_API_KEY |
Lets discovery look businesses up on Google Maps (Places API, New). Each lookup costs 3.5 credits, set by AI_CREDITS_PER_MAPS_LOOKUP. PLACES_RPM, PLACES_BURST and PLACES_TIMEOUT_MS tune it. |
PEXELS_API_KEY |
Adds up to four stock photos to sites whose business has fewer than six pictures of its own. |
The preview domain
Sites published on the Preview domain are served from a public R2 bucket
behind a Cloudflare Pages project, under one domain shared by every workspace.
Set SHARED_DOMAIN and SHARED_DOMAIN_R2_ENDPOINT, SHARED_DOMAIN_R2_BUCKET,
SHARED_DOMAIN_R2_ACCESS_KEY_ID and SHARED_DOMAIN_R2_SECRET_ACCESS_KEY on web
and workers. npm run shared-domain setup creates the bucket and project with
the SHARED_DOMAIN_CLOUDFLARE_* credentials, and npm run shared-domain check
verifies it. Without the bucket, the option reads Not available on this
server.
Billing for plans
Plans and top-ups are sold through Stripe Billing on the platform's own Stripe
account. Set STRIPE_BILLING_PRICE_SOLO, _STUDIO, _AGENCY, their _YEARLY
versions, STRIPE_BILLING_PRICE_CREDITS_1000 and _CREDITS_5000,
STRIPE_BILLING_PORTAL_CONFIGURATION, and STRIPE_BILLING_WEBHOOK_SECRET for a
webhook at <APP_URL>/api/webhooks/platform-billing. In a sandbox,
node scripts/setup-platform-billing.js --write-env --local-webhook creates
them for you.
Sign-in providers
Google needs GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET; Microsoft needs
MICROSOFT_CLIENT_ID, MICROSOFT_CLIENT_SECRET and optionally
MICROSOFT_TENANT_ID. Leave either pair incomplete and that button does not
render. Register the callback as <APP_URL>/api/auth/callback/google or
…/microsoft.
With MICROSOFT_TENANT_ID left at common, any Microsoft account can create a
workspace. Set it to your directory's id to keep sign-in inside one company.
Payments
PAYMENTS_LIVEMODE=true for real money; anything else is sandbox. Stripe needs
the platform setup described in Connect
Stripe.
PayPal needs no variable of its own, only the encryption key and an HTTPS
APP_URL for its webhook.
Workers
Each worker process drains five queues by default — discovery, generation,
publish, editor and payments — and holds no state between jobs, so
replicas are interchangeable. The editor queue runs editor chat turns and is
not optional: without a worker draining it, chat messages wait.
- More throughput: start more workers.
DISCOVERY_CONCURRENCY,GENERATION_CONCURRENCY,PUBLISH_CONCURRENCYandEDITOR_CONCURRENCYset how many jobs each runs at once.EDITOR_TURNS_PER_WORKSPACE(default 2) caps a workspace's editor turns at once; set the same value on workers and the autoscaler. - Split the workloads:
QUEUES=discoveryon one machine,QUEUES=generation,publishon another. - Autoscale on running plus runnable jobs per queue from
GET /api/queues/depth, enabled byQUEUE_METRICS_TOKEN. Runnable excludes jobs waiting for a workspace plan slot. Keep at least one worker for payment reconciliation and housekeeping.
Plans cap running discovery, generation and publishing jobs together: Trial/Solo 1, Studio 3, Agency 10 per workspace. Waiting jobs do not use a running slot. One generation per website and one publish per workspace prevent conflicting changes.
For Railway, the app repository includes railway/worker.json, railway/autoscaler.json, and docs/RAILWAY_SCALING.md with the setup instructions. The controller grows the worker service from queue demand and returns to its minimum after an idle period.
Run a worker from the repository root; it loads .env.local from where it
starts.
Docker
The Dockerfile builds one image for both roles: npm start for the web app,
npm run worker for workers. docker-compose.yml runs Postgres and, behind a
profile, workers:
docker compose --profile worker up -d --build --scale worker=3
Compose does not start the web app; run the image with npm start behind your
own proxy. For multiple replicas, put uploads in a private bucket shared by web
and workers: UPLOADS_STORAGE=r2 with R2_ENDPOINT, R2_BUCKET,
R2_ACCESS_KEY_ID and R2_SECRET_ACCESS_KEY (the older UPLOADS_S3_*
variables still work). The bucket stores logos, attachments and copied images
for all instances. On a single host, put UPLOADS_DIR (default .uploads) on
shared persistent storage. Do not attach a local volume to replicated
workers.
Backups
There is no export in the app. Back up three things, separately:
- The database — every workspace, every invoice, and every generated site's HTML.
- The uploads directory — logos, attachments, and the pictures copied from clients' old sites. They are not in the database.
CREDENTIAL_ENCRYPTION_KEY— somewhere other than the database backup. Without it no stored Cloudflare token or PayPal secret can be opened.
Rotating the encryption key
- Generate a new key.
- Move the old one to
CREDENTIAL_ENCRYPTION_KEY_PREVIOUS, put the new one inCREDENTIAL_ENCRYPTION_KEY, and restart every web and worker process. npm run secrets:reseal -- --checklists anything neither key opens.npm run secrets:resealrewrites every stored credential under the new key.- Remove
CREDENTIAL_ENCRYPTION_KEY_PREVIOUSand restart.
A value neither key opens stays as it is; that workspace reconnects the account.
Command-line tools
Credits and announcements are command-line tools:
npm run credits -- <workspace> show
npm run credits -- <workspace> grant 500 --kind topup --note "Goodwill after the outage"
npm run credits -- <workspace> plan studio
npm run credits -- <workspace> ledger --limit 20
<workspace> is the workspace id or its slug. --note is required on a grant.
To post a message to everyone's notification bell:
node scripts/announce.js maintenance-0912 "Scheduled maintenance tonight at 22:00" --preview
node scripts/announce.js maintenance-0912 "Scheduled maintenance tonight at 22:00"
The first argument is a key you choose. Sending the same key twice only reaches
people who do not have it yet. --to limits it to one workspace, --href sets
where the bell links, and --preview reports who would get it without sending.
Run it with node, not npm run: npm swallows the flags, and a rehearsal with
--preview turns into a send.
Run logs and cost
Every finished discovery run writes a JSON file to logs/discovery-runs/ and a
line to index.ndjson beside it: what it found, what it cost in tokens and
searches, and what that cost in money at the prices configured.
npm run discovery:cost summarises them. It is the data you price the product
from.