Refactor the controller and the models into JavaScript modules.