OpenProgram Docs

Single-port architecture

Path (in match order)Served by the worker fromCache
/wsNative WebSocket
/api/*Native routers
/v1/*OpenAI-compatible routers: OpenAI-compatible endpoint
/files/raw, /docs/*Static mounts
/_next/staticapps/web/out/Immutable
/*Files in out/; any other GET gets the shell out/chat.htmlNo-cache for HTML

The Electron shell loads the same origin. Ports and conflicts: Web UI port. Stable: 18100, or the next free port the account chose at its first start; development 18200.

Invariants

  • The backend is the sole origin. Nothing proxies it and nothing bakes a port into the build. /ws is right by construction: it is the origin the page loaded from.
  • API routes beat static. The frontend mount registers last.
  • Node is build-time only. Runtime needs Python and the worker.

Why not a Next server

A Next server beside the worker would costHere
The /ws proxy target fixed at build time; a build with the wrong profile env leaves every client disconnectedRelative /ws, /api/...; no rewrites()
Worker code for port reclaim, orphan killing, build watching, parent-PID watchWorker starts no Node process
Node at runtime for a UI that is all client-sideStatic export

Merging is cheap: the shell loads through next/dynamic with ssr: false, every real page is "use client", and there is no middleware.ts, server action or next/image. FastAPI has docs_url=None, so nothing collides with the docs mount.

Frontend export

PartDesign
apps/web/next.config.mjsoutput: "export": next build writes HTML, JS and CSS into apps/web/out/
Dynamic segmentsSession, skill and provider-settings paths have no page files; static export would reject them without generateStaticParams. The SPA fallback serves the shell and the client routes from pathname. A segment that does real work keeps generateStaticParams with one placeholder.
API route handlersNone; the worker serves those paths
Servingopenprogram/interfaces/server/frontend.py, mounted last in create_app()
Build gateensure_frontend_built: if out/index.html is missing or older than the newest source, run npm run build once at startup. A packaged release ships out/ and never invokes Node.

Process and port

PartDesign
Entryoperations/worker/runner.py calls interfaces.server.start_web and ensure_frontend_built
DiscoveryThe worker.port file is the single source of truth
Port knobsOPENPROGRAM_WEB_PORT and ui.web_port set the one port
Electronapps/desktop/main.js: WEB_PORT is OPENPROGRAM_WEB_PORT, else the instance's port. Start URL, origin check and navigation guard use it

operations/worker/web.py is leftover dual-port code outside the active call path, retained for a separate cleanup. It still names a watcher script that no longer exists.

Trade-offs

  • No next dev hot reload against the merged origin.
  • A dynamic segment that really rendered content would lose its deep link once its page file is gone. The SPA fallback covers it.
  • out/ can go stale after a pull. The startup gate covers it; run openprogram restart after git pull.
Acceptance criteria
  1. openprogram (dev profile) starts exactly one listening port; lsof shows no next-server.
  2. Fresh loads on /chat, /s/<id>, /settings/providers/<id> and /skills/<name> render; /ws connects; /api/pick-folder works.
  3. Killing the worker leaves a loaded page showing disconnected; restarting reconnects. No orphan processes.
  4. A build with no profile env produces a working instance.
  5. Tests pass; desktop app repackaged and verified.

Distribution

InstallPython
macOS desktopCPython and core dependencies embedded in the signed bundle; nothing downloaded at first launch
CLI, serveruv-managed environment
Source checkoutDevelopment build flow

Authority: Installation, packaging, release, and upgrade.

Implementation status

Implemented in the current runner and frontend mount. Desktop supervision and distribution status live in the page linked above.

Last updated · 2026-11-25