The parts of an install
This page is for owners who want a map of their server. After reading it you can name every program an install runs, say which one talks to which, and know what the internet can reach.
An install is one server running a set of programs side by side with Docker Compose. Each program runs in its own container: a sealed box with only the files and settings that program needs. The list of containers, and how they connect, is one file on your server, /opt/blackbranch/compose.yaml. The values and secrets they use are in /opt/blackbranch/.env beside it.
Installing is covered in Installing, and day-to-day care in Running your install.
The parts at a glance
| Part | What it is | What it does |
|---|---|---|
| web | The website, built with Next.js | Every page viewers see, the Admin Panel, the setup pages, sign-in, the store and checkout, and the Stripe and PayPal webhooks |
| stream-api | The central service (Node.js), called the chat service in these docs | Takes in chat, gives every person one identity, keeps the money ledger, fires alerts, runs polls and the timer, holds the settings, serves the OBS overlays, and sends live updates to every open page over a WebSocket |
| stream-ingest | The chat reader (Node.js), called the ingest service in these docs | Connects to Twitch, Kick, YouTube and Streamplace, reads their chat and paid events, turns each one into one common shape and hands it to stream-api. It also runs the AI features: the chat bot, automod, the help desk and memory |
| postgres | The database (PostgreSQL with the pgvector add-on) | Holds three databases: stream (the platform's own data), and synapse and mas (the chat server's). pgvector stores and searches the number lists that memory uses |
| migrate | A one-shot job | Runs at every start, before the programs that use the database. It builds the database on a new install, or applies newer changes to an existing one, then exits. See Updates and the database |
| synapse | The homeserver (Synapse) | Runs your community rooms and direct messages on the Matrix standard |
| mas | The sign-in service (MAS) | Handles every account and every sign-in, for the website and for Matrix apps alike |
| caddy | The router (Caddy) | The only part that faces the internet. It reads which address each request is for and passes it to web, stream-api or the homeserver |
| cloudflared | The tunnel (Cloudflare's connector) | Runs only in tunnel mode, the default. It dials out to Cloudflare and brings visitors' requests back to caddy, so your server needs no open ports |
| backup, backup-verify, backup-restore | One-shot jobs | Make, check and restore backups. They run only when the nightly timer or the blackbranch command calls them |
What runs in Docker and what runs on the server itself
Every program in the table runs in a container, from a pinned image. The server has no Node.js, no Postgres and no web server of its own. When the host command needs to run platform code (the Doctor's checks, or checking an update's signature), it starts a short-lived container and runs the code there.
A few small pieces live on the server itself, because they manage the containers from outside:
| On the server | What it is | Why it is not in a container |
|---|---|---|
| Docker Engine and the Compose plugin | Installed by the installer from Docker's own package repository, if missing. Compose 2.20 or newer is needed | It is what runs the containers |
/usr/local/bin/blackbranch |
The host command, a Bash script | It starts, stops, backs up and updates the containers. A container that could do that would need full control of Docker |
| systemd units | The request watcher (blackbranch-requests.path, below), timers for the nightly backup, the weekly restore check and the nightly update check, the update services, and blackbranch-reconcile.service, which finishes an update cut off by a power loss at the next boot |
They run on a schedule or at boot, whether or not any container is up |
| A few standard packages | ca-certificates, curl, rsync, openssl and unattended-upgrades (security updates for the server's own system) |
The installer and the host command use them |
/opt/blackbranch/ |
The install's folder: .env, compose.yaml, the releases, generated configuration, and backups if you keep them locally |
Plain files the containers mount |
So the platform relies on Linux in a narrow way. The installer supports Debian stable and Ubuntu LTS on x86-64, and uses apt and systemd. The containers would run on any Docker host, but the installer, the host command, the timers and the request watcher are written for that kind of system, and nothing else is supported. See What you need.
Who talks to whom
flowchart LR
subgraph Internet
V[Viewer's browser]
OBS[OBS browser source]
P[Twitch, Kick, YouTube, Streamplace]
PAY[Stripe, PayPal, Ko-fi, Patreon]
AI[Your AI provider]
end
CF[Cloudflare tunnel]
subgraph Server
C[caddy]
W[web]
A[stream-api]
I[stream-ingest]
S[synapse]
M[mas]
DB[(postgres)]
end
V --> CF
OBS --> CF
PAY -- webhooks --> CF
CF --> C
C -- example.com --> W
C -- api.example.com --> A
C -- matrix.example.com --> S
C -- matrix.example.com/auth --> M
I -- reads chat --> P
I -- chat, events --> A
I -- model calls --> AI
W -- secret-signed calls --> A
W --> DB
A --> DB
S --> DB
M --> DB
W -- admin API, inside only --> M
🖼 Image: the same diagram drawn as a clean figure, with the three public addresses labelled on the router.
What the arrows mean:
- stream-ingest has no database password. It reads its settings from stream-api and sends everything it hears to stream-api. That keeps one program, stream-api, in charge of writing chat, identities and money.
- web reads the database directly, but anything that must happen once and in order (a chat message, a payment's effects, joining two identities) goes through stream-api. web calls it inside the server and signs every call with a shared secret that only the two of them hold. stream-api refuses an internal request without it.
- Only stream-api can read stored credentials. Keys you paste into the Admin Panel are stored encrypted, and only stream-api holds the key that opens them. web and stream-ingest ask stream-api for the ones they need. See Credentials.
- The browser talks to three addresses: the site itself for pages,
api.example.comfor the live WebSocket, andmatrix.example.comfor the community rooms and sign-in. - OBS loads its overlays and the rig page from
api.example.comand keeps a WebSocket open there, the same way a browser does.
Each container is given only the values it reads, listed one by one in compose.yaml. No container gets the whole .env file, so no program holds a secret it has no use for.
What the internet can reach
Your domain is used under three names. Everything else on the server answers only inside its private Docker network.
| Address | Goes to | What is there |
|---|---|---|
example.com |
web | Every page, the site's /api/… addresses, the Stripe and PayPal webhooks, and the Matrix discovery files under /.well-known/matrix/ that tell Matrix apps where the homeserver is |
api.example.com |
stream-api | The live WebSocket, the OBS overlays, and the Ko-fi and Patreon webhooks. Every other address there needs the shared secret, so a stranger gets "unauthorized" |
matrix.example.com |
synapse, and mas under /auth |
The Matrix client API and the sign-in pages. The federation paths answer "not found" while federation is off, which is the default |
Not reachable from outside at all: the database, stream-ingest, the sign-in service's admin API (it listens on an internal port the router never routes), and the backup jobs. The security side of this is in Security for owners.
The front door
How visitors reach caddy depends on the front door you chose at install:
| Mode | How it works | Certificates |
|---|---|---|
tunnel (default) |
cloudflared dials out to Cloudflare. Visitors connect to Cloudflare, and Cloudflare sends their requests down that connection. No ports are opened on your server or router | Cloudflare's, at Cloudflare's edge. Inside the server the traffic is plain HTTP |
direct |
caddy takes ports 80 and 443 on the server itself | caddy gets them from Let's Encrypt by itself |
internal |
Lab mode for a test box, never for a real site | caddy makes its own, which no browser trusts until you add them by hand |
The visitor's real address
Some limits count per visitor address, such as how many live connections one address may open. Behind a tunnel, every request arrives from cloudflared, so the real address is passed along in a header. A header can be faked, so each step believes it from one sender only: caddy believes Cloudflare's header only when it comes from cloudflared inside the server, and stream-api believes caddy's only when it comes from caddy. caddy writes the header fresh on every request, so a visitor cannot pick their own address.
How the site asks the server for things
Some jobs only the server itself can do: restart a container, rewrite the homeserver's settings, run a backup, apply an update. The website is never given control of Docker, because a website that could start containers could take over the whole server.
Instead, the site drops a file with a fixed name into /opt/blackbranch/requests/, such as restart-web.req or backup.req. A systemd watcher on the server sees it, runs the one matching action, deletes the request and writes the answer into /opt/blackbranch/results/. Only the server's administrator account can write there; the site can only read. A name the watcher does not know is refused and logged. This is how the Admin Panel's Restart buttons, the federation switch, the Doctor's Check again and the update Apply button work. A backup on demand is a server command: sudo blackbranch backup.
Where data lives
| Data | Where |
|---|---|
| Chat, identities, the money ledger, points, settings | The stream database, in two groups of tables: stream.* (written by stream-api) and site.* (the website's own: accounts, subscriptions, the store, settings) |
| Community rooms, direct messages, the homeserver's signing key, uploaded media | The synapse database and the synapse-data volume |
| Accounts and sign-in sessions | The mas database |
| Your secrets | .env and matrix/mas-keys.yaml in /opt/blackbranch/ |
| Text-to-speech scratch files | The media volume |
What a backup includes is in Backups and restore. What is stored about viewers is in What is stored.
Next: How chat flows