flexx logoflexx docs

Self-Hosting

Deploy the flexx relay and API on your own infrastructure. Docker Compose setup, required environment variables, and CLI configuration.

Architecture

The flexx platform consists of three backend services:

ServicePurposeDefault URL
BFFAPI gateway (auth, OAuth 2.1, billing, remotes)bff.flexx.dev
RelayWebSocket hub for MCP and SSHrelay.flexx.dev
DashboardWeb UI for managing remotes and onboardingapp.flexx.dev

Plus infrastructure:

  • PostgreSQL — primary database
  • Redis (x2) — caching and job queues

Docker Compose

All services have Dockerfiles in the monorepo. For local development:

docker compose up -d

This starts PostgreSQL, Redis, and the development services.

Production deployment

The services are designed to run on any container platform. The default deployment uses Railway.

Required environment variables

Key variables for each service:

VariableServiceDescription
DATABASE_URLBFFPostgreSQL connection string
REDIS_URLBFF, RelayRedis for caching
REDIS_QUEUE_URLBFFRedis for job queues
JWT_SECRETBFFJWT signing key
BFF_EXTERNAL_URLBFFPublic URL of the BFF (e.g., https://bff.flexx.dev)
BFF_INTERNAL_URLRelayInternal URL to reach BFF (e.g., http://bff:4000)
BFF_INTERNAL_TOKENBFF, RelayShared secret for internal APIs
RELAY_EXTERNAL_URLRelayPublic URL of the relay
DASHBOARD_URLBFFPublic URL of the dashboard (for CORS, OAuth redirects)
BETTER_AUTH_SECRETBFFBetter Auth encryption secret
BETTER_AUTH_URLBFFSame as BFF_EXTERNAL_URL

Pointing the flexx CLI to your server

Edit ~/.flexx/config.json:

{
  "apiUrl": "https://your-bff-host.com/api",
  "apiKey": "your-key"
}

The relay URL is derived automatically from the API URL (replacing bff with relay), or set explicitly in ~/.flexx/remote.json:

{
  "relayUrl": "https://your-relay-host.com",
  "remoteId": "...",
  "secret": "...",
  "workspace": "/path/to/workspace"
}

Database migrations

The BFF runs Drizzle ORM migrations on startup via entrypoint.sh. For manual migrations:

cd packages/db
DATABASE_URL=your_connection_string npx drizzle-kit push

On this page