2026-08-03 18:07:40 +02:00
|
|
|
# CollabTable Server
|
|
|
|
|
|
|
|
|
|
The CollabTable backend is a small Go `net/http` service backed by PostgreSQL. It serves the
|
|
|
|
|
Svelte dashboard and the Android synchronization API from one container.
|
|
|
|
|
|
|
|
|
|
## Features
|
|
|
|
|
|
|
|
|
|
- REST API for lists, fields, items, and item values
|
|
|
|
|
- Transactional HTTP synchronization with soft-delete tombstones
|
|
|
|
|
- Notification polling for background refreshes
|
2026-09-01 01:34:48 +02:00
|
|
|
- Multi-user browser sessions (with per-account roles/admin user management) authenticated
|
|
|
|
|
through AuthGuard, a centralized identity service shared across projects (optional -- see
|
|
|
|
|
`AUTHGUARD_URL` below)
|
|
|
|
|
- Long-lived bearer API token for Android and other sync clients (independent of AuthGuard)
|
2026-08-03 18:07:40 +02:00
|
|
|
- Embedded SvelteKit dashboard
|
|
|
|
|
- Idempotent PostgreSQL schema initialization
|
|
|
|
|
|
|
|
|
|
## Quick start with Docker
|
|
|
|
|
|
|
|
|
|
```bash
|
2026-08-03 22:40:08 +02:00
|
|
|
cd ..
|
|
|
|
|
docker build -f docker/Dockerfile -t collabtable-server .
|
2026-08-03 18:07:40 +02:00
|
|
|
docker run -d --name collabtable-server --restart unless-stopped \
|
2026-09-08 17:05:34 +02:00
|
|
|
-p 8080:8080 \
|
2026-08-03 18:07:40 +02:00
|
|
|
-e DATABASE_URL=postgres://user:password@host:5432/collabtable \
|
2026-09-01 01:34:48 +02:00
|
|
|
-e AUTHGUARD_URL=https://auth.example.com \
|
2026-08-03 18:07:40 +02:00
|
|
|
-e COOKIE_SECURE=false \
|
|
|
|
|
collabtable-server
|
|
|
|
|
```
|
|
|
|
|
|
2026-09-08 17:05:34 +02:00
|
|
|
Open `http://localhost:8080` to create the first account. Generate an API token from
|
2026-08-03 18:07:40 +02:00
|
|
|
the dashboard's Settings menu and enter it in the Android app.
|
|
|
|
|
|
|
|
|
|
## Local development
|
|
|
|
|
|
|
|
|
|
The backend requires Go 1.26+ and PostgreSQL. The dashboard requires Node.js 22+.
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
cp .env.example .env
|
|
|
|
|
go test ./...
|
|
|
|
|
go run .
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
To build the dashboard for the embedded production binary:
|
|
|
|
|
|
|
|
|
|
```bash
|
2026-08-03 22:40:08 +02:00
|
|
|
cd ../frontend
|
2026-08-03 18:07:40 +02:00
|
|
|
npm ci
|
|
|
|
|
npm run check
|
|
|
|
|
npm run build
|
|
|
|
|
cd ..
|
2026-08-03 22:40:08 +02:00
|
|
|
Copy-Item -Recurse -Force frontend/build backend/web
|
|
|
|
|
go -C backend build -o collabtable-server .
|
2026-08-03 18:07:40 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The Dockerfile performs those dashboard and Go build steps automatically.
|
|
|
|
|
|
|
|
|
|
## API
|
|
|
|
|
|
|
|
|
|
All Android synchronization routes are prefixed with `/api/` and require:
|
|
|
|
|
|
|
|
|
|
```text
|
|
|
|
|
Authorization: Bearer <api-token>
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
The Android app also sends `x-device-id`, which is used to avoid showing a device its own
|
|
|
|
|
notification events.
|
|
|
|
|
|
|
|
|
|
### Authentication
|
|
|
|
|
|
|
|
|
|
- `GET /api/auth/status`
|
|
|
|
|
- `POST /api/auth/setup`
|
|
|
|
|
- `POST /api/auth/login`
|
|
|
|
|
- `POST /api/auth/logout`
|
|
|
|
|
- `POST /api/auth/credentials`
|
|
|
|
|
- `GET /api/auth/token/status`
|
|
|
|
|
- `POST /api/auth/token/regenerate`
|
|
|
|
|
|
2026-09-01 01:34:48 +02:00
|
|
|
Browser authentication proxies to AuthGuard (`AUTHGUARD_URL`), which sets and reads its own
|
|
|
|
|
`auth_session` HTTP-only cookie; CollabTable itself mints no session token. Any number of
|
|
|
|
|
accounts can exist, with `user`/`admin`/`superadmin` roles managed via `/api/auth/users`.
|
|
|
|
|
`AUTHGUARD_URL` is optional: leaving it unset disables authentication entirely (no login
|
|
|
|
|
screen, nothing gated) rather than falling back to any local account store -- only use that for
|
|
|
|
|
local development or a deployment you are certain does not need access control. API tokens are
|
|
|
|
|
unrelated to AuthGuard (see below), hashed at rest, and shown only when generated.
|
2026-08-03 18:07:40 +02:00
|
|
|
|
|
|
|
|
### Data
|
|
|
|
|
|
|
|
|
|
- `GET|POST /api/lists`
|
|
|
|
|
- `GET|PUT|DELETE /api/lists/:id`
|
|
|
|
|
- `GET /api/fields/list/:listId`
|
|
|
|
|
- `POST /api/fields`
|
|
|
|
|
- `PUT|DELETE /api/fields/:id`
|
|
|
|
|
- `GET /api/items/list/:listId`
|
|
|
|
|
- `GET /api/items/:itemId/values`
|
|
|
|
|
- `POST /api/items`
|
|
|
|
|
- `POST /api/items/values`
|
|
|
|
|
- `PUT|DELETE /api/items/:id`
|
|
|
|
|
- `POST /api/sync`
|
|
|
|
|
- `GET /api/notifications/poll?since=<timestamp-ms>`
|
|
|
|
|
|
|
|
|
|
### Dashboard and health
|
|
|
|
|
|
|
|
|
|
- `GET /health` is public.
|
|
|
|
|
- `GET /web/data` requires the admin session.
|
|
|
|
|
- `GET /web/info` requires the admin session.
|
|
|
|
|
- `/`, `/about`, and `/lists/:id` serve the embedded dashboard SPA.
|
|
|
|
|
|
|
|
|
|
## Environment variables
|
|
|
|
|
|
2026-09-08 17:05:34 +02:00
|
|
|
- `PORT` — HTTP port, default `8080`
|
2026-08-03 18:07:40 +02:00
|
|
|
- `APP_VERSION` — optional version displayed in the dashboard, default `dev`
|
|
|
|
|
- `COOKIE_SECURE` — set to `true` when served over HTTPS
|
|
|
|
|
- `DATABASE_URL` — PostgreSQL connection string, required
|
2026-09-01 01:34:48 +02:00
|
|
|
- `AUTHGUARD_URL` — base URL of the AuthGuard identity service CollabTable authenticates
|
|
|
|
|
against, default unset (auth disabled). Leaving it unset does not fall back to any local
|
|
|
|
|
account store -- it disables authentication entirely, treating every request as
|
|
|
|
|
authenticated with nothing gated.
|
2026-08-03 18:07:40 +02:00
|
|
|
- `DB_INIT_RETRY_INTERVAL_MS` — startup retry delay, default `5000`
|
|
|
|
|
- `DB_INIT_RETRY_MAX_ATTEMPTS` — maximum startup attempts, `0` retries forever
|
|
|
|
|
- `SYNC_MAX_FUTURE_SKEW_MS` — allowed client timestamp skew, default `0`
|
|
|
|
|
- `NOTIF_RETENTION_MS` — notification retention period, default seven days
|
|
|
|
|
|
|
|
|
|
The Go server initializes the existing CollabTable tables in place, so switching from the
|
|
|
|
|
previous server does not require a data export or schema conversion.
|
|
|
|
|
|
|
|
|
|
## License
|
|
|
|
|
|
|
|
|
|
MIT
|