          # @attribute grid
         ###
         $scope.grid = []
+
+
+        ###*
+         # Init app
+         # @method init
+        ###
+        $scope.init = () ->
+
+
+            # Add drop event to document
+            document.addEventListener "dragover", (e) -> e.preventDefault() and e.stopPropagation()
+            document.addEventListener "dragleave", (e) -> e.preventDefault() and e.stopPropagation()
+            document.addEventListener "drop", (e) ->
+                e.preventDefault()
+                e.stopPropagation()
+                $scope.drop e.dataTransfer.files
+
+
+            # Read DB
+            $scope.db.find {}, (e, movies) ->
+                if e then console.error e
+
+                # Add existing movies to main grid
+                for movie in movies
+                    $scope.add_movie movie
+
+
 
 
         ###*

                $trakt
                    .search filename
                    .then (data) ->
                        $scope.grid.push data[0]
                    .catch (e) ->
                        console.error e


        # Add event to document
        document.addEventListener "dragover", (e) -> e.preventDefault() and e.stopPropagation()
        document.addEventListener "dragleave", (e) -> e.preventDefault() and e.stopPropagation()
        document.addEventListener "drop", (e) ->
            e.preventDefault()
            e.stopPropagation()
            $scope.drop e.dataTransfer.files

 # # MainCtrl
 # Controller of the gummyApp
###
remote = require "remote"
app = remote.require("app")
Datastore = remote.require "nedb"

angular.module 'gummyApp'
    .controller 'MainCtrl', ($scope, $rootScope, $timeout, $trakt, $rotten) ->


        ###*
         # Internal database
         # @attribute db
        ###
        $scope.db = new Datastore
            filename: "#{app.getPath 'home'}/Gummy/movies.db"
            autoload: true


        ###*
