Serve the navigator and city on a network
codegraph serve starts a small HTTP server with both artifacts loaded: the
navigator, with the 3D city as one of its tabs. By default it binds every
interface, which is convenient on a LAN and wrong for a codebase you would not
email. This guide covers both, and the route that needs no server from codegraph
at all.
Before you start: a built workspace — serve needs the built frontend
(pnpm -r build).
Keep it on this machine
codegraph serve model.jsonl --host 127.0.0.1codegraph at http://localhost:4177/ — Ctrl-C to stop.serve defaults to port 4177. replay --serve and history --serve open the
standalone city viewer on a replay and also default to 4177 — run them one at a
time, or give each its own port.
Share it on a LAN
The default --host 0.0.0.0 already does this. The announcement never prints
http://0.0.0.0:4177/, which nobody can type; it prints the local URL and states
the reach beside it — (every interface — reachable from other machines).
Colleagues reach it at your machine’s own address on that port.
--host 127.0.0.1 is the
setting you want unless you have decided otherwise.Pick a port
codegraph serve model.jsonl --host 127.0.0.1 --port 0--port 0 takes any free port and announces the one it got:
codegraph at http://localhost:38885/ — Ctrl-C to stop.If the port is taken:
codegraph: port 4177 is already in use — pick another with --port (0 = any free port).If the address does not exist on this machine:
codegraph: cannot bind 10.0.0.5 — no interface on this machine has that address. Use --host 0.0.0.0 for every interface, or 127.0.0.1 for this machine only.Serve it yourself, in two steps
serve is a convenience. The artifacts and the viewer are separate things, so
you can put the artifacts on any static host — behind your own authentication,
in a CI job’s pages, or on a share.
-
Write the artifacts. The city must be laid out;
servedoes that implicitly,city --outdoes not.codegraph city model.jsonl --layout --internal-only --out city.json codegraph navigator model.jsonl --out navigator.json -
Publish them next to the built frontend.
packages/navigator-ui/distloadsnavigator.jsonandcity.jsonfrom beside itsindex.html(the City tab loads the city on first visit). Both accept an explicit URL —?src=URLfor the navigator artifact,?city=URLfor the city — which is how one deployed bundle serves several corpora. The standalone city viewer inpackages/viz/diststill loads acity.json(or?src=URL) on its own.
Both artifacts are plain JSON and deterministic, so they cache well and diff cleanly.