Skip to content

Configuration

Everything is set through environment variables. Bun loads packages/server/.env when the server starts through the repo scripts; packages/server/.env.example lists the same variables with comments.

Server

VariableDefaultWhat it does
DATABASE_URLnone, requiredPostgreSQL connection string. The server does not start without it.
PORT3001HTTP port. Socket.IO listens on PORT + 1.
API_TOKENempty (off)Static bearer token for scripts, agents and a self-hosted browser. It maps to the bootstrap user. Empty means token access is off, not that some default works.
ALLOWED_ORIGINSlocalhost dev originsComma-separated browser origins allowed to open Socket.IO. Set it to your terminal’s public origin in production.
ALLOW_REGISTRATIONoffSet to 1 to allow sign-up at POST /api/auth/register. Every local account has full access, so keep it off on a server the internet can reach.
STATIC_DIRpackages/client/distBuilt client that the server serves next to the API.
MODULES_DIRpackages/server/.modulesWhere installed modules and modules.json live.
MODULES_ADMIN_TOKENemptyOperator token for installing, updating and removing modules. The browser sends it from the Operator token field in the Module Store. With no token and no SSO admin, module management answers 503.
PROFITMAKER_DEV_MODULESemptyAbsolute path to a module folder to load live in dev mode. See Write your first module.

Single sign-on (MarketMaker accounts)

Only needed if your server accepts MarketMaker logins. A plain self-host can leave all of these unset.

VariableDefaultWhat it does
AUTH_URLhttps://auth.marketmaker.ccAuth service. Its JWKS verifies sign-in tokens.
AUTH_AUDIENCEemptyExpected aud claim. Set it once the auth service issues tokens scoped to the terminal.
AUTH_REQUIRED_SERVICEemptyIf set, a token must carry a role for this service.
AUTH_VERIFY_ISSUERoff1 also checks the token’s iss against AUTH_URL.
AUTH_INTERNAL_URLAUTH_URL hostAddress for server-to-auth calls that fetch stored exchange keys.
AUTH_INTERNAL_SECRETemptyShared secret for those calls. Without it, trading with stored accounts answers 503. Keep it out of logs and git.
MODULES_ADMIN_SERVICEprofitmakerService whose admin role may manage modules.
USAGE_METERING_ENABLED0Usage analytics for the hosted service.

Client (build time)

VITE_* values are baked into the JavaScript at build time. The browser can read them, so never put a token there for a terminal other people use.

VariableDefaultWhat it does
VITE_SERVER_URLpage origin in production, http://localhost:3001 in devWhere the client finds the server.
VITE_API_TOKENemptyToken the client sends when nobody is signed in. Handy for a personal terminal.
VITE_AUTH_URLhttps://auth.marketmaker.ccAuth service address for the sign-in button.

The client looks for a token in this order: a MarketMaker sign-in, the token saved in the provider settings, the token typed into the Enter token form (kept in local storage as profitmaker.apiToken), then VITE_API_TOKEN.

CLI and MCP

VariableDefaultWhat it does
PROFITMAKER_URLhttp://localhost:3001Server the profitmaker CLI and MCP server talk to.
PROFITMAKER_TOKENemptyBearer token they send. Usually your API_TOKEN.

How a request is authenticated

/health and /api/auth/* are open. Every other route needs Authorization: Bearer <token>. The server tries the token as:

  1. the API_TOKEN,
  2. a local session from /api/auth/login (valid 30 days),
  3. a MarketMaker sign-in token, checked against the auth service’s keys.

No token gives 401 Access token required. A token that matches none of these gives 403 Invalid token.