app.js: refactor the code into MVC structure