Internals

This section explains how Gamehoster runs, worked through as one model. It starts on your machine with the client, moves to the server box and the live networking that carries the play, covers the two management APIs the client speaks — sync and tools — and ends deep in the model: the instance and the front end. None of it is needed to ship a game; it is here so the whole picture, and the design, has one place to live.

How it runs: generated ahead of time

A game's definition (JSON schemas and raw JS bodies) is generated into plain static code when you sync it, not interpreted on the server. The build emits two files per game and the sync pushes them; the server loads them directly, so no new Function ever runs at request time:

The runtime that runs every game is shared: the same code loads each generated module and runs the tick, rather than compiling raw bodies. How that runtime works, and the network layer that serves it, is the Networking and Instance pages; the generation step itself is the Sync page.

definition ──generate (at sync)──▶ static server module + front-end library
 (JSON + raw JS)                     (bodies inlined as real functions,
        │                             pushed to the server, ready to run)
        │
        └── sync ──▶ server ──require──▶ World ──▶ live instances (tick loop)
                       │                              │
   browser ◀── relayed commands + state (send rate) ◀─┘
      └── commands ──▶ Caddy ──▶ localhost (Host→game routing)
The definition is generated to static code at sync time; the server requires it and runs the tick, with no runtime compilation

Each tick runs the tick function, the three-step cycle from Updates: handle the commands, update every actor, run the instance body.

The pages

Model and code

These pages describe both the code as it runs and the model it is built to: the snapshot, the tick function, the timeline and rewind, the view, and prediction. It is the design we are refining and the target the code is being brought in line with. Where a detail is still open, the page says so.