Two servers
Two servers run side by side behind Caddy, sharing one PostgreSQL database and one Redis.
| Server | Language | Owns |
|---|---|---|
apps/server |
Node | The Socket.IO gateway, Messenger, conversations, games, calls, uploads, Zone |
retro-core |
Rust | Logon, sessions, accounts and settings, files, Retro Mail |
Caddy sends retro-core’s routes to it, and everything else, including Socket.IO, to Node.
There is no fallback: while retro-core is down, logon fails. Every retro-core response
has an x-retro-server: core header.
Who writes what
Section titled “Who writes what”Each table has one writer, so the two never race:
retro-corewrites sessions, logon’s account rows, passkeys, recovery codes, the security log, files and Retro Mail.- Node writes everything else, and reads what
retro-corewrote.
The bridge
Section titled “The bridge”The servers talk through Redis, in both directions.
Rust to the browser. retro-core publishes events on <prefix>core:events. Node’s
gateway forwards them to the right sockets: log-offs, fsChanged, new mail. When retro-core
rotates a session, it publishes rekey and Node moves the device’s sockets to the new id.
Browser to Rust. A few socket calls are answered by Rust. CORE_CALL_NAMES in
packages/protocol/src/core-calls.ts lists them (the mail:* calls). Node checks the
session, rate limits and payload, pushes the request on <prefix>core:calls, and waits up
to 5 seconds for Rust’s reply on <prefix>core:replies:<node id>. The reply can join and
leave rooms and send events; Node applies them, then answers the browser.
Scaling
Section titled “Scaling”Node is stateless: run any number behind a load balancer. The Socket.IO Redis adapter delivers events across nodes, and presence is checked across all of them.