Local-First Collaborative Board: CRDT Sync, Offline Edits and Live Presence

Build a run-of-show board that works without a network and merges everyone's edits: a React app whose data lives in a Yjs document saved to IndexedDB, a service worker for offline reloads, a WebSocket sync protocol with token authentication, presence and reconnection, two Node.js server instances that store every update in PostgreSQL before broadcasting it and share updates and revocations through LISTEN/NOTIFY, and tests from convergence property tests to Playwright taking two browsers offline. Everything runs in a Docker Compose lab on your computer.

Full-Stack Engineer. Advanced.

What you will build and explain

  • Explain why last-write-wins loses data and design a CRDT document whose concurrent edits merge without loss: character-level text, fractional-index ordering that never duplicates a moved card, and archiving instead of deletion.
  • Keep an application usable offline with IndexedDB and a service worker, and remove each user's local data at sign-out and when someone else signs in on the same browser.
  • Implement and debug a WebSocket sync protocol: a short-lived token as the first message, the y-protocols state-vector handshake, heartbeats, presence, limits and close codes that tell the client whether to retry.
  • Secure a real-time service with scrypt passwords, HttpOnly SameSite=Strict session cookies stored as hashes, origin checks against CSRF and cross-site WebSocket hijacking, server-enforced roles and revocation of open connections on every instance.
  • Store a replicated document durably and scale it across instances: persist before broadcast, gap-free sequence numbers, compaction safe under concurrent writes, restore as a forward edit, and fan-out through PostgreSQL LISTEN/NOTIFY that survives lost notifications.
  • Test convergence with property tests, protocols with in-memory fakes, storage against PostgreSQL and offline behaviour in two Playwright browser contexts, and measure cross-instance fan-out latency under load.

Before you begin

  • TypeScript or JavaScript with async/await, React with hooks and controlled inputs, HTTP and cookies, and SQL with transactions
  • Running Node.js and npm, Git and Docker Compose from a terminal
  • A computer running Linux, macOS or Windows with WSL 2, with Docker and Compose v2.24 or later, GNU Make and OpenSSL, about 4 CPU cores, 8 GB of memory and 8 GB of free disk; Node.js 24.12 or later is optional

Who this is for

For full-stack engineers who build React apps, HTTP APIs and SQL schemas, and want to build a board that works offline, merges concurrent edits without losing any, shows live presence and cuts off a removed member on every server at once.

Curriculum

