Browse guides

Deployment and security

Configure the gateway, run the bounded worker and keep the ledger and market recordings together.

On this page

How the hosted demo runs

Next.js on Vercel renders Workspace, Dashboard and Docs. The gateway forwards permitted browser requests to a FastAPI service on Railway. The operator can start a bounded collector on that same service. The API and worker use the same persistent volume.

How the web app reads the trading ledger. The browser calls the Next.js gateway, which authenticates to FastAPI. A bounded worker reads both markets and writes the SQLite ledger and recording archive.

The root Workspace serves the input field in the initial HTML. Session selection, chat history and ledger details load in the background. A visitor can type while those reads are pending. Submitted text waits for the conversation to open and returns to the composer if that connection fails.

Configure server access

VariableLocation and use
FLOWSHIELD_WEB_ORIGINNext.js. The exact public HTTPS origin, including the host the browser will use.
FLOWSHIELD_API_ORIGINNext.js. The HTTPS API origin, or a loopback HTTP sidecar.
FLOWSHIELD_API_TOKENBoth services. Matching server-side bearer token, 32 to 256 letters, digits, underscores or hyphens.
FLOWSHIELD_ALLOWED_API_HOSTSFastAPI. Allowed hostnames or IP addresses without ports.
FLOWSHIELD_PAPER_SECONDSRailway. Zero keeps scheduled-on-start collection idle. A positive duration starts one bounded worker.
FLOWSHIELD_PAPER_SESSION and FLOWSHIELD_PAPER_INTERVALRailway. Set a new session ID for a new window and set the observation interval in seconds.

Public visitors use the same run settings. ETH/BTC conversations and pending proposals use an anonymous HTTP-only browser cookie. The Next.js gateway sends the API token server to server and checks the origin on browser writes. Keep external model credentials and private trading credentials in their respective server or operator environments.

Persist the ledger and recordings

Mount the Railway volume at /data. The service uses /data/flowshield.sqlite3 and stores live recording segments beside the ledger. SQLite serializes writes for this deployment. The collector lock prevents overlapping worker runs on the same host. When restoring a run, restore the SQLite backup and the associated recording directory together so the manifest can be checked before replay.

A separate database or queue service is optional at this scale. PostgreSQL becomes relevant if the worker and API move to independent hosts that must share writes. The current event viewer polls the active run through the gateway.

Check a local production build

Start FastAPI and build the web app as separate processes. The default local gateway expects port 8000.

uv run --locked flowshield serve
npm --prefix frontend ci
npm --prefix frontend run build
FLOWSHIELD_LOCAL_MODE=1 npm --prefix frontend run start

If using another local API port, set FLOWSHIELD_API_ORIGIN to its actual loopback origin before starting Next.js. Check /healthz on FastAPI, open a seeded market session in the web app, and refresh the conversation after asking for positions. For an end-to-end runtime check, follow the Quickstart.