THESIS docs
v1.1.0
Live demo Get help
● Set up · How the parts talk

Architecture
who talks to whom.

One picture of where each piece runs and which way data moves. The short version: trading happens between the user's browser tab and Hyperliquid; your server holds settings and calls the AI, and never sees a wallet key or an order.

01Data flow

THESIS architecture and data flow The user's browser tab talks directly to the Hyperliquid API for market data and signed orders, and directly to the Telegram Bot API for optional alerts. It calls the THESIS server only for settings, AI chart reading and the Pro plan. The server stores the admin in Postgres or SQLite, keeps aggregate counters in a file or Vercel Blob, calls the Anthropic API with the operator's key, and reads public Hyperliquid data for status checks and revenue. The operator's browser opens the admin console on the same server. User's browser tab landing / and desk /app • Rules, backtest, robustness lab (lab in a Web Worker) • Strategies, journal, alert settings in localStorage, never on a server • Agent key created here memory, or sessionStorage for the tab • Signs each order with the agent key • Browser wallet signs once: approveAgent, approveBuilderFee • Evaluates rules on each closed candle while the tab is open Operator's browser Admin console /admin settings, team, status, revenue Telegram Bot API user's own bot · alerts only THESIS server server/app.ts · Node or Vercel function /api/config public settings /api/strategy AI chart reading /api/pro/* plan sign-in /api/health quick check /admin/api/* Admin Kit (Hono) Never holds a wallet key. Never signs, places or relays an order. Stores no IPs, wallets or visitor IDs. Secrets encrypted with ADMIN_SECRET_KEY Hyperliquid API api.hyperliquid.xyz · testnet REST + WebSocket Anthropic API (optional) operator's key · billed per request Postgres or SQLite DATABASE_URL, or admin.sqlite file settings, team, audit, encrypted secrets stats.json or Vercel Blob aggregate daily counters only market data · signed orders · wallet approvals direct from the tab, not through your server read only: Status checks, Pro payments, revenue Trading path: the user's tab and Hyperliquid only Server reads public Hyperliquid data (no key, no orders) HTTPS request (arrow points to the one called)
Every arrow is a real call in the code; the table below names the file.

02Every arrow, with the code behind it

From → toWhat movesCode
Browser tab → HyperliquidMarket list, candles, funding, prices (REST and WebSocket); account state; for testnet and mainnet runs, orders and cancels signed by the agent key in the tab.src/hl/market.ts, src/hl/trade.ts, src/landing/live.ts
Browser wallet → HyperliquidTwo one-time signatures: approveAgent (the expiring trading key) and, if you set a builder fee, approveBuilderFee. A Pro payment is a usdSend the user signs.src/hl/trade.ts
Browser tab → TelegramAlert messages, with the user's own bot token. Only when the user sets up Telegram alerts.src/live/telegram.ts
Browser tab → THESIS serverGET /api/config (public settings), POST /api/strategy (chart image or candles, for AI chart reading), /api/pro/* (plan sign-in by a signed message).src/config.ts, src/ui/actions.ts, src/ui/pro.ts → server/app.ts
Operator's browser → THESIS serverThe admin console and its API under /admin/api/*, with an HttpOnly session cookie.packages/admin-kit/server/kit.ts
Server → AnthropicThe chart or candles and the prompt, with your key. Only when AI is on and a key is set.server/ai.ts
Server → Postgres or SQLiteAdmin settings, owner and team, sessions, audit log, history, encrypted secrets.packages/admin-kit/server/postgres.ts, sqlite.ts; chosen in server/node.ts and server/app.ts
Server → stats file or Vercel BlobAggregate daily counters (AI requests, tokens, page loads). No visitor is identified.server/store.ts
Server → Hyperliquid (read only)Status checks (mainnet and testnet answer, builder address value), your pay-to address ledger for Pro payments, reward claims for Revenue. No key, no orders.server/admin-kit.ts, server/revenue.ts

On Vercel, api/[...path].ts passes every /api/* and /admin/api/* request to the same handler; on your own server server/node.ts does, and also serves the built pages from dist/.

03How the boundaries are enforced

  • Content-Security-Policy: the pages may connect only to their own origin, the Hyperliquid hosts (mainnet and testnet, api. and rpc., HTTPS and WSS) and https://api.telegram.org. The list is in server/csp.ts (Node) and vercel.json (Vercel). A request to any other host is blocked by the browser.
  • Network log: the desk's key panel lists every host the tab contacted, so you and your users can check it (Using the desk).
  • No key on the server: the agent key is generated in the tab (src/hl/trade.ts) and kept in memory or sessionStorage; the server code has no signing path for orders.
  • Secrets at rest: the Anthropic key, the webhook secret and two-factor secrets are encrypted with ADMIN_SECRET_KEY (Secrets and backups).