Learning topics (18)
  1. Check your starting skills and prepare your computer

    This project assumes you already build ordinary web applications: a React front end, an HTTP API and a SQL database. It teaches what changes when several people edit the same data, some of them offline. Check the list below honestly: each item is used without explanation later, and each has a short way to fill the gap.

  2. A board that works offline and merges everyone's edits

    Lanternway's crew plan each show on a run-of-show board: a column per phase of the day and a card per task. The board has to keep working in a stadium tunnel with no signal, and when two people change the same card, both changes have to survive. That requirement decides the shape of the whole system:

  3. Why last write wins loses work, and how a CRDT merges instead

    By the end of this lesson you can explain why the crew's old board lost notes, what a conflict-free replicated data type (CRDT) guarantees instead, and how Yjs represents the board so that two people's offline edits always merge into the same result.

  4. Design the board for concurrent edits

    A CRDT guarantees that replicas agree; it does not guarantee that what they agree on is what the crew meant. This lesson designs the board's document so that the merge rules from the previous lesson produce sensible results for every edit a crew member can make: typing, adding, moving, archiving and restoring cards. By the end you can explain each choice in shared/board.ts and predict what two concurrent edits will do.

  5. IndexedDB, a service worker and nothing left behind

    The crew's board has to open in a tunnel, after a reload, with no signal. This lesson covers the three browser features that make that possible: IndexedDB for the board's data, a service worker for the application itself, and localStorage for who is signed in. It also covers the part that is easy to forget: removing all of it when someone signs out of a shared laptop.

  6. From a token to a synced board over WebSocket

    Two replicas converge only if every update eventually reaches both. This lesson follows the connection that carries them: how a browser proves who it is over a WebSocket, how two sides work out what each is missing in two messages, what happens to edits while connected, and how each way of losing the connection is handled. By the end you can read a WebSocket trace in the browser's developer tools and say what every message does.

  7. Sessions, tokens, roles and revocation

    A freelancer who had left the production kept a browser tab open and could still change the board a day later. That is the crew's third bug, and it is a security bug. This lesson builds the board's defences in the order a request meets them: the password, the session cookie, the origin check, the sync token, the role, and finally revocation of a connection that is already open. It ends with what the browser itself must refuse to do with board content.

  8. Store updates before anyone sees them, and compact safely

    Browsers keep their own copies, so why does the server need to store anything carefully? Because the server is where copies meet: a browser that clears its storage, a new device, a crew member who joins tomorrow, and the second server instance all learn the board from what the server kept. This lesson designs that storage in PostgreSQL: an append-only log of updates, written before anyone else sees them, numbered without gaps, and folded into snapshots without losing anything

  9. Fan-out between instances with LISTEN and NOTIFY

    A WebSocket server keeps state in memory: each open board is a room with its document and its connections. One instance is easy. Two are where real-time systems get interesting, because Ana may be connected to one and Ben to the other. This lesson explains why that breaks naive designs, and how this project shares updates, presence and revocations between instances with PostgreSQL's LISTEN and NOTIFY, without depending on any message arriving.

  10. Who is here, and whose edit to revert

    Two features make a shared board feel shared rather than merely synchronized: seeing that Ben is editing the "Brief the ushers" card before you start typing into it, and pressing Undo without wiping out Ben's work. Both depend on the same idea: telling apart what this person did from what arrived from others. This lesson covers presence (Yjs awareness) end to end, then the undo manager.

  11. Restore a version as a forward edit

    Before doors open, the stage manager wants a snapshot of the plan: "this is what we agreed". Later, after a confused hour of edits, they want to put the board back. In an ordinary application that is a database restore. In a replicated document it is not, because other replicas, some of them offline right now, hold the edits you would be rewinding. This lesson explains why restoring has to be a new edit, and how restoreFrom computes it.

  12. Bind React to a shared document

    React renders from state; Yjs changes underneath you whenever someone else types. This lesson covers how the board's interface stays a faithful view of a document it does not own: one-way data flow from the document, writes only through the model, a text box that keeps your caret in place while others edit the same text, and the lifecycle of a board session inside React's effects.

  13. Property, unit, integration and two-browser tests

    Most bugs in a collaborative system need two people, an unlucky ordering of messages or a network that fails at the wrong moment. You will not see them by clicking around in one browser. This lesson explains the project's four layers of tests, what each can and cannot prove, and how the two-browser partition test is built.

  14. Images, least privilege, the proxy, health and metrics

    The board runs as five long-lived containers and a few one-off jobs. This lesson explains how the Compose lab is put together, what each security setting buys, how the proxy spreads and fails over connections, and how an operator tells whether the system is healthy: health checks, metrics, logs and a rolling restart. The ordered commands are in deployment; this lesson explains why they are what they are.

  15. Run the checks, the lab and the tests

    This is the single ordered procedure for the project: from a fresh copy of the source to a running lab, its tests and a rolling release. Removing everything afterwards is in cleanup; you can jump there at any point, including after a step failed.

  16. Diagnose sync problems from evidence

    Collaborative systems rarely fail loudly. A message is lost and nobody notices for an hour; one instance stops hearing the other and half the crew sees a stale board; a client reconnects a little too eagerly and a restart turns into a stampede. The skill this lesson practises is turning "it's not syncing" into a specific, testable explanation.

  17. Explain the design in an interview

    Full-stack interviews about real-time systems rarely ask for an API name. They ask you to walk through what happens to a user's action, defend a choice when a constraint changes, and say what you would check when something looks wrong. This project gives you a concrete system to talk about, with real trade-offs: a CRDT instead of last write wins, a custom sync server instead of a hosted one, PostgreSQL notifications instead of a broker, store-then-broadcast, archive instead o

  18. Remove the lab and check for leftovers

    Everything this project creates lives on your computer: containers, one volume and one network from Compose, four images, and generated folders inside the source folder. Nothing is billed, but the images take about 3 GB and the volume keeps the boards until you remove it. This page removes them in order and shows how to confirm that nothing is left. It is safe to follow at any point, including after a failed step.

