Refactored the api so that both server-side and front-end can access the same model