A teaching page for a new engineer
How a note travels between devices
A note saves on your phone first, then the server numbers it, and your other devices ask for what is newer.
- A note saves on your phone before it is sent.
- The server numbers every change, so the order is never in doubt.
- Each device asks what is new since its last number.
The four layers a note passes through
Easiest first- On your phoneThe note is saved on the phone before anything is sent.Local copyOutbox
- On the sync serverThe server puts every change in one order.ChangeChange number
- On your other devicesA device asks for what is newer than the last change it saw.CursorPull
- When two devices disagreeThe later change wins and the other text is replaced.ConflictLast write wins
Take: a note passes through four layers, and each one adds only a few words. The chips are the words you learn there.
- Where does a note live first?On the phone, saved before it is sent.
- What does the server do with a change?It numbers the change, so the order is fixed.
- How does another device find out?It asks for everything after its cursor.
- What if two devices edit the same note?The later change wins.
- How can you watch it happen?Five steps with a phone and a browser.
Chapter 1 of 5, about 1 minute
Where does a note live first?
Before this: the answer says a note saves on your phone first and travels after that.
When you edit a note, the app does not wait for the network. It saves the edit to the local copy of your notes. The screen answers at once, and nothing is lost if the signal drops.
Next the app adds the edit to the outbox. A background task sends the outbox in order whenever the phone is online. In a lift, the outbox waits.
- Local copy
- The notes stored on the phone itself. The app reads and writes this copy first.
- Outbox
- The edits the phone has saved but not yet sent. It empties as the server confirms each one.
Show one outbox row
Each edit is one row. The phone keeps it until the server confirms it.
outbox row 1
note id n_7f3a
text Milk, eggs
edited at 2026-10-16 09:12:04
tries 0
Remember: a note saves on the phone at once, and its edit waits in the outbox until the network is back.
Chapter 2 of 5, about 1 minute
What does the server do with a change?
Before this: an edit sits in the phone's outbox until the phone is online.
The phone sends each edit to the sync server as a change. The server writes it down and gives it the next change number for your account: 41, then 42, then 43.
- Sync server
- The one program, run by us, that every device of yours talks to.
- Change
- One saved edit, packed to send: the note's id, its new text and when you made it.
- Change number
- The server's running count of changes for your account. Change 42 always comes after change 41.
Phones, tablets and the web app all feed the same list. The server never asks which device was first. The order of arrival is the order.
Show the request and the reply
The phone posts one change. The server answers with the number it gave it.
POST /v1/changes
{ "note": "n_7f3a", "text": "Milk, eggs", "edited": "09:12:04" }
201 Created
{ "change": 41 }
Remember: the server numbers each change as it arrives, and that number fixes the order.
Chapter 3 of 5, about 1 minute
How does another device find out?
Before this: every change has a number, and the server keeps the changes in order.
Your laptop does not wait to be told. It asks every 10 seconds, while the app is open: what is new since the last number I saw? That number is its cursor. The question is a pull.
- Cursor
- The last change number a device has applied. The device stores it.
- Pull
- A device asking the server for what is new. The server never pushes.
The server answers with every change after that number, in order. The device applies them one by one. Then it moves its cursor to the last number it received.
Show the question and the answer
The cursor travels in the address. The reply lists the changes and the newest number.
GET /v1/changes?after=41
200 OK
{ "latest": 43,
"changes": [
{ "change": 42, "note": "n_2c91", "text": "Trip ideas" },
{ "change": 43, "note": "n_7f3a", "text": "Milk, eggs" } ] }
Remember: a device is never pushed to, and it asks for everything after its cursor.
Chapter 4 of 5, about 1 minute
What if two devices edit the same note?
Before this: a device asks for the changes after its cursor and applies them in order.
Sometimes two devices change the same note before either hears from the server. That is a conflict. Version 2.3 settles it with one rule: the higher change number wins.
- Conflict
- Two edits to the same note that neither device knew about.
- Last write wins
- The rule that the change with the higher number replaces the other change's text.
Later means later to arrive, not later typed. A laptop that typed at 09:10 and was offline reaches the server after a phone that typed at 09:12. The laptop's text wins.
In 2.3 the replaced text is not kept. A shared notebook could lose a teammate's words. Mara and Ted are deciding whether 2.4 keeps both copies.
Remember: when two edits clash, the one that reaches the server last wins, and the other text is replaced.
Chapter 5 of 5, about 1 minute
How can you watch it happen?
Before this: a note is saved, sent, numbered, pulled and, in a clash, replaced.
You need your phone and a browser, both signed in to the same test account. The steps take five minutes.
- Open the web app and the phone app. Sign in to the same test account on both.
- Turn on airplane mode on the phone. The app keeps working.
- Edit the note called Groceries. Add "eggs" at the end.
- Open More, then Sync details. It shows one edit waiting to send.
- Turn airplane mode off. Within 10 seconds the count drops to 0 and the web app shows "eggs".
- Airplane mode
- A phone setting that turns off every connection, so the app is offline.
- Sync details
- The screen under More that shows the outbox count and the last change number the phone has seen.
Try a clash on purpose
Repeat the steps, with one change at step 3. Edit Groceries in the browser first, then on the phone.
- Keep airplane mode on. Edit Groceries on the phone and add "eggs".
- Edit Groceries in the browser. Add "bread" and wait for it to save.
- Turn airplane mode off. The phone sends last, so the phone's text wins on both screens.
Remember: the outbox count on the Sync details screen shows whether an edit has left the phone.
Recap
- A note saves on the phone at once, and its edit waits in the outbox until the network is back.
- The server numbers each change as it arrives, and that number fixes the order.
- A device is never pushed to, and it asks for everything after its cursor.
- When two edits clash, the one that reaches the server last wins, and the other text is replaced.
- The outbox count on the Sync details screen shows whether an edit has left the phone.