{"path":"README.md","content":"# cf-durable-whiteboard\n\nRealtime collaborative whiteboard on Cloudflare. It shows one Durable Object per board, the SQLite storage API, WebSocket Hibernation and presence.\n\n[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/nexarq-ai/cf-durable-whiteboard)\n\n## What it shows\n- One `Board` Durable Object per board id, with SQLite tables `shapes` and `ops`.\n- WebSocket Hibernation (`ctx.acceptWebSocket`, `serializeAttachment`).\n- Presence and live cursors (relayed, never stored).\n- Per-user undo/redo applied on the server as inverse ops.\n- Tools: pen (3 sizes, 8 colours), rectangle, ellipse, arrow, sticky note, eraser, select/move, pan, zoom 10-400 %. PNG export is rendered client-side.\n\n```mermaid\nflowchart LR\n  B[Browser] -->|static| A[Assets]\n  B -->|GET /ws/:id upgrade| W[Worker]\n  B -->|GET /api/boards/:id| W\n  W --> D[(Board Durable Object<br/>SQLite + hibernating WebSockets)]\n  D -->|op, cursor, peer events| B\n```\n\n## Local dev\n```\nnpm install\nnpm run dev\n```\nHealth check: `GET /health`. Board page: `/b/<id>`. Open it in two browsers to see shapes and cursors sync.\n\n## Tests\n```\nnpm test\nnpm run typecheck\n```\nPure logic lives in `src/lib/` and is tested in Node with Vitest; the Durable Object is tested through hand-written fakes.\n\n## Configuration\n`wrangler.jsonc` defines the `assets` binding, the `Board` Durable Object binding with a `new_sqlite_classes` migration, and `staging` / `production` environments that repeat every binding. A `previews` block serves Worker Previews. Placeholder resource ids, if any, must be replaced with your own before deploying.\n\nLimits: messages over 32 KB are rejected; each socket has a token bucket (60 msgs/s, burst 120) and is closed with 1008 after repeated abuse; the last 500 ops per board are kept.\n\n## Deploy\n```\nnpm run deploy            # top-level\nnpm run deploy:staging\nnpx wrangler deploy --env production\n```\n\n## Costs\nWorkers and Durable Objects with SQLite are available on the Workers Free plan within limits; beyond that, usage is billed per request, duration and storage. Hibernation means idle boards do not accrue duration charges. See Cloudflare pricing for current numbers.\n\n## Docs\n- [Architecture](docs/ARCHITECTURE.md)\n- [Protocol](docs/PROTOCOL.md)\n- [Contributing](CONTRIBUTING.md), [Security](SECURITY.md)\n\n## Screenshots\nScreenshots will be added under `docs/` once the UI is final.\n\n## Built with Gitflare\nThis project was built by coordinated agents on Gitflare, each owning one part (server, UI, docs) and merged after tests passed.\n\n## License\nApache-2.0\n","commitSha":"6eb4fbd3f80652f3c1a247d94fe6521ad71d4dec"}