# GatherGate Documentation (Full Agent Reference) > Self-hosted, MIT-licenced magic-link client document intake portal, deterministic validator engine, AES-256-GCM encrypted review vault, signed webhook queue, and built-in stateless MCP 2.0 server. - Quick index: https://gathergate.app/llms.txt - Full documentation: https://gathergate.app/docs/llms-full.txt - Per-page Markdown: append .md to any documentation page slug (for example, https://gathergate.app/docs/guides/ai-agents.md) - Source repository: https://github.com/FAAS19/gathergate - Contact: contact@tensorforge.dev ## Documentation Pages - [GatherGate Documentation](https://gathergate.app/docs/index.md) (HTML: https://gathergate.app/docs/) - Self-hosted, MIT-licenced magic-link client document intake, deterministic validation, and encrypted review vault. - [Quickstart](https://gathergate.app/docs/getting-started/quickstart.md) (HTML: https://gathergate.app/docs/getting-started/quickstart/) - Start GatherGate in under 30 seconds with npx, Docker, Docker Compose, or Node.js from source. - [Configuration (.env) Reference](https://gathergate.app/docs/getting-started/configuration.md) (HTML: https://gathergate.app/docs/getting-started/configuration/) - Every environment variable supported by GatherGate, with defaults and production rules. - [1-Click Self-Hosted Deploy Templates](https://gathergate.app/docs/deployment/one-click-templates.md) (HTML: https://gathergate.app/docs/deployment/one-click-templates/) - Deploy GatherGate on Render, Coolify, Dokploy, Railway, Umbrel, CasaOS, or Fly.io with a persistent /data volume for SQLite WAL and encrypted uploads. - [Reverse Proxy & TLS](https://gathergate.app/docs/deployment/reverse-proxy.md) (HTML: https://gathergate.app/docs/deployment/reverse-proxy/) - Expose GatherGate securely over HTTPS using Caddy, Nginx, or Cloudflare Tunnel. - [Storage Backends (Local & S3 / R2)](https://gathergate.app/docs/deployment/storage.md) (HTML: https://gathergate.app/docs/deployment/storage/) - Configure encrypted local disk storage or S3-compatible object storage (Cloudflare R2, AWS S3, MinIO, Backblaze B2). - [Email Delivery](https://gathergate.app/docs/deployment/email.md) (HTML: https://gathergate.app/docs/deployment/email/) - Configure Local Outbox, SMTP (Gmail, Outlook/M365, Fastmail, SES), or Resend for magic-link invites, OTP codes, and reminders. - [Backups & Upgrading](https://gathergate.app/docs/deployment/backups-and-upgrades.md) (HTML: https://gathergate.app/docs/deployment/backups-and-upgrades/) - Safely back up SQLite WAL databases, protect MASTER_KEY, and upgrade GatherGate without downtime or data loss. - [AI Agents & MCP 2.0](https://gathergate.app/docs/guides/ai-agents.md) (HTML: https://gathergate.app/docs/guides/ai-agents/) - Connect Antigravity, Claude, Cursor, Codex, Copilot, Windsurf, Cline, or Zed to GatherGate's built-in stateless, metadata-only MCP endpoint and bundled SKILL.md. - [Signed Webhooks, Retry Queue & API Keys](https://gathergate.app/docs/guides/webhooks.md) (HTML: https://gathergate.app/docs/guides/webhooks/) - Trigger downstream workflows across 6 request lifecycle events, inspect and replay failed deliveries, and automate securely with scoped workspace API keys. - [Deterministic Validator Packs](https://gathergate.app/docs/guides/validator-packs.md) (HTML: https://gathergate.app/docs/guides/validator-packs/) - Built-in statutory checksum validators across Generic, AU, UK, US, and EU packs, plus how to contribute a new country pack. - [Security & Threat Model](https://gathergate.app/docs/security/architecture.md) (HTML: https://gathergate.app/docs/security/architecture/) - How GatherGate encrypts data at rest, sniffs uploaded files, sandboxes previews, and enforces tenant isolation. --- # GatherGate Documentation > Self-hosted, MIT-licenced magic-link client document intake, deterministic validation, and encrypted review vault. Canonical HTML: https://gathergate.app/docs/ Raw Markdown: https://gathergate.app/docs/index.md GatherGate is a self-hosted, open-source alternative to Content Snare and FileInvite. Collect client documents and structured details through passwordless magic links with deterministic validation, AES-256-GCM encryption at rest, automated reminders, and keyboard-first review in a single Node.js or Docker runtime. - **Runtime**: Node.js `>= 22.13` (Node 24+ recommended for built-in `node:sqlite` and `node:crypto.argon2Sync`), 5 backend production dependencies, zero external database. - **Zero telemetry**: GatherGate never phones home. Outbound network traffic happens only when you configure SMTP/Resend, S3/R2 storage, or webhooks. - [Quickstart (30 seconds)](https://gathergate.app/docs/getting-started/quickstart/): Run GatherGate locally via npx, Docker, or Docker Compose and verify /healthz. - [1-Click Self-Hosted Deploy](https://gathergate.app/docs/deployment/one-click-templates/): Launch on Render, Coolify, Dokploy, Railway, Umbrel, CasaOS, or Fly.io with persistent /data storage. - [AI Agents & MCP 2.0](https://gathergate.app/docs/guides/ai-agents/): Connect Antigravity, Claude, Cursor, Codex, Copilot, Windsurf, Cline, or Zed to POST /mcp without exposing raw IDs, notes, or files. - [Reverse Proxy & TLS](https://gathergate.app/docs/deployment/reverse-proxy/): Put Caddy, Nginx, or Cloudflare Tunnel in front of 127.0.0.1:3080 with TRUST_PROXY. - [Webhooks, Retries & API Keys](https://gathergate.app/docs/guides/webhooks/): Verify 6 signed lifecycle events, inspect dead-letter retries, and mint scoped workspace API keys. > **Reading with an AI agent?** Fetch [`/docs/llms-full.txt`](https://gathergate.app/docs/llms-full.txt) for the full compiled guide, or replace the trailing `/` on any documentation URL with `.md` (for example, `/docs/guides/ai-agents.md`, or `/docs/index.md` for this overview). ## Product Walkthrough Watch the 51-second end-to-end intake flow from passwordless magic link and live ATO ABN checksum validation to AES-256-GCM encryption and keyboard-first review (`Space` / `A` / `R`). - Watch product walkthrough: https://gathergate.app/#watch - Direct MP4 (1080p, 51s): https://gathergate.app/media/gathergate-launch-v2-web.mp4 - English WebVTT captions: https://gathergate.app/media/gathergate-launch-v2.vtt ## Architecture at a Glance | Layer | Implementation | | :--- | :--- | | **HTTP API & SPA** | Hono (`@hono/node-server`) serving the built React 19 + Tailwind CSS v4 frontend | | **Metadata Store** | Built-in `node:sqlite` in WAL mode (`DATA_DIR/gathergate.sqlite`) with versioned migrations | | **Blob Storage** | Encrypted local files (`DATA_DIR/blobs`) or any SigV4 S3/R2/MinIO/B2 bucket (`aws4fetch`) | | **Encryption at Rest** | Per-record HKDF-SHA256 + AES-256-GCM bound with authenticated additional data (AAD) | | **Outbound Email** | Built-in Local Outbox (`console`), SMTP (`nodemailer`), or Resend HTTP API | | **ZIP Export** | Streaming decrypted archive (`yazl`) with `summary.json` and canonicalised `files/` | --- # Quickstart > Start GatherGate in under 30 seconds with npx, Docker, Docker Compose, or Node.js from source. Canonical HTML: https://gathergate.app/docs/getting-started/quickstart/ Raw Markdown: https://gathergate.app/docs/getting-started/quickstart.md GatherGate requires no external database, Redis, or message broker. Pick the runtime that matches your machine or server. ### npx (Node.js 24+) ```bash npx gathergate ``` Runs natively on Node.js `>= 22.13` (Node 24+ recommended), auto-loads `.env` from the working directory, and stores data in `./data` on `http://127.0.0.1:3080`. Useful CLI helpers: `npx gathergate doctor`, `npx gathergate setup --client claude-desktop`, and `npx gathergate mcp`. ### Docker ```bash docker run -d \ --name gathergate \ -p 127.0.0.1:3080:3080 \ -v gathergate_data:/data \ ghcr.io/faas19/gathergate:latest ``` Multi-arch (`linux/amd64` and `linux/arm64`) non-root container image published from GitHub Actions. ### Docker Compose ```bash git clone https://github.com/FAAS19/gathergate.git \ && cd gathergate \ && docker compose up -d --build ``` Hardened container defaults (`cap_drop: [ALL]`, `read_only: true`, `no-new-privileges:true`, bound to `127.0.0.1:3080`). ### From Source ```bash git clone https://github.com/FAAS19/gathergate.git && cd gathergate npm ci npm --prefix client ci npm run build NODE_ENV=production HOST=127.0.0.1 PORT=3080 DATA_DIR=./data npm start ``` ## Verify the Server Confirm the health endpoint returns HTTP `200`, or run the read-only CLI diagnostic: ```bash curl http://127.0.0.1:3080/healthz # {"ok":true,"service":"gathergate"} npx gathergate doctor --url http://127.0.0.1:3080 ``` ## First-Run Setup 1. Open `http://127.0.0.1:3080` in your browser. 2. Complete the split-screen workspace onboarding (workspace name, operator email, password, and optional demo packs). 3. Inspect outgoing magic-link invites and 6-digit OTP codes inside **Local Outbox** (`/outbox`) before connecting SMTP or Resend. > **Production `MASTER_KEY`** > On first boot without `MASTER_KEY` set, GatherGate auto-generates a 32-byte key at `DATA_DIR/.master.key` so quickstarts work immediately. Before storing real client documents, move that value into your environment or secret manager and back it up separately from `DATA_DIR`. ## Next Steps - Prefer a visual overview first? Watch the [51-second product walkthrough](https://gathergate.app/docs/#product-walkthrough). - Set `BASE_URL=https://...` and `TRUST_PROXY=true` behind a [Reverse Proxy & TLS](https://gathergate.app/docs/deployment/reverse-proxy/). - Configure [Storage](https://gathergate.app/docs/deployment/storage/) and [Email Delivery](https://gathergate.app/docs/deployment/email/). - Review all variables in the [Configuration (.env) Reference](https://gathergate.app/docs/getting-started/configuration/). --- # Configuration (.env) Reference > Every environment variable supported by GatherGate, with defaults and production rules. Canonical HTML: https://gathergate.app/docs/getting-started/configuration/ Raw Markdown: https://gathergate.app/docs/getting-started/configuration.md GatherGate reads configuration from environment variables (or `.env` automatically when started with `npx gathergate` / `gathergate serve`, `gathergate doctor`, or `docker compose`). The stdio bridge (`gathergate mcp`) intentionally ignores `.env` files in the working directory. Copy `.env.example` from the repository root to get started. ## Core Server & Security | Variable | Default | Description | | :--- | :--- | :--- | | `HOST` | `127.0.0.1` | Bind address. Keep `127.0.0.1` on hosts and let your reverse proxy terminate TLS. In Docker, `docker-compose.yml` sets `0.0.0.0` inside the container while publishing only `127.0.0.1:3080`. | | `PORT` | `3080` | Listening HTTP port (`0` selects an ephemeral port). | | `BASE_URL` | `http://127.0.0.1:3080` | Public external origin used in magic links, emails, and webhook `export_url` values. When unset, falls back automatically to `RENDER_EXTERNAL_URL`, `https://`, `https://.fly.dev`, or `http://:` (`http://localhost:` for wildcard binds). Must be `https://...` in production so cookies receive the `Secure` attribute. | | `DATA_DIR` | `./data` | Directory holding `gathergate.sqlite` (WAL), encrypted `blobs/` (when `STORAGE_BACKEND=local`), and auto-generated `.master.key` fallback. | | `DB_PATH` | `DATA_DIR/gathergate.sqlite` | Optional explicit path to the SQLite WAL database file. | | `MASTER_KEY` | *(auto-generated)* | 64-character hex string (32 bytes) used for HKDF-SHA256 + AES-256-GCM encryption. Generate with `node -e "console.log(require('node:crypto').randomBytes(32).toString('hex'))"`. | | `TRUST_PROXY` | `false` | Set `true` **only** behind a trusted TLS reverse proxy so per-IP rate limiting reads forwarded client IPs instead of `127.0.0.1`. | | `NODE_ENV` | `development` | Set `production` for hardened production runs. | ## Retention & Background Jobs | Variable | Default | Description | | :--- | :--- | :--- | | `CRON_INTERVAL_MINUTES` | `15` | Cadence for automated reminder chases, overdue pack checks, exponential webhook retries, and expired/completed blob purges. Set `0` to disable the in-process timer. | | `DEFAULT_PURGE_DAYS` | `30` | Days after request completion before encrypted blobs and sensitive fields are purged. Packs using sensitive national ID validators (`au_tfn_mod11`, `au_medicare_mod10`, `uk_nino`, `us_ssn`) automatically default to `14` days. | ## Storage Backend | Variable | Default | Description | | :--- | :--- | :--- | | `STORAGE_BACKEND` | `local` | `local` (encrypted files in `DATA_DIR/blobs`) or `s3` (S3, Cloudflare R2, MinIO, Backblaze B2 via SigV4). | | `S3_ENDPOINT` | *(required for `s3`)* | Base endpoint URL without bucket path (e.g. `https://.r2.cloudflarestorage.com`). | | `S3_REGION` | `auto` | SigV4 signing region (`auto` for R2, `ap-southeast-2` for AWS Sydney, `us-east-1`, etc.). | | `S3_BUCKET` | *(required for `s3`)* | Target bucket name. | | `S3_ACCESS_KEY_ID` | *(required for `s3`)* | Bucket access key ID. | | `S3_SECRET_ACCESS_KEY` | *(required for `s3`)* | Bucket secret access key. | ## Email Delivery (Instance Defaults) Workspace operators can override email settings in-app under **Settings > Email Delivery** (stored encrypted in SQLite). These variables act as instance defaults in single-tenant mode. | Variable | Default | Description | | :--- | :--- | :--- | | `EMAIL_BACKEND` | `console` | `console` (built-in Local Outbox), `smtp`, or `resend`. | | `EMAIL_FROM` | `GatherGate ` | Default `From` header. | | `RESEND_API_KEY` | *(required for `resend`)* | Resend API key (scope to `sending_access` for your domain). | | `SMTP_HOST` | *(required for `smtp`)* | SMTP server hostname. | | `SMTP_PORT` | `587` | SMTP port (`587` STARTTLS or `465` implicit TLS). | | `SMTP_SECURE` | `false` | Set `true` for implicit TLS (port `465`), `false` for STARTTLS (`587`). | | `SMTP_USER` | `""` | SMTP username. | | `SMTP_PASS` | `""` | SMTP password. | ## Tenancy Controls | Variable | Default | Description | | :--- | :--- | :--- | | `MULTI_TENANT` | `false` | `false` = single-workspace self-hosted mode; `true` = enables self-serve workspace signup and strict public-host SSRF guards on webhooks and workspace SMTP. | | `FREE_MAX_ACTIVE_REQUESTS` | `5` | Active request cap when a workspace is on plan `free` (`0` = unlimited). | | `FREE_MAX_STORAGE_BYTES` | `1073741824` | Encrypted blob storage cap in bytes for plan `free` (`1 GiB` default, `0` = unlimited). | --- # 1-Click Self-Hosted Deploy Templates > Deploy GatherGate on Render, Coolify, Dokploy, Railway, Umbrel, CasaOS, or Fly.io with a persistent /data volume for SQLite WAL and encrypted uploads. Canonical HTML: https://gathergate.app/docs/deployment/one-click-templates/ Raw Markdown: https://gathergate.app/docs/deployment/one-click-templates.md GatherGate ships audited deployment manifests under `deploy/` and a root `render.yaml` Blueprint for persistent container hosts. Every template pulls the signed multi-arch container image (`ghcr.io/faas19/gathergate:latest`, `linux/amd64` and `linux/arm64`), mounts persistent storage at `/data`, and runs healthchecks against `GET /healthz`. ## Prerequisites (All Platforms) 1. **Persistent `/data` volume**: Stores `gathergate.sqlite` (SQLite WAL), encrypted local blobs (`DATA_DIR/blobs`), and `.master.key` if `MASTER_KEY` is not yet set in environment variables. 2. **Single replica (`1` instance)**: SQLite WAL and the built-in background cron scheduler (automated reminders, webhook retries, auto-purge) expect one container attached to the `/data` volume. 3. **Production `MASTER_KEY`**: Generate a 64-character hex key once (`openssl rand -hex 32`) and save it in your platform's secret manager alongside a separate offline backup. ## Platform Templates ### Render (Instant Blueprint) GatherGate includes [`render.yaml`](https://github.com/FAAS19/gathergate/blob/main/render.yaml) at the repository root so you can launch directly from GitHub: 1. Open Render Blueprint deploy: `https://render.com/deploy?repo=https://github.com/FAAS19/gathergate` 2. Select a paid web service plan (`starter` or higher, required by Render for persistent disks) with the preconfigured 10 GB disk mounted at `/data`. 3. `BASE_URL` falls back automatically to Render's `RENDER_EXTERNAL_URL` (set `BASE_URL` explicitly if you attach a custom domain). On first boot without `MASTER_KEY`, GatherGate generates `/data/.master.key`; copy that 64-character hex value into a `MASTER_KEY` environment variable (and back it up offline) so existing encrypted records remain readable. 4. Confirm `https:///healthz` returns HTTP `200`, then open `/` for first-run workspace setup. ### Coolify Use [`deploy/coolify/docker-compose.yml`](https://github.com/FAAS19/gathergate/blob/main/deploy/coolify/docker-compose.yml): 1. In Coolify, create **New Resource > Docker Compose Empty** and paste `deploy/coolify/docker-compose.yml`. 2. Assign your HTTPS domain on port `3080` (`SERVICE_URL_GATHERGATE_3080` automatically populates `BASE_URL`). 3. Set `MASTER_KEY` (`openssl rand -hex 32`) in Coolify's **Environment Variables** tab. 4. Click **Deploy** and verify `/healthz`. ### Dokploy Use [`deploy/dokploy/docker-compose.yml`](https://github.com/FAAS19/gathergate/blob/main/deploy/dokploy/docker-compose.yml) and [`deploy/dokploy/template.toml`](https://github.com/FAAS19/gathergate/blob/main/deploy/dokploy/template.toml): 1. In Dokploy, create a new **Compose** service using `deploy/dokploy/docker-compose.yml`. 2. Attach a domain pointing to service `gathergate` on port `3080` with HTTPS enabled. 3. Set `BASE_URL=https://your-domain` and `MASTER_KEY` (`openssl rand -hex 32`) in **Environment**, then deploy. ### Railway Use [`deploy/railway/railway.json`](https://github.com/FAAS19/gathergate/blob/main/deploy/railway/railway.json): 1. Create a new Railway service from `FAAS19/gathergate` using the `DOCKERFILE` builder with Config File Path `/deploy/railway/railway.json` (or deploy `ghcr.io/faas19/gathergate:latest` directly). 2. Add a Railway **Volume** mounted at `/data` and keep **Replicas** set to `1`. 3. Set environment variables: `NODE_ENV=production`, `HOST=0.0.0.0`, `PORT=3080`, `DATA_DIR=/data`, `TRUST_PROXY=true`, and `MASTER_KEY` (`openssl rand -hex 32`). `BASE_URL` automatically falls back to `https://` (or set `BASE_URL` explicitly for a custom domain). The container entrypoint repairs `/data` ownership automatically and drops privileges to non-root UID `1000` (`node`). 4. Configure healthcheck path `/healthz` and expose port `3080`. ### Umbrel Manifests live at [`deploy/umbrel/umbrel-app.yml`](https://github.com/FAAS19/gathergate/blob/main/deploy/umbrel/umbrel-app.yml) and [`deploy/umbrel/docker-compose.yml`](https://github.com/FAAS19/gathergate/blob/main/deploy/umbrel/docker-compose.yml): - Runs as non-root `user: "1000:1000"` (`node:24-alpine`) with `${APP_DATA_DIR}/data:/data` and `app_proxy` routing to `gathergate_web_1:3080`. - `app_proxy` configures `PROXY_AUTH_WHITELIST` strictly for the client magic-link portal (`/c/*`), static bundle assets (`/assets/*`, `/favicon.svg`, `/site.webmanifest`), client API (`/api/client/*`), public workspace logo (`/api/public/*`), Bearer-authenticated MCP (`/mcp`), and `/healthz`. Recipients can open magic links without an Umbrel session (protected by GatherGate's 256-bit magic token and optional 6-digit email OTP) and AI agents can authenticate directly to `POST /mcp` with a scoped Bearer API key (`mcp:read`), while the operator console and REST API routes (`/api/requests*`) remain behind both Umbrel login and GatherGate authentication. - Before creating client checklists, set `BASE_URL` to a reachable origin so generated magic links work from client devices: use `http://:3080` (for example `http://umbrel.local:3080`) for LAN-only access, or your public `https://...` origin behind a TLS reverse proxy (keep direct container access restricted to the trusted proxy whenever `TRUST_PROXY=true`). - Ready for custom Umbrel Community App Stores or upstream submission to `getumbrel/umbrel-apps`. ### CasaOS Import [`deploy/casaos/docker-compose.yml`](https://github.com/FAAS19/gathergate/blob/main/deploy/casaos/docker-compose.yml) via **App Store > Custom Install > Import**: 1. Maps `/DATA/AppData/$AppID/data:/data` and exposes port `3080`. The template retains minimal capabilities (`CHOWN`, `SETUID`, `SETGID`) so GatherGate's entrypoint initialises `/data` ownership automatically and drops to the non-root `node` user (`UID 1000`) with zero manual `chown` step. 2. Set `BASE_URL` (defaults to `http://casaos.local:3080` in the template) to a reachable origin before creating checklists: - **Direct LAN access**: set `BASE_URL=http://:3080` and keep `TRUST_PROXY=false`. - **Public HTTPS behind a reverse proxy** (Caddy, Nginx, or Cloudflare Tunnel): set `BASE_URL=https://intake.yourfirm.com.au` and **first restrict port `3080`** to loopback (`127.0.0.1:3080`), a private proxy network, or a host firewall allowing only the proxy before enabling `TRUST_PROXY=true` (preventing direct callers from spoofing `X-Forwarded-For` to bypass IP rate limits). ### Fly.io Use [`deploy/fly/fly.toml`](https://github.com/FAAS19/gathergate/blob/main/deploy/fly/fly.toml) (replace `your-gathergate-app` and `syd` with your chosen app name and region; `BASE_URL` automatically falls back to `https://.fly.dev` unless overridden): ```bash fly apps create your-gathergate-app fly volumes create gathergate_data --region syd --size 10 -a your-gathergate-app fly secrets set \ MASTER_KEY="$(openssl rand -hex 32)" \ BASE_URL="https://your-gathergate-app.fly.dev" \ -a your-gathergate-app fly deploy -c deploy/fly/fly.toml -a your-gathergate-app ``` `auto_stop_machines = "off"` and `min_machines_running = 1` keep GatherGate's built-in reminder, webhook retry, and auto-purge cron jobs running continuously. ## Why Not Vercel or Stateless Serverless Functions? GatherGate's **backend application** is intentionally designed for a persistent container or Node.js process rather than ephemeral serverless functions (such as Vercel Functions or Netlify Functions): - **Embedded SQLite WAL (`node:sqlite`)**: Requires a single persistent POSIX filesystem (`/data/gathergate.sqlite`) with write-ahead logging. Ephemeral serverless filesystems reset between cold starts and cannot share a local SQLite WAL file across concurrent invocations. - **Encrypted local blob storage (`/data/blobs`)**: Stores AES-256-GCM encrypted client documents on disk when `STORAGE_BACKEND=local`. - **In-process background cron**: Runs scheduled reminder sweeps, exponential webhook retries, overdue detection, and automatic document shredding without external queues or third-party schedulers. Static frontend artefacts (the marketing showcase, interactive browser demo, and Starlight documentation under `site/` and `docs/`) are pure static files and deploy cleanly to **Cloudflare Workers Static Assets**, **GitHub Pages**, or **Vercel**. For the live GatherGate server itself, always choose a persistent host above or a standard VPS with Docker / Node.js 24+. --- # Reverse Proxy & TLS > Expose GatherGate securely over HTTPS using Caddy, Nginx, or Cloudflare Tunnel. Canonical HTML: https://gathergate.app/docs/deployment/reverse-proxy/ Raw Markdown: https://gathergate.app/docs/deployment/reverse-proxy.md Never expose port `3080` directly to the public internet over plain HTTP. Keep GatherGate bound to `127.0.0.1:3080` and terminate TLS at a reverse proxy. ## Required GatherGate Settings Set these two variables in `.env` whenever GatherGate sits behind a reverse proxy: ```dotenv BASE_URL=https://intake.yourfirm.com.au TRUST_PROXY=true ``` - `BASE_URL` starting with `https://` instructs GatherGate to mark `gg_session` and client OTP cookies `Secure` and generate HTTPS magic links. - `TRUST_PROXY=true` allows per-IP rate limiting on `/api/login`, OTP, and uploads to inspect the client IP forwarded by your proxy. > **Never set `TRUST_PROXY=true` without a trusted proxy** > If port `3080` is reachable directly by clients with `TRUST_PROXY=true`, callers can spoof `X-Forwarded-For` headers to bypass IP rate limits. Always bind GatherGate to `127.0.0.1:3080` or an isolated Docker network. ## Proxy Configurations ### Caddy Caddy provisions and renews Let's Encrypt TLS certificates automatically: ```txt title="Caddyfile" intake.yourfirm.com.au { request_body { max_size 64MB } reverse_proxy 127.0.0.1:3080 } ``` ### Nginx Ensure `client_max_body_size` is at least `60m` so GatherGate's 50 MB per-upload limit is not cut off by Nginx's default 1 MB cap: ```nginx server { listen 443 ssl http2; server_name intake.yourfirm.com.au; ssl_certificate /etc/letsencrypt/live/intake.yourfirm.com.au/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/intake.yourfirm.com.au/privkey.pem; client_max_body_size 64m; location / { proxy_pass http://127.0.0.1:3080; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_read_timeout 120s; } } ``` ### Cloudflare Tunnel Cloudflare Tunnel (`cloudflared`) exposes `127.0.0.1:3080` without opening inbound firewall ports: ```yaml # /etc/cloudflared/config.yml tunnel: credentials-file: /etc/cloudflared/.json ingress: - hostname: intake.yourfirm.com.au service: http://127.0.0.1:3080 - service: http_status:404 ``` Remember to set `BASE_URL=https://intake.yourfirm.com.au` and `TRUST_PROXY=true` in GatherGate's `.env`. ## Post-Proxy Checklist 1. Verify `https://intake.yourfirm.com.au/healthz` returns `200 OK`. 2. Open DevTools > Application > Cookies after signing in and confirm `gg_session` has `HttpOnly`, `Secure`, and `SameSite=Lax`. 3. Upload a multi-megabyte PDF to confirm your proxy body size limit allows files up to 50 MB. --- # Storage Backends (Local & S3 / R2) > Configure encrypted local disk storage or S3-compatible object storage (Cloudflare R2, AWS S3, MinIO, Backblaze B2). Canonical HTML: https://gathergate.app/docs/deployment/storage/ Raw Markdown: https://gathergate.app/docs/deployment/storage.md GatherGate encrypts **every uploaded file in memory** using a per-upload HKDF-SHA256 key and AES-256-GCM **before** writing bytes to disk or sending them to S3. Your object bucket never sees plaintext client PDFs or ID scans. ## Option 1: Encrypted Local Disk (Default) No extra configuration is required: ```dotenv STORAGE_BACKEND=local DATA_DIR=/data ``` - SQLite metadata lives at `DATA_DIR/gathergate.sqlite` (WAL mode). - Encrypted file blobs live under `DATA_DIR/blobs/` with file mode `0600`. - When running Docker, always mount a persistent volume or host bind mount at `/data`. ## Option 2: S3-Compatible Storage (Cloudflare R2, AWS S3, MinIO, B2) GatherGate signs requests using AWS Signature Version 4 (`aws4fetch`) with bounded timeouts (`60s` PUT/GET, `15s` DELETE) and 3 retries on transient `5xx`/`429` responses. ### Cloudflare R2 Example ```dotenv STORAGE_BACKEND=s3 S3_ENDPOINT=https://.r2.cloudflarestorage.com S3_REGION=auto S3_BUCKET=gathergate-vault S3_ACCESS_KEY_ID= S3_SECRET_ACCESS_KEY= ``` ### AWS S3 (Sydney `ap-southeast-2`) Example ```dotenv STORAGE_BACKEND=s3 S3_ENDPOINT=https://s3.ap-southeast-2.amazonaws.com S3_REGION=ap-southeast-2 S3_BUCKET=your-firm-gathergate-vault S3_ACCESS_KEY_ID= S3_SECRET_ACCESS_KEY= ``` ### Minimum IAM / Bucket Policy Scope the credentials strictly to the target bucket with only three object actions: - `s3:PutObject` - `s3:GetObject` - `s3:DeleteObject` Disable public bucket access. GatherGate never generates public bucket URLs; operators stream decrypted files exclusively through authenticated `/api/uploads/:id/download` and `/api/requests/:id/export.zip` routes. ### Failure & Atomicity Guarantees - **Startup fail-closed**: If `STORAGE_BACKEND=s3` is set with any missing `S3_*` variable, GatherGate refuses to boot rather than silently falling back to local disk. - **Atomic multi-file uploads**: All files in a multi-file upload are encrypted and written to storage before SQLite rows commit; if any write fails, uploaded blobs are cleaned up automatically. - **Automated purging**: When `purge_at` passes, the background purge sweep issues SigV4 `DELETE` calls to shred expired objects from your bucket. --- # Email Delivery > Configure Local Outbox, SMTP (Gmail, Outlook/M365, Fastmail, SES), or Resend for magic-link invites, OTP codes, and reminders. Canonical HTML: https://gathergate.app/docs/deployment/email/ Raw Markdown: https://gathergate.app/docs/deployment/email.md GatherGate supports three outbound email drivers: **Local Outbox** (`console`), **SMTP**, and **Resend**. You can configure defaults via `.env` or manage per-workspace settings directly in the UI under **Settings > Email Delivery**. ## 1. Local Outbox (`console`, Default) Zero setup required. Outbound invites, 6-digit OTP verification codes, and automated chasers are saved locally in SQLite and viewable in **Local Outbox** (`/outbox`) inside a sandboxed (`sandbox=""`) preview iframe. ```dotenv EMAIL_BACKEND=console EMAIL_FROM=GatherGate ``` Ideal for local evaluation, offline tests, and checking your branded email templates before connecting a live mail provider. ## 2. In-App Configuration (Recommended) Open **Settings > Email Delivery** inside GatherGate: 1. Select **SMTP** (includes presets for Gmail, Outlook / Microsoft 365, Fastmail, Amazon SES, or Custom) or **Resend**. 2. Enter your credentials, `From` address, and optional `Reply-To` address. 3. Click **Save**, then click **Send test email** to verify delivery. Secrets saved through **Settings > Email Delivery** are encrypted at rest with HKDF-SHA256 + AES-256-GCM bound to your workspace ID and are never returned in `GET /api/settings`. ## 3. Environment Variable Defaults ### Resend Use a domain-scoped **Sending access** API key (never a full-access key): ```dotenv EMAIL_BACKEND=resend EMAIL_FROM=Intake RESEND_API_KEY=re_xxxxxxxxxxxxxxxxx ``` ### SMTP ```dotenv EMAIL_BACKEND=smtp EMAIL_FROM=Intake SMTP_HOST=smtp.fastmail.com SMTP_PORT=465 SMTP_SECURE=true SMTP_USER=intake@yourfirm.com.au SMTP_PASS=your-app-password ``` - Use `SMTP_SECURE=true` for implicit TLS (`465`) and `SMTP_SECURE=false` for STARTTLS (`587`). - Ensure SPF, DKIM, and DMARC records are configured on your sending domain so magic-link invites and 6-digit OTP emails land in client inboxes rather than spam. ## Multi-Tenant Email Isolation When `MULTI_TENANT=true`, GatherGate blocks private, loopback, and link-local SMTP hostnames (with DNS resolution checks on both test and live sends) to prevent SSRF, and workspaces cannot inherit host-level SMTP secrets. --- # Backups & Upgrading > Safely back up SQLite WAL databases, protect MASTER_KEY, and upgrade GatherGate without downtime or data loss. Canonical HTML: https://gathergate.app/docs/deployment/backups-and-upgrades/ Raw Markdown: https://gathergate.app/docs/deployment/backups-and-upgrades.md GatherGate keeps all state in two places: your **encryption key** (`MASTER_KEY`) and your **data directory** (`DATA_DIR` + optional S3 bucket). ## Backing Up Safely ### 1. Protect `MASTER_KEY` Separately Without `MASTER_KEY`, encrypted blobs and encrypted SQLite fields (client tax numbers, notes, email credentials, and webhook secrets) cannot be decrypted. Store `MASTER_KEY` in a password manager or secret vault **separate** from your database backups. ### 2. Back Up SQLite WAL Cleanly Because GatherGate runs SQLite in WAL mode (`gathergate.sqlite`, `-wal`, `-shm`), avoid copying the `.sqlite` file directly while writes are active. Use SQLite's online backup API (`VACUUM INTO` or `.backup`) or pause the container briefly: ```bash # Consistent online snapshot via Node.js (no downtime) node -e ' const { DatabaseSync } = require("node:sqlite"); const db = new DatabaseSync("/data/gathergate.sqlite", { readOnly: true }); db.exec("VACUUM INTO '\''/backups/gathergate-" + new Date().toISOString().slice(0,10) + ".sqlite'\''"); db.close(); ' ``` If using `STORAGE_BACKEND=local`, also back up `DATA_DIR/blobs/`. If using `STORAGE_BACKEND=s3`, enable bucket versioning or lifecycle backups on your S3/R2 bucket. ## Upgrading GatherGate SQLite migrations in GatherGate are **append-only, versioned, and idempotent** (`schema_migrations` + `PRAGMA user_version`). On startup, GatherGate applies any pending migrations automatically inside transactions and fails closed if a database is newer than the binary version. ### Docker Upgrade ```bash # 1. Take a snapshot backup first docker pull ghcr.io/faas19/gathergate:latest docker stop gathergate && docker rm gathergate docker run -d \ --name gathergate \ -p 127.0.0.1:3080:3080 \ -v gathergate_data:/data \ --env-file .env \ ghcr.io/faas19/gathergate:latest ``` ### `npx` Upgrade ```bash npx gathergate@latest ``` ### Verify After Upgrade ```bash curl http://127.0.0.1:3080/healthz ``` Confirm logs show no migration errors and sign in to verify existing requests remain accessible. --- # AI Agents & MCP 2.0 > Connect Antigravity, Claude, Cursor, Codex, Copilot, Windsurf, Cline, or Zed to GatherGate's built-in stateless, metadata-only MCP endpoint and bundled SKILL.md. Canonical HTML: https://gathergate.app/docs/guides/ai-agents/ Raw Markdown: https://gathergate.app/docs/guides/ai-agents.md GatherGate ships with a **built-in stateless MCP 2.0 server** at `POST /mcp` and a bundled **Agent Skill (`SKILL.md`, `SEP-2640`)**. Because everything runs inside your own GatherGate container or Node.js process, AI agents can create checklists, triage overdue packs, adjust deadlines, and send follow-up reminders **100% offline/self-hosted** with zero external SaaS dependencies. ## Strict Metadata-Only Security Boundary GatherGate's MCP endpoint is **metadata-only by design**, strictly separating workflow triage from raw client submissions: - **What MCP tools return**: Request titles, statuses, deadlines, item completion counts, validator keys, operator `review_url` deep links, `client_name` (for non-purged requests; `null` once purged), and masked client emails (`cl***@example.com.au`, or `***@domain` for 1-2 character local parts). - **Never exposed to LLMs**: Decrypted national IDs (TFN, Medicare, NINO, SSN), any submitted item text values, client notes, uploaded file names, raw file bytes, download/ZIP streams, workspace secrets (SMTP/Resend/webhook keys), and raw client magic-link tokens (`/c/`). - **Human-in-the-loop review**: Every pack summary returns an operator `review_url` (`https://your-host/requests/`). Agents direct humans to inspect uploaded documents or reveal masked IDs inside GatherGate's browser `ReviewSheet`. - **Bearer-only + Origin-checked**: `POST /mcp` requires a scoped workspace API key (`Authorization: Bearer gg_live_...`), rejects session cookies (eliminating CSRF), enforces `Origin` validation when present, and logs all mutations under `actor: "api_key"` in `audit_events`. ## Step 1: Mint a Scoped API Key 1. Open your GatherGate instance and navigate to **Settings > API Keys**. 2. Create a key with the minimum scopes your agent needs: - **Read-only triage**: `mcp:read` - **Create packs, update due dates, and chase clients**: `mcp:read` + `requests:write` 3. Copy the `gg_live_...` secret once and export it in your shell or secret manager as `GATHERGATE_API_KEY`. > **Never paste API keys into prompts or committed config files** > Reference `GATHERGATE_API_KEY` via environment variables or editor secret inputs instead of hardcoding `gg_live_...` tokens in shared repositories. ## Zero-Docker CLI Setup (`npx gathergate`) GatherGate ships three built-in CLI helpers (zero extra dependencies, works without Docker): ```bash # 1. Verify Node runtime, DATA_DIR, SQLite header, /healthz, and authenticated POST /mcp npx gathergate doctor --url https://intake.yourfirm.com.au # 2. Print MCP client config for any supported tool (add --write for JSON configs; claude-code prints a CLI command and codex prints TOML) npx gathergate setup --client claude-desktop --url https://intake.yourfirm.com.au --write # 3. Run the built-in stdio-to-HTTP MCP bridge (zero mcp-remote needed) GATHERGATE_URL=https://intake.yourfirm.com.au GATHERGATE_API_KEY=gg_live_... npx gathergate mcp ``` Both `doctor` and `mcp` require `https://` before transmitting `GATHERGATE_API_KEY` to non-loopback hosts (`http://` is permitted only on `localhost`, `127.0.0.1`, and `[::1]`), disable HTTP redirects (`redirect: "error"`), and never echo secrets into reports or `stderr`. ## Step 2: Connect Your AI Agent Replace `https://intake.yourfirm.com.au/mcp` with your GatherGate base URL (`http://127.0.0.1:3080/mcp` for local setups). You can generate any tab below automatically with `npx gathergate setup --client --url `. ### Antigravity Add GatherGate to your Antigravity MCP configuration (`mcp_config.json`): ```json { "mcpServers": { "gathergate": { "serverUrl": "https://intake.yourfirm.com.au/mcp", "headers": { "Authorization": "Bearer ${env:GATHERGATE_API_KEY}" } } } } ``` GatherGate also advertises `skill://gathergate/SKILL.md` over MCP (`SEP-2640`), or you can install the local skill folder directly from `skills/gathergate/SKILL.md` in the repository. ### Claude Code Register the remote Streamable HTTP server via CLI: ```bash claude mcp add --transport http gathergate \ https://intake.yourfirm.com.au/mcp \ --header "Authorization: Bearer $GATHERGATE_API_KEY" ``` Optionally install the bundled skill so Claude Code loads workflow guidance automatically: ```bash npx skills add FAAS19/gathergate ``` ### Claude Desktop For native remote connectors (Settings > Connectors), add `https://intake.yourfirm.com.au/mcp` with header `Authorization: Bearer `. Or use GatherGate's built-in stdio bridge directly inside `claude_desktop_config.json` (zero `mcp-remote` required; run `npx gathergate setup --client claude-desktop --url https://intake.yourfirm.com.au --write` to merge it safely): ```json { "mcpServers": { "gathergate": { "command": "npx", "args": ["-y", "gathergate", "mcp"], "env": { "GATHERGATE_URL": "https://intake.yourfirm.com.au", "GATHERGATE_API_KEY": "gg_live_replace_me" } } } } ``` ### Cursor Add to `.cursor/mcp.json` (project) or `~/.cursor/mcp.json` (global): ```json { "mcpServers": { "gathergate": { "url": "https://intake.yourfirm.com.au/mcp", "headers": { "Authorization": "Bearer ${env:GATHERGATE_API_KEY}" } } } } ``` ### Codex Add to `~/.codex/config.toml`: ```toml [mcp_servers.gathergate] url = "https://intake.yourfirm.com.au/mcp" bearer_token_env_var = "GATHERGATE_API_KEY" ``` ### GitHub Copilot (VS Code) Add to `.vscode/mcp.json`: ```json { "inputs": [ { "type": "promptString", "id": "gathergate_api_key", "description": "GatherGate workspace API key (gg_live_...)", "password": true } ], "servers": { "gathergate": { "type": "http", "url": "https://intake.yourfirm.com.au/mcp", "headers": { "Authorization": "Bearer ${input:gathergate_api_key}" } } } } ``` ### Windsurf Add to `~/.codeium/windsurf/mcp_config.json`: ```json { "mcpServers": { "gathergate": { "serverUrl": "https://intake.yourfirm.com.au/mcp", "headers": { "Authorization": "Bearer ${env:GATHERGATE_API_KEY}" } } } } ``` ### Cline Add to `cline_mcp_settings.json`: ```json { "mcpServers": { "gathergate": { "type": "streamableHttp", "url": "https://intake.yourfirm.com.au/mcp", "headers": { "Authorization": "Bearer ${env:GATHERGATE_API_KEY}" } } } } ``` ### Zed Add to Zed `settings.json` (or run `npx gathergate setup --client zed --url https://intake.yourfirm.com.au --write`; pass `--transport stdio` for the local `npx -y gathergate mcp` stdio entry): ```json { "context_servers": { "gathergate": { "url": "https://intake.yourfirm.com.au/mcp", "headers": { "Authorization": "Bearer gg_live_replace_me" } } } } ``` ## Bundled Agent Skill (`SKILL.md` / `SEP-2640`) GatherGate advertises the `io.modelcontextprotocol/skills` extension (`SEP-2640`) in both `server/discover` and legacy `initialize` capabilities. Hosts can inspect digests and pull progressive-disclosure Markdown files on demand: - `skills/list` and `skills/get` return `frontmatter` plus SHA-256 `digest` and byte `size` for each skill resource. - `resources/read` serves: - `skill://gathergate/SKILL.md` (core operator workflows and zero-PII rules) - `skill://gathergate/references/intake-workflows.md` (AU/UK/US/EU packs, OTP defaults, partial submissions) - `skill://gathergate/references/security-boundary.md` (scopes, masking, and audit trail) For agents that read skills from disk, the exact same files live at `skills/gathergate/` in `FAAS19/gathergate` and inside the published `gathergate` npm package. ## Tool Reference | Tool | Required Scope | Behaviour | | :--- | :--- | :--- | | `list_templates` | `mcp:read` | Lists workspace templates, item counts, validator keys, and sensitivity flags. | | `list_requests` | `mcp:read` | Lists active/closed packs with `client_name` (non-purged), masked emails (`cl***@example.com.au`), item counts, and `review_url`. | | `get_request_status` | `mcp:read` | Returns pack metadata (`client_name` for non-purged packs, masked email), per-item status (`pending`, `submitted`, `approved`, `rejected`), `has_value`, `has_client_note`, `upload_count`, and `review_url`. | | `list_overdue_requests` | `mcp:read` | Lists overdue packs (or packs due within `within_days` `0..30`) with `client_name` (non-purged), masked email, and outstanding item labels. | | `create_request` | `requests:write` | Creates a checklist from a workspace template and optionally emails the client invite. Never returns the raw client magic token. | | `send_reminder` | `requests:write` | Sends a polite manual reminder for outstanding items, enforcing the 15-minute cooldown and per-request concurrency lock. | | `update_due_date` | `requests:write` | Updates or clears `due_at` on an active pack. | ## Protocol Versions & Quick Smoke Check GatherGate supports both **MCP `2026-07-28`** (stateless `server/discover`, `resultType: "complete"`, `Mcp-Method`/`Mcp-Name` header validation, `ttlMs`/`cacheScope`) and legacy revisions (`2025-11-25`, `2025-06-18`, `2025-03-26`, `2024-11-05`). Verify your live endpoint with `npx gathergate doctor` or `curl`: ```bash GATHERGATE_API_KEY=gg_live_... npx gathergate doctor --url https://intake.yourfirm.com.au curl -sS -X POST https://intake.yourfirm.com.au/mcp \ -H "Authorization: Bearer $GATHERGATE_API_KEY" \ -H "Content-Type: application/json" \ -H "MCP-Protocol-Version: 2026-07-28" \ -H "Mcp-Method: server/discover" \ -d '{"jsonrpc":"2.0","id":1,"method":"server/discover"}' ``` ## Reading GatherGate Docs from Agents Every page on `gathergate.app/docs/` is also served as clean raw Markdown by replacing its trailing `/` with `.md` (or fetching `/docs/index.md` for the overview), and the complete documentation is compiled into a single file: - Concise install index: `https://gathergate.app/llms.txt` - Full agent documentation: `https://gathergate.app/docs/llms-full.txt` - This page as raw Markdown: `https://gathergate.app/docs/guides/ai-agents.md` --- # Signed Webhooks, Retry Queue & API Keys > Trigger downstream workflows across 6 request lifecycle events, inspect and replay failed deliveries, and automate securely with scoped workspace API keys. Canonical HTML: https://gathergate.app/docs/guides/webhooks/ Raw Markdown: https://gathergate.app/docs/guides/webhooks.md GatherGate sends HMAC-SHA256 signed HTTP `POST` JSON webhooks to your workspace's configured **Webhook URL** (**Settings > Webhooks**) across the full request lifecycle, backed by a durable SQLite retry queue and dead-letter replay log. ## Supported Webhook Events | Event | Trigger | | :--- | :--- | | `request.opened` | Client opens a magic-link checklist for the first time (recorded atomically once per request). | | `item.submitted` | Client submits a text answer, uploads a file, or marks an optional item Not applicable. | | `request.in_review` | All required items are submitted and the pack enters operator review. | | `request.completed` | Operator approves the final required item and the pack reaches `completed`. | | `request.overdue` | Active pack passes its `due_at` deadline during the scheduled sweep (deduplicated per deadline). | | `request.purged` | Encrypted payload and uploaded blobs are shredded after retention expiry (prior `webhook_deliveries` payloads are shredded first, then a minimal metadata-only `request.purged` event is queued and dispatched). | The test button in **Settings > Webhooks** sends `X-GatherGate-Event: webhook.test`. ## Security Design - **Encrypted signing secret**: Your webhook secret is encrypted at rest with HKDF-SHA256 + AES-256-GCM in SQLite. - **Masked sensitive IDs**: Sensitive national IDs (`au_tfn_mod11`, `au_medicare_mod10`, `uk_nino`, `us_ssn`) are **always masked** in webhook payloads (e.g. `****** 789`). Raw sensitive values are never broadcast to third-party automation endpoints. - **DNS-pinned delivery & zero redirects**: Outbound requests use `redirect: "error"` and a 10-second timeout. In `MULTI_TENANT=true`, private, loopback, and link-local IP ranges are blocked after DNS resolution and connections pin directly to verified public IPs (mitigating DNS rebinding). - **Pre-purge shredding**: When a request is purged, its prior stored `webhook_deliveries` payload rows are shredded from SQLite first, then a minimal metadata-only `request.purged` event is inserted and dispatched. ## Durable Retry Queue & Manual Replay Every lifecycle event is written to the `webhook_deliveries` table in SQLite before dispatch: - **5 exponential retries**: Transient 5xx, 429, timeout, or network failures automatically retry at **1 minute, 5 minutes, 15 minutes, 1 hour, and 6 hours** (6 total attempts). - **Dead-letter queue**: Exhausted deliveries move to `dead_letter`. - **Inspect & replay**: Filter recent deliveries in **Settings > Webhooks** (`All`, `Dead letter`, `Retrying`, `Delivered`) and trigger one-click **Replay** (the session-authenticated API `GET /api/settings/webhook/deliveries?status=...` also accepts `pending` and `in_flight`, alongside `POST /api/settings/webhook/deliveries/:id/replay`). ## Request Headers Every delivery includes these headers: ```http Content-Type: application/json User-Agent: GatherGate/1.1 (TensorForge; contact@tensorforge.dev) X-GatherGate-Event: request.completed X-GatherGate-Delivery: whd_01J... X-GatherGate-Timestamp: 1764240000 X-GatherGate-Signature: t=1764240000,v1= ``` Use `X-GatherGate-Delivery` as your idempotency key so retried deliveries never duplicate downstream work. ## Payload Shape (`request.completed`) ```json { "event": "request.completed", "timestamp": "2026-11-27T10:00:00.000Z", "workspace": { "id": "ws_...", "name": "Harbour Advisory" }, "request": { "id": "req_...", "title": "FY26 Individual Tax Return Pack", "client_name": "Claire Nguyen", "client_email": "claire@example.com.au", "completed_at": "2026-11-27T10:00:00.000Z", "purge_at": "2026-12-11T10:00:00.000Z", "export_url": "https://intake.yourfirm.com.au/api/requests/req_.../export.zip" }, "items": [ { "id": "itm_...", "section": "Identity & ATO Details", "label": "Tax File Number (TFN)", "kind": "text", "validator": "au_tfn_mod11", "status": "approved", "value": "****** 789", "client_na": false, "client_note": null, "files": [] } ] } ``` ## Verifying the Signature (Node.js / n8n Code Node) Compute `HMAC-SHA256(secret, "${timestamp}.${rawBody}")`, verify timestamp freshness (within 5 minutes), and compare using `crypto.timingSafeEqual`: ```js import crypto from "node:crypto"; export function verifyGatherGateWebhook(rawBody, signatureHeader, secret, maxAgeSec = 300) { if (!signatureHeader || !secret) return false; const parts = Object.fromEntries( signatureHeader.split(",").map((kv) => kv.split("=").map((s) => s.trim())) ); const ts = Number(parts.t); const v1 = parts.v1; if (!Number.isFinite(ts) || !v1 || !/^[0-9a-f]{64}$/i.test(v1)) return false; if (Math.abs(Math.floor(Date.now() / 1000) - ts) > maxAgeSec) return false; const expected = crypto .createHmac("sha256", secret) .update(`${parts.t}.${rawBody}`) .digest("hex"); const a = Buffer.from(v1, "hex"); const b = Buffer.from(expected, "hex"); return a.length === b.length && crypto.timingSafeEqual(a, b); } ``` ### Using with n8n 1. Add a **Webhook** trigger node (`POST`, Raw Body enabled under Options). 2. Add a **Code** node immediately after it running the signature check against `$env.GATHERGATE_WEBHOOK_SECRET`, deduplicating on `X-GatherGate-Delivery`, and failing closed on mismatch. 3. Route verified events (`request.completed`, `request.overdue`, `item.submitted`) to Slack, Xero, Cliniko, or your document management system. ## Scoped Workspace API Keys For headless automation and n8n HTTP Request nodes, create least-privilege Bearer tokens (`gg_live_...`) under **Settings > API Keys**: | Scope | Permitted Operations | | :--- | :--- | | `templates:read` | `GET /api/templates` | | `requests:read` | `GET /api/requests`, `GET /api/requests/:id`, `GET /api/clients`, `GET /api/validators` (sensitive IDs remain masked; `portal_url`, `portalUrl`, and `demoPortalUrl` are redacted unless the key also holds `requests:write`) | | `requests:write` | `POST /api/requests`, `PATCH /api/requests/:id`, `POST /api/requests/:id/items`, `POST /api/requests/:id/items/:itemId/review`, `POST /api/requests/:id/approve-all-submitted`, `POST /api/requests/:id/remind-now`, `POST /api/requests/:id/toggle-reminders`, `POST /api/requests/bulk-reminders` | | `mcp:read` | Access `POST /mcp` read tools and bundled `SKILL.md` resources (combine with `requests:write` for MCP write tools) | Keys are stored strictly as SHA-256 hashes (shown once at creation), support optional expiry dates and instant revocation, and are blocked from session-only routes (Settings, API key management, raw sensitive ID reveal, file downloads, and `export.zip`). --- # Deterministic Validator Packs > Built-in statutory checksum validators across Generic, AU, UK, US, and EU packs, plus how to contribute a new country pack. Canonical HTML: https://gathergate.app/docs/guides/validator-packs/ Raw Markdown: https://gathergate.app/docs/guides/validator-packs.md GatherGate validates structured text fields deterministically on **every** client submission before saving. Bad checksums are rejected immediately in the client portal with actionable feedback, and unknown validator keys always **fail closed**. ## Built-In Packs ### Generic (`generic`) | Key | Check & Normalisation | Masked | | :--- | :--- | :---: | | `none` | Any non-empty text | No | | `email` | RFC-style email format, lowercased | No | | `url` | Valid `http://` or `https://` URL | No | | `phone_e164` | International E.164 (`+[1-9]`, 8 to 15 digits) | No | | `iban` | ISO 13616 `mod-97` checksum, 4-char spaced groups | No | ### Australia (`au`) | Key | Check & Normalisation | Masked | | :--- | :--- | :---: | | `au_abn_mod89` | 11-digit ATO ABN `mod-89` checksum (`XX XXX XXX XXX`) | No | | `au_bsb` | 6-digit Australian BSB (`XXX-XXX`) | No | | `au_phone_e164` | AU mobile/landline normalised to `+61` E.164 | No | | `au_tfn_mod11` | 8 or 9-digit ATO TFN `mod-11` checksum | **Yes** | | `au_medicare_mod10` | 10 or 11-digit Services Australia Medicare + IRN `mod-10` | **Yes** | ### United Kingdom (`uk`) | Key | Check & Normalisation | Masked | | :--- | :--- | :---: | | `uk_utr_mod11` | 10-digit HMRC Unique Taxpayer Reference `mod-11` | No | | `uk_sort_code` | 6-digit UK Bank Sort Code (`XX-XX-XX`, rejects `00-00-00`) | No | | `uk_nino` | UK National Insurance format & prefix exclusions | **Yes** | ### United States (`us`) | Key | Check & Normalisation | Masked | | :--- | :--- | :---: | | `us_ein` | 9-digit IRS EIN with valid campus prefix (`XX-XXXXXXX`) | No | | `us_routing_aba` | 9-digit Federal Reserve ABA routing `mod-10` | No | | `us_ssn` | 9-digit SSA area, group, and serial rules | **Yes** | ### European Union (`eu`) | Key | Check & Normalisation | Masked | | :--- | :--- | :---: | | `eu_vat` | All 27 EU member-state patterns + BE (`mod-97`), DE (ISO 7064 `mod 11,10`), and FR (`mod-97`) checksums | No | ## Sensitive Field Behaviour Any validator marked `sensitive: true`: 1. Triggers a **14-day default auto-purge** window (instead of 30 days) on requests using it. 2. Stays masked (`****** 789`) in operator lists and API detail responses until an authenticated operator triggers an audited reveal. Lifecycle webhooks always carry the masked value and are not affected by a reveal. ## Contributing a Country Validator Pack Validator packs live in `src/validators/packs/` and require zero external dependencies: 1. Create `src/validators/packs/.ts` exporting a `ValidatorPack` (see `src/validators/packs/types.ts`). 2. Register the pack in `VALIDATOR_PACKS` inside `src/validators/index.ts`. 3. Add user-facing selector options in `client/src/lib/api.ts` (`VALIDATOR_OPTIONS`) and mirror the pure checksum in `client/src/lib/demo-validators.ts`. 4. Add unit tests for valid inputs, invalid checksums, normalisation, and masking in `tests/validator-packs.test.ts`. 5. Run the verification gate (`npm run typecheck && npm run build && npm test`) and open a PR against `main`. --- # Security & Threat Model > How GatherGate encrypts data at rest, sniffs uploaded files, sandboxes previews, and enforces tenant isolation. Canonical HTML: https://gathergate.app/docs/security/architecture/ Raw Markdown: https://gathergate.app/docs/security/architecture.md GatherGate is designed for practices handling regulated identity, tax, financial, and clinical records on their own infrastructure. ## Protections Built In ### 1. Per-Record Encryption at Rest - Uploaded files, sensitive text fields, client notes, workspace email credentials, and webhook signing secrets are encrypted with **AES-256-GCM**. - Every record derives its own unique 256-bit key via **HKDF-SHA256** from `MASTER_KEY` and binds the ciphertext to its record/workspace ID using **authenticated additional data (AAD)**. - Tampering with ciphertext or swapping encrypted values across rows fails authentication immediately. - Uploaded blobs record `enc_version = "v1"` in SQLite for future key-rotation workflows. ### 2. Fail-Closed Magic-Byte File Sniffing Every upload is inspected by binary signature (`src/security/magic-bytes.ts`), never just file extension or `Content-Type`: - **Allowed**: `PDF`, `PNG`, `JPEG`, `WebP`, `DOCX`, `XLSX`, `CSV`, `TXT`. - **Blocked**: Spoofed executables, HTML/JavaScript masquerading as images, HTML/script tags disguised as CSV/TXT, arbitrary ZIPs, and SVG workspace logos (preventing stored XSS via embedded `