Refactor: function to build whole application.