# 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 - Single-admin browser session with bcrypt-hashed credentials - Long-lived bearer API token for Android and other sync clients - Embedded SvelteKit dashboard - Idempotent PostgreSQL schema initialization ## Quick start with Docker ```bash docker build -t collabtable-server . docker run -d --name collabtable-server --restart unless-stopped \ -p 3000:3000 \ -e DATABASE_URL=postgres://user:password@host:5432/collabtable \ -e COOKIE_SECURE=false \ collabtable-server ``` Open `http://localhost:3000` to create the administrator account. Generate an API token from 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 cd webui npm ci npm run check npm run build cd .. Copy-Item -Recurse -Force webui/build web go build -o collabtable-server . ``` The Dockerfile performs those dashboard and Go build steps automatically. ## API All Android synchronization routes are prefixed with `/api/` and require: ```text Authorization: Bearer ``` 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` Browser authentication uses the `collabtable_session` HTTP-only cookie. There is one admin account per database. API tokens are hashed at rest and shown only when generated. ### 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=` ### 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 - `PORT` — HTTP port, default `3000` - `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 - `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