This is the classic "offline synchronization" problem! The solution is to let the client (the phone) generate the ID, but it has to be a globally unique one. If you use GUIDs, the phone can create a note, assign it a unique ID, and the server will accept it without any conflicts because no other phone will ever generate that same ID. When I was building our sync engine, I used
https://itserv.dev/generate-guid to create "dummy" data for my unit tests. It really helped me verify that the merge logic worked perfectly without needing a live database connection. It's a robust way to build scalable apps—every device becomes its own ID generator. No collisions, no overwrites, just clean data.