Deployment with Workspaces
Everything in the core deployment, plus workspaces: shared storage for your team's documents, sign-in through your organization's identity provider, and live sessions that only people who have signed in can join.
Documents are kept on your server as the editor sends them. The server, and whoever administers it, can read them, so this deployment belongs inside your own network and its database and backups need the protection the documents do. How your work is protected explains this for your users.
You'll end up with
https://design.example.gov/ the editor
https://design.example.gov/docs/ this documentation
wss://design.example.gov/relay/ the relay, for live sessions
https://design.example.gov/store/ the workspace store
https://design.example.gov/auth/ Keycloak - only if you run it herePlan for about twenty minutes.
1. Before you start
Everything the core deployment needs - Docker with Compose v2, a DNS name, a TLS certificate, ports 80 and 443 - plus somewhere for people to sign in. Either:
- Your organization's identity provider - Keycloak, Entra ID, Okta, Auth0, GitLab or Google; anything that speaks OpenID Connect. Recommended for production: people sign in with the accounts they already have.
- Keycloak, run here alongside everything else. Good when you have no provider, or for evaluating. You then manage its users yourself.
Decide now; step 4 differs between them.
You also need to know who will administer it. Administrators create workspaces and decide what is kept. The simplest way to name them is a group in your provider; step 4 sets that up.
2. Create a folder with the files
mkdir system-design && cd system-design
mkdir certs# Engineers Notebook - with workspaces: shared team storage on your server.
#
# One domain, one TLS proxy:
# https://<DOMAIN>/ the editor (and its documentation at /docs/)
# wss://<DOMAIN>/relay/ the relay, for live sessions
# https://<DOMAIN>/store/ the workspace store
#
# The store keeps documents as the editor sends them, so this server and
# whoever administers it can read them. Protect it, its database and its
# backups as you would the documents. Sign-in uses your identity provider;
# to run one here instead, add compose.keycloak.yml (see the setup guide).
name: system-design
services:
editor:
image: ghcr.io/jbraunsmajr/system-design:${VERSION:-latest}
restart: unless-stopped
# If you are using self-signed certs
#volumes:
# - ./certs:/certs:ro
environment:
APP_URL: https://${DOMAIN:?Set DOMAIN in .env}/
RELAY: wss://${DOMAIN}/relay/
STORE_URL: https://${DOMAIN}/store
ICE_SERVERS: ${ICE_SERVERS:-}
# If you are using self-signed certs
# NODE_EXTRA_CA_CERTS: /certs/your-ca.crt
relay:
image: ghcr.io/jbraunsmajr/system-design-relay:${VERSION:-latest}
restart: unless-stopped
# If you are using self-signed certs, mount the certs
#volumes:
# - ./certs:/certs:ro
environment:
# The same value as the store's: the relay then admits only people the
# store has let into a session.
RELAY_TOKEN_SECRET: ${RELAY_TOKEN_SECRET:?Set RELAY_TOKEN_SECRET in .env}
# If you are using self-signed certs
# NODE_EXTRA_CA_CERTS: /certs/your-ca.crt
store:
image: ghcr.io/jbraunsmajr/system-design-store:${VERSION:-latest}
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
environment:
PUBLIC_URL: https://${DOMAIN}/store
AFTER_LOGIN_URL: https://${DOMAIN}/
DATABASE_URL: postgresql://store:${POSTGRES_PASSWORD:?Set POSTGRES_PASSWORD in .env}@postgres:5432/store
AUTH_PROVIDERS: oidc
OIDC_ISSUER: ${OIDC_ISSUER:?Set OIDC_ISSUER in .env}
OIDC_INTERNAL_URL: ${OIDC_INTERNAL_URL:-}
OIDC_CLIENT_ID: ${OIDC_CLIENT_ID:?Set OIDC_CLIENT_ID in .env}
OIDC_CLIENT_SECRET: ${OIDC_CLIENT_SECRET:?Set OIDC_CLIENT_SECRET in .env}
# The ID-token claim that lists a person's groups. Workspace roles
# and ADMIN_GROUPS are matched against it.
OIDC_GROUPS_CLAIM: ${OIDC_GROUPS_CLAIM:-groups}
RELAY_TOKEN_SECRET: ${RELAY_TOKEN_SECRET}
# Who administers the store: members of these groups, and anyone
# listed by issuer#subject. Without either, nobody can create a
# workspace.
ADMIN_GROUPS: ${ADMIN_GROUPS:-}
ADMIN_SUBJECTS: ${ADMIN_SUBJECTS:-}
# admins: only administrators create workspaces. anyone: anyone signed in.
WORKSPACE_CREATION: ${WORKSPACE_CREATION:-admins}
RETENTION_PERIOD: ${RETENTION_PERIOD:-30d}
# If you are using self-signed certs, mount your certificates and specify the CA here
# NODE_EXTRA_CA_CERTS: /certs/your-ca.crt
# If you are using self-signed certs, mount the certs
#volumes:
# - ./certs:/certs:ro
postgres:
image: postgres:16-alpine
restart: unless-stopped
environment:
POSTGRES_USER: store
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: store
volumes:
- store-data:/var/lib/postgresql/data
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U store']
interval: 5s
timeout: 5s
retries: 10
proxy:
image: nginx:alpine
restart: unless-stopped
ports:
- '80:80'
- '443:443'
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
- ./certs:/etc/nginx/certs:ro
depends_on:
- editor
- relay
- store
volumes:
store-data:# TLS termination for the Engineers Notebook, with workspaces.
# Mounted into the proxy container as /etc/nginx/conf.d/default.conf.
# WebSocket upgrades for the relay.
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# Plain HTTP only redirects.
server {
listen 80;
server_name _;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name _;
# Your certificate and key, in ./certs beside this file.
ssl_certificate /etc/nginx/certs/fullchain.pem;
ssl_certificate_key /etc/nginx/certs/privkey.pem;
# The relay. The trailing slashes strip /relay/ before it reaches the
# relay, so /relay/health is the relay's /health. This matches RELAY in
# compose.yml (wss://<domain>/relay/).
location /relay/ {
# If the "relay" name does not resolve on your host, use the host
# machine's IP address in its place.
proxy_pass http://relay:4444/;
# WebSockets need HTTP/1.1 to the upstream; without this line the
# upgrade is dropped and live sessions never connect.
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
# Sessions stay open while people work; don't cut them off.
proxy_read_timeout 1h;
proxy_send_timeout 1h;
}
# The workspace store. /store/v1/... reaches the store as /v1/....
location /store/ {
# If the "store" name does not resolve on your host, use the host
# machine's IP address in its place.
proxy_pass http://store:8080/;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# Document updates are uploaded in pieces of up to 8 MB.
client_max_body_size 16m;
}
# Keycloak, only if you run it here (compose.keycloak.yml). The address
# is in a variable so nginx looks the name up when a request arrives,
# through Docker's own DNS at 127.0.0.11. Written as a plain
# "proxy_pass http://keycloak:8080;" nginx would look it up at start
# and refuse to start at all when Keycloak is not part of the
# deployment (Option A).
#
# Keycloak listens on 8080 and serves under /auth itself
# (KC_HTTP_RELATIVE_PATH in compose.keycloak.yml), so the path is passed
# through unchanged.
location /auth/ {
resolver 127.0.0.11 valid=30s ipv6=off;
set $keycloak http://keycloak:8080;
proxy_pass $keycloak;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Keycloak's sign-in responses carry large headers.
proxy_buffer_size 16k;
proxy_buffers 8 16k;
}
# The editor, and its documentation at /docs/. It is served at the root:
# APP_URL and AFTER_LOGIN_URL in compose.yml are https://<domain>/. To
# serve it under a prefix instead, change this location and those two
# values together.
location / {
# If the "editor" name does not resolve on your host, use the host
# machine's IP address in its place.
proxy_pass http://editor:80;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}# ── Where ──────────────────────────────────────────────────────────────
# The name people will type to reach the editor. Point its DNS at this host.
DOMAIN=design.example.gov
# "latest" follows each release; a date such as 2026-09-21 pins one.
VERSION=latest
# ── Secrets ────────────────────────────────────────────────────────────
# Generate each with: openssl rand -hex 32
POSTGRES_PASSWORD=
RELAY_TOKEN_SECRET=
OIDC_CLIENT_SECRET=
# ── Sign-in ────────────────────────────────────────────────────────────
# Option A - your organization's provider (Keycloak, Entra ID, Okta, ...).
# The issuer URL is the one that serves /.well-known/openid-configuration.
OIDC_ISSUER=https://login.example.gov/realms/yourrealm
OIDC_CLIENT_ID=system-design-store
# This is meant to be the docker network based route, bypass the domain and such if needed
OIDC_INTERNAL_URL=
# Option B - Keycloak run here (compose.keycloak.yml). Replace the three
# lines above with these, and set the two passwords.
# OIDC_ISSUER=https://design.example.gov/auth/realms/system-design
# OIDC_CLIENT_ID=system-design-store
# OIDC_INTERNAL_URL=http://keycloak:8080
# KEYCLOAK_ADMIN_PASSWORD=
# KEYCLOAK_DB_PASSWORD=
# The ID-token claim that lists a person's groups.
OIDC_GROUPS_CLAIM=groups
# ── Who administers the store ──────────────────────────────────────────
# Administrators create workspaces, can manage every workspace, and decide
# what is kept. Name one or more groups from your provider, comma separated,
# exactly as they appear in the groups claim - with Keycloak's full group
# paths, that includes the leading slash. With Keycloak run here, the realm
# file creates this group; put yourself in it (step 7 of the guide).
ADMIN_GROUPS=/notebook-admins
# Or name people one by one, as issuer#subject, comma separated. Used as
# well as the groups above. Leave empty if groups are enough.
ADMIN_SUBJECTS=
# admins: only administrators create workspaces. anyone: anyone signed in.
WORKSPACE_CREATION=admins
# How long deleted documents stay restorable: immediate, 30d, 6m, 7y,
# or indefinite. Set this to your records schedule before the first
# document is stored.
RETENTION_PERIOD=30d
# Only for networks where browsers cannot reach each other directly.
ICE_SERVERS=If you will run Keycloak here, also create these two:
# Optional: run Keycloak here as the identity provider, at https://<DOMAIN>/auth/.
# Use it with: docker compose -f compose.yml -f compose.keycloak.yml up -d
#
# Skip this file entirely if your organization already has a provider.
services:
keycloak:
image: quay.io/keycloak/keycloak:26.0
restart: unless-stopped
command: start --import-realm
depends_on:
keycloak-db:
condition: service_healthy
environment:
KC_BOOTSTRAP_ADMIN_USERNAME: admin
KC_BOOTSTRAP_ADMIN_PASSWORD: ${KEYCLOAK_ADMIN_PASSWORD:?Set KEYCLOAK_ADMIN_PASSWORD in .env}
KC_DB: postgres
KC_DB_URL: jdbc:postgresql://keycloak-db:5432/keycloak
KC_DB_USERNAME: keycloak
KC_DB_PASSWORD: ${KEYCLOAK_DB_PASSWORD:?Set KEYCLOAK_DB_PASSWORD in .env}
# Served behind the proxy at /auth/, and told so, so the addresses it
# hands out are the ones browsers can reach.
KC_HOSTNAME: ${DOMAIN}
# These notes are assuming keycloak is hosted on the same machine as everything else.
# This value will depend on the reverse proxy configuration.
# For instance, if this is hosted on `example.com` your proxy might take `/auth` url and forward it to keycloak.
# example.com/auth.
# It is NOT recommended to strip the path from the URL at the proxy
KC_HTTP_RELATIVE_PATH: /auth
KC_HTTP_ENABLED: 'true'
KC_PROXY_HEADERS: xforwarded
KC_HEALTH_ENABLED: 'true'
# Read by keycloak-realm.json when it is imported.
DOMAIN: ${DOMAIN}
OIDC_CLIENT_SECRET: ${OIDC_CLIENT_SECRET}
# If you are using self-signed certificates, you can use the following to trust them.
# KC_TRUSTSTORE_PATHS: /certs
volumes:
- ./keycloak-realm.json:/opt/keycloak/data/import/system-design-realm.json:ro
# Mount self-signed certificates
# - ./certs:/certs:ro
keycloak-db:
image: postgres:16-alpine
restart: unless-stopped
environment:
POSTGRES_USER: keycloak
POSTGRES_PASSWORD: ${KEYCLOAK_DB_PASSWORD}
POSTGRES_DB: keycloak
volumes:
- keycloak-data:/var/lib/postgresql/data
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U keycloak']
interval: 5s
timeout: 5s
retries: 10
proxy:
depends_on:
- keycloak
volumes:
keycloak-data:{
"realm": "system-design",
"enabled": true,
"sslRequired": "external",
"registrationAllowed": false,
"loginWithEmailAllowed": true,
"clients": [
{
"clientId": "system-design-store",
"name": "Engineers Notebook Workspace",
"enabled": true,
"protocol": "openid-connect",
"publicClient": false,
"secret": "${OIDC_CLIENT_SECRET}",
"standardFlowEnabled": true,
"directAccessGrantsEnabled": false,
"serviceAccountsEnabled": false,
"redirectUris": ["https://${DOMAIN}/store/v1/auth/callback"],
"webOrigins": ["https://${DOMAIN}"],
"attributes": {
"pkce.code.challenge.method": "S256"
},
"protocolMappers": [
{
"name": "groups",
"protocol": "openid-connect",
"protocolMapper": "oidc-group-membership-mapper",
"consentRequired": false,
"config": {
"claim.name": "groups",
"full.path": "true",
"id.token.claim": "true",
"access.token.claim": "false",
"userinfo.token.claim": "true",
"introspection.token.claim": "true"
}
}
]
}
],
"groups": [
{
"name": "notebook-admins"
}
]
}3. Set your domain and generate the secrets
In .env, set DOMAIN to your name. Then fill in the three secrets with long random values. This prints them ready to paste:
for name in POSTGRES_PASSWORD RELAY_TOKEN_SECRET OIDC_CLIENT_SECRET; do
echo "$name=$(openssl rand -hex 32)"
doneKeep .env private
It holds the database password and the secret that controls who can join a session. chmod 600 .env, and keep it out of version control.
4. Connect sign-in and name the administrators
Option A - your organization's provider
Register the workspace with your provider as a confidential client:
| Setting | Value |
|---|---|
| Client ID | system-design-store (or anything; match OIDC_CLIENT_ID. This example value comes from the keycloak-realm.json) |
| Client type | Confidential, with a client secret |
| Client secret | The OIDC_CLIENT_SECRET from your .env |
| Redirect URI | https://design.example.gov/store/v1/auth/callback |
| Flow | Authorization Code, with PKCE |
| Scopes | openid profile |
Then set OIDC_ISSUER in .env to your provider's issuer - the URL that serves /.well-known/openid-configuration. For Keycloak that is https://<keycloak>/realms/<realm>. Leave OIDC_INTERNAL_URL empty.
Put groups in the ID token. Workspaces give roles to groups, and administrators are usually named by group, so the store needs each person's groups at sign-in. Add a mapper or claim that lists them in the ID token under the name groups (or set OIDC_GROUPS_CLAIM to the name your provider uses). Groups and Roles has the steps for Keycloak and what to check for other providers.
Name the administrators. In .env, set ADMIN_GROUPS to a group whose members should administer the store, spelled exactly as it appears in the token, and make sure you are in it.
Check the issuer before going further
curl https://login.example.gov/realms/yourrealm/.well-known/openid-configurationIf that doesn't return JSON from this server, the store won't reach it either.
Option B - Keycloak, run here
In .env, replace the three Option A lines with the Option B ones, and set KEYCLOAK_ADMIN_PASSWORD and KEYCLOAK_DB_PASSWORD (the loop from step 3 works for these too). Nothing else to edit: the realm file reads your domain and client secret when Keycloak imports it, puts each person's groups in their token, and creates the group notebook-admins, which .env already names in ADMIN_GROUPS as /notebook-admins. Keycloak reports groups by their full path, so group names here start with a slash.
You'll add people to Keycloak, and yourself to that group, in step 7.
5. Add your certificate
As in the core deployment: certs/fullchain.pem and certs/privkey.pem.
6. Start it
If people cannot see each other in a session
In an air-gapped network it has been observed that sessions sometimes fail to connect with RELAY_TOKEN_SECRET set. If two people have the same document open and do not appear to each other, comment RELAY_TOKEN_SECRET out of both the store and relay services to confirm that is the cause. Documents still save and merge through the store without a session.
Leaving it out has a cost: the relay then admits anyone on your network who knows a session's room and key, including someone since removed from a workspace. See Workspace Store.
docker compose up -ddocker compose -f compose.yml -f compose.keycloak.yml up -dWith Keycloak, give it a minute on first start: it builds itself and imports the realm.
7. Check it works
curl https://design.example.gov/store/v1/healthYou should see:
{
"status": "ok",
"authentication": "required",
"relayAuthentication": "required"
}| If you see | It means |
|---|---|
"relayAuthentication":"none" | RELAY_TOKEN_SECRET is empty in .env. |
| No response | docker compose logs store - the store says what is wrong and stops, rather than starting misconfigured. |
Then check the workspace service itself:
curl https://design.example.gov/store/v2/health{ "status": "ok", "mode": "trusted" }A 404 here means the store image is older than this guide. Pull the current one.
Option B only - add people. Open https://design.example.gov/auth/admin (this depends on your proxy: the example forwards /auth to Keycloak), sign in as admin with KEYCLOAK_ADMIN_PASSWORD, and switch to the system-design realm.
- Under Users, add each person. Give them an email address, marked verified: Keycloak will otherwise interrupt their first sign-in to ask for one.
- Open your own user, choose Groups, and join
notebook-admins. - Under Groups, create a group for each team (such as
platform-eng) and add its people. You will give these groups roles in step 8, where this one is typed/platform-eng.
8. Sign in and create a workspace
- Open
https://design.example.gov, then File → Documents, and choose Sign in. - In the Workspaces panel, choose New workspace and name it for a team. If the button is not there, you are not an administrator yet: see the box below.
- Choose Members, then under Groups type the team's group exactly as your provider reports it (
/platform-engwith Keycloak), pick a role, and choose Add group. Everyone in that group has the workspace the next time they sign in. Nobody approves them. - Open a diagram and choose Add a copy to … to put the first document in.
No "New workspace" button?
The store decides who is an administrator when you sign in. Open https://design.example.gov/store/v2/me: isAdmin should be true and groups should list your groups.
groupsis empty - your provider is not putting groups in the ID token, or uses another claim name. See Groups and Roles.- Your group is there but spelled differently from
ADMIN_GROUPS- for examplenotebook-adminswithout the leading slash. Copy it from here into.envexactly, thendocker compose up -d store. - You changed your groups after signing in - sign out and in again. Groups are read at sign-in.
9. Invite your team
Send people the address. Anyone in a group you mapped signs in and finds the workspace. For someone outside those groups, an owner adds them by name from Members; they appear in the search once they have signed in for the first time. Workspaces is the guide to give them.
Keeping it running
| Task | Command |
|---|---|
| See what is running | docker compose ps |
| Read the logs | docker compose logs -f store |
| Update to the newest release | docker compose pull && docker compose up -d |
With Keycloak, add -f compose.yml -f compose.keycloak.yml to each.
Backups
Back up the store-data volume - and keycloak-data if you run Keycloak - like any PostgreSQL database:
docker compose exec postgres pg_dump -U store store > store-$(date +%F).sqlThe database holds every document in readable form. Encrypt the backups and restrict who can reach them, as you would for the documents themselves.
Next
- Administering Workspaces - archiving, retention, legal holds, and the audit trail.
- Groups and Roles - getting groups into the token, and how roles are decided.
- Workspace Store - every setting, including retention and running more than one instance.