Refactor

organize the server side code
Good idea! I was actually struggling to find a name for this (couchdb/couch-db is so unsatisfying)