define([
  'backbone',
  'backbone.marionette',
  'common/collections/NavigationCollection',
  'common/controllers/SelectedModulesController',
  'common/views/NavigationView',
  'common/views/SelectView',
  'localforage',
  'qtip2'
], function (Backbone, Marionette, NavigationCollection,
             SelectedModulesController, NavigationView, SelectView,
             localforage) {
  'use strict';

  var App = new Marionette.Application();

  App.addRegions({
    mainRegion: '.content',
    navigationRegion: 'nav',
    selectRegion: '.navbar-form'
  });

  var navigationCollection = new NavigationCollection();
  var navigationView = new NavigationView({collection: navigationCollection});
  App.navigationRegion.show(navigationView);

  App.reqres.setHandler('addNavigationItem', function (navigationItem) {
    return navigationCollection.add(navigationItem);
  });

  var selectedModulesController = new SelectedModulesController();
  App.reqres.setHandler('selectedModules', function(){
    return selectedModulesController.selectedModules;
  });
  App.commands.setHandler('removeModule', function (id) {
    var selectedModules = selectedModulesController.selectedModules;
    selectedModules.remove(selectedModules.get(id));
  });

  App.selectRegion.show(new SelectView({
    collection: App.request('selectedModules')
  }));

  App.on('start', function () {
    require([
      'common/views/AppView',
      // 'ivle',
      'modules',
      'timetable_builder',
      'preferences'
    ], function (AppView) {
      Backbone.history.start({pushState: true});

      new AppView();

      if (Backbone.history.fragment === '') {
        Backbone.history.navigate('timetable-builder', {trigger: true});
      }
    });

    var $body = $('body');
    ['theme', 'mode'].forEach(function (property) {
      localforage.getItem(property, function (value) {
        if (!value) {
          localforage.setItem(property, 'default');
        }
        $body.addClass(property + '-' + value);
        $body.attr('data-' + property, value);
        if (property === 'mode' && value !== 'default') {
          $('#mode').attr('href', '/styles/' + value + '.min.css');
        }
      });
    });
  });

  return App;
});

@@ -215,16 +215,29 @@
 orage',%0A
+  'nusmods',%0A
   'qtip2
@@ -387,16 +387,25 @@
 alforage
+, NUSMods
 ) %7B%0A  'u
@@ -1009,18 +1009,20 @@
 function
+ 
 ()
+ 
 %7B%0A    re
@@ -1085,15 +1085,197 @@
 App.
-command
+reqres.setHandler('addModule', function (id) %7B%0A    return NUSMods.getMod(id).then(function (mod) %7B%0A      return selectedModulesController.selectedModules.add(mod);%0A    %7D);%0A  %7D);%0A  App.reqre
 s.se
@@ -1384,24 +1384,31 @@
 odules;%0A    
+return 
 selectedModu
@@ -1445,24 +1445,154 @@
 (id));%0A  %7D);
+%0A  App.reqres.setHandler('isModuleSelected', function (id) %7B%0A    return !!selectedModulesController.selectedModules.get(id);%0A  %7D);
 %0A%0A  App.sele

Add addModule and isModuleSelected request handlers