WebMCP production-scheduling sandbox. Anyone can open the workspace without an account: inspect the synthetic factory, optimize an isolated scenario, compare it to the committed baseline, and request human approval. Agents cannot commit.
npm install
cp .env.example .env.local # set BETTER_AUTH_SECRET
npm run db:migrate
npm run devOpen http://localhost:3000. Sandbox is at /workspace.
Production is a long-lived Node process (npm start) with SQLite on a host volume. One instance.
- Create one Application resource using this Dockerfile. Do not create a Coolify Database resource or a second container.
- Add Persistent Storage with destination
/data, as a directory. A bind mount such as/var/lib/takt_shift→/datakeeps the SQLite file on the host. Never mounttakt.dbas a single file. - Set
DATABASE_URL=file:/data/takt.db,PORT=3000,BETTER_AUTH_URLto the public origin, andBETTER_AUTH_SECRETas a Coolify secret. - Run one instance. Disable rolling or zero-downtime deployments so two processes never write the same SQLite file. Preview deployments must not mount the production volume.
server.mjs still migrates on boot in production, before the container starts listening. The /data directory is the durable store; the database is not baked into the image.
Before changing the auth configuration, inspect the incoming x-forwarded-for chain on the deployed instance. Watch the Coolify application/container logs while making requests, or perform a one-off observation of the request headers that Coolify/Traefik/Caddy injects at the app boundary. Record the observed chain and its proxy addresses before making any trust decision.
Success means that deployed logs no longer show Rate limiting could not determine a client IP and is falling back to a single shared per-path bucket, and sign-in attempts from two different client IPs are rate-limited independently.
- If the observed chain is single-hop, Better Auth's default already resolves the client IP; no code change is needed.
- If Coolify produces a multi-hop chain, configure Better Auth's
advanced.ipAddress.trustedProxieswith the exact proxy address(es) observed. Use named hops only: never trust broad CIDRs and never widen the accepted forwarded headers. - Any
trustedProxiesvalue must be an exact address recorded in this README at the time it is added. Coolify has not been observed here, so no addresses are invented andsrc/server/auth.tsmust remain unchanged until that observation is recorded.
The /data bind mount is durable, not recoverable. Use SQLite's online backup, never a raw copy of a live database:
sqlite3 /data/takt.db ".backup /backups/takt-<timestamp>.db"Store backups outside the app's /data mount, for example in /var/backups/takt_shift on the host. The command must run where sqlite3 can see the live file. With the directory bind mount /var/lib/takt_shift → /data, the live file is at /var/lib/takt_shift/takt.db on the host, so prefer running the backup there so it does not require a second container:
sqlite3 /var/lib/takt_shift/takt.db ".backup /var/backups/takt_shift/takt-<timestamp>.db"Schedule it daily with a Coolify scheduled task or host cron on the bind-mount directory, and retain a rotating set of the last 7 daily backups. Do not add a second container, a Coolify Database resource, or another lockfile. better-sqlite3 also writes takt.db-wal and takt.db-shm; .backup captures the database consistently. Never run cp takt.db while the app is running.
- Stop the single app instance (instances = 1); do not run two writers.
- Replace
takt.dbon the mount with the backup file. - Remove stale
takt.db-walandtakt.db-shmsiblings. - Start the instance. Boot migrates, then serves.
- Confirm that a previously signed-up user still has their committed revision and baseline.
No .db file or .env.local is ever committed. A volume is not a backup. Preview deployments must not mount the production volume.
npx tsc --noEmit
npm run check
npx tsx verify/run-all.ts