If you want a code-first approach, you might try the "Reference CRDT" implementations, here, written by 'josephg:
https://github.com/josephg/reference-crdts
Seems to have good density of explanatory comments.
(Seph, if you're reading this, I don't know you but Angelo has had good things to say. :)