add sync_doc modules

refactor code from couchapps and mvp into re-usable module