Practical build steps (9)
  1. Install the tools and run the local checks

    You start with a computer and your own copy of the source, and finish with every npm package installed from its lock file, the whole codebase type-checked and the unit tests passing. Nothing runs in containers yet, and nothing outside the source folder changes.

  2. Watch concurrent edits converge

    You start with the local checks passing and finish having run the board model's tests on their own, read what they assert, and merged two Yjs documents by hand. No lab is needed.

  3. Start the lab

    You start with Docker running and port 8080 free, and finish with five containers running: the database, two server instances and the proxy, plus the migrator and seeder that ran once. The board is at http://127.0.0.1:8080 with synthetic users and a sample board.

  4. Use the board as two people, online and offline

    You start with the lab running and finish having seen, with your own eyes, the three problems the crew had solved: two people editing the same card offline keep both edits, a moved card is in one place, and a removed member is cut off at once.

  5. Test against PostgreSQL and two instances

    You start with the lab running and finish with the integration tests passing and two measurements in server/evidence/: how long a compacted board of 10,000 updates takes to load, and how long an edit takes to reach the other instance.

  6. Run the browser tests

    You start with the lab running and finish with ten browser tests passing and a report in e2e/results/report/. The last test stops one server instance; the Makefile starts it again.

  7. Measure fan-out under load

    You start with the lab running and finish with a load-test summary in server/evidence/load.json and the instances' metrics showing the same traffic from the server's side.

  8. Release a change without dropping anyone

    You start with the lab running and a board open in a browser, and finish with a changed server image running on both instances, replaced one at a time while the board stayed usable.

  9. Remove the lab and check for leftovers

    You start with the lab in any state, including after a failed step, and finish with no container, volume or network of the project left, and optionally no images, generated folders, secrets or browser data either.

Access

Learning Access: INR 199 plus 18% GST. Source Pack: INR 399 plus 18% GST. 90 days of online access. No auto-renewal.

Cloud costs and boundaries

No cloud account or spending is needed: the lab runs as containers on your own computer, publishes one port on 127.0.0.1 only, and its images take about 3 GB of disk. GitHub Actions is optional; it is free on public repositories and uses your account's included minutes on private ones. The people and shows in the data are invented. This is a learning project, not a hosted service or a production-readiness guarantee.

Licence and completion

Vectametric Project Source Licence (2026-09-27): lawfully obtained source may be copied, modified and deployed for personal learning and interview preparation, including personal portfolio demonstrations with attribution. These permissions continue after online access expires. Do not resell or redistribute the Source Pack or its original source files, unchanged or modified. Commercial or client production use requires separate written permission. Third-party components, such as Yjs, React, Vite, Fastify, node-postgres, TypeScript and Playwright, retain their own licences. See LICENSE.txt and the Project Source Licence section of the site Terms for the full rules.

Questions about projects

Do I need a cloud account?

You can read the project material without deploying it. Running a cloud build requires the accounts, permissions and tools listed in that project's prerequisites. Deployment runs in your environment, not in a hosted Vectametric lab.

Can I read the code with Learning Access?

Yes. Learning Access includes the online source-file browser and explanations. The Source Pack adds the downloadable reference repository where available. The project's licence governs use of the source.

Are cloud charges included?

No. Cloud and CI usage are separate. Read the project's cost notice, set a budget and stop deadline, and follow its destruction and leftover-resource checks.

Does the project include troubleshooting and interview preparation?

The project curriculum lists the available scenarios and interview topics. These focus on understanding the architecture and explaining decisions; they are not a promise of particular interview questions or a job.

How long can I use the project?

The project page and checkout show the online access period for your selected plan. Access does not auto-renew. Downloaded source remains subject to its licence; future releases are not automatically included.

Review the Terms and No-Refund Policy before confirming access. All sales are final; Vectametric does not offer refunds.

This website is operated by VECTAMETRIC EDTECH (OPC) PRIVATE LIMITED, operating as Vectametric.

Corporate Identity Number (CIN): U85499KA2026OPC229822. GSTIN: 29AAMCV8281D1ZS. Registered office: RS NO/38/2A/1 BASTAND, ROAD MAHANTESH NAGAR, Ramdurg, Ramdurg, Belgaum- 591123, Karnataka.

Queries and grievances: Prajval Honnungar, Grievance Officer and Data Protection Contact.

Telephone: +91 94800 09310. Support: support@vectametric.com. Grievances: support@vectametric.com.

Copyright 2026 VECTAMETRIC EDTECH (OPC) PRIVATE LIMITED. All rights reserved.

Vectametric home · Roadmaps · Vecta IT Exams · Vecta Government Exams · Vecta Banking & Finance Exams · Vecta Entrance Exams · About us · Contact · Privacy Policy · Terms and Conditions · No-Refund Policy