Skip to content

Flank Environment

This page is the canonical list of environment variables the flank app reads at runtime. Flank is the visual workflow editor for the brain-owned workflow engine; its server functions call brain over HTTP, so its essential config is the brain API target plus Clerk auth.

Per the deployment-env standard, the service stage variable is FLANK_STAGE and must be one of production, staging, sandbox, or development. NODE_ENV is reserved for the Node runtime mode and must not be used as the app stage.

Variables

VariableRequiredDefaultSourcePurpose
BRAIN_API_URLYesapps/flank/app/lib/brain-http-client.tsBase URL of brain’s HTTP workflow API. All workflow/execution operations go here. Server functions throw if unset.
FLANK_STAGEYes (prod/staging)developmentapps/flank/server/runtime/stage.tsService app stage. Drives logging, feature flags, telemetry tags.
PORT / FLANK_PORTNo3100apps/flank/server/entry.tsHTTP port for the TanStack Start app. PORT wins on Railway; FLANK_PORT is the local default.
CLERK_SECRET_KEYYes (prod/staging)apps/flank/app/lib/auth.tsClerk backend secret. Used by requireAuth() on every server function and to mint the per-request session JWT forwarded to brain.
CLERK_PUBLISHABLE_KEY / VITE_CLERK_PUBLISHABLE_KEYYes (prod/staging)apps/flank/app/lib/auth.tsClerk client/publishable key. Used by createClerkClient; the VITE_-prefixed form is exposed to the browser.
FLANK_AUTH_BYPASS_UUIDNounsetapps/flank/app/lib/auth.tsWhen set, requireAuth() returns this UUID without calling Clerk. Local development only — never set in production. Note: with auth bypassed no Clerk JWT is minted, so brain calls are unauthenticated.
NODE_ENVNoproduction (build)Vite/TanStack StartNode runtime mode only. Do not use as service stage.

How flank authenticates to brain

Flank does not hold a brain API key. For each request, mintBrainToken() (apps/flank/app/lib/auth.ts) mints a fresh Clerk session JWT and sends it as a Bearer token to brain (the same shape fennec produces). Brain validates it via Clerk and gates workflow operations behind the ADMIN role. A valid Clerk session is therefore required for flank to read or write any workflow data.

Legacy / being retired

These variables belonged to the old model where flank ran its own engine and stored data in sirloin via gRPC. They are superseded by BRAIN_API_URL and brain’s HTTP API. They may still appear in apps/flank/.env.example and in code paths that have not been deleted yet, but new deployments should not depend on them. TODO(@law): remove these once the legacy gRPC/seed-sync wiring is gone.

VariableFormer purpose
SIRLOIN_GRPC_URLSirloin gRPC address for the old FlankStorageService storage client and seed-sync.
FLANK_SERVICE_TOKENService-to-service token flank sent on FlankResolveSecrets gRPC calls.
FLANK_ENCRYPTION_KEYAES-256 master key sirloin used to encrypt flank secret values at rest.
FLANK_SECRET_*Env-var fallback for adapter secret references ({{secret:name}}) under the old secret store.
FLANK_R2_PUBLIC_URL / FLANK_R2_SIGNING_KEYCDN base URL and signing key for the old data:media / data:character flank nodes.

Stage-by-stage requirements

StageMust setMay set
development (local)BRAIN_API_URLFLANK_AUTH_BYPASS_UUID, FLANK_PORT, Clerk keys
sandboxBRAIN_API_URL, Clerk keys, FLANK_STAGE
stagingAll Yes rows above
productionAll Yes rows above

Source of truth

Definitive references when this table drifts:

  • apps/flank/.env.example — the maintained example env
  • apps/flank/app/lib/brain-http-client.tsBRAIN_API_URL, request wiring
  • apps/flank/app/lib/auth.ts — Clerk + bypass UUID + brain token minting
  • apps/flank/server/entry.ts — port wiring, startup order
  • apps/flank/railway.json — Railway build/deploy config (Dockerfile builder, healthcheck path /sign-in, single replica in us-east4-eqdc4a). Note: the full set of environment variables for each Railway environment is configured in the Railway dashboard, not in this file. TODO(@law): mirror the Railway env list here once exported.

When adding a new variable, update both the table here and apps/flank/CLAUDE.md.