If you know JavaScript you could take a look at a project I've been working on, to sum it up quickly it's a basic version control system wrote in JavaScript which gives you the offline editing, tracking changes, retrieving what's changed locally and a way to put remote change into the local version.
The code itself is very decoupled but there is a server implemented in the MongoDB branch. I'm working on a connection manager to detect connections and re-sync when it can.
The project is based at https://github.com/forbesmyester/SyncIt
Thanks