If you want to build something like this without writing the tricky code, Couchbase Lite has peer to peer sync. Our big vertical for that is currently point-of-sale but the applications are limitless.
I admit I have only skimmed over the page, but...how does Couchbase create the connection? All I see is that you have to share a QR code with others, which is not really flexible compared to connecting ad hoc via Bluetooth and Wi-Fi.