When a module is loaded ( In other words load a javascript file using require(..) ), it returns whatever is assigned to module.exports, for example
//javascript file add.js
module.exports = function(a,b){
return a+b;
}
//Usage in app.js
var add = require("add.js");
var result = add(2+2);//result would be 4
//Similarly
var result = require("add.js")(2+2);//result would be 4
In your case database.js returns a function in its module.exports and that function takes one paramter which is an object.
var db = require(__dirname + '/components/database.js')({});
In the above snippet you are passing an empty object to the function.The creators of database.js have given you options to customize some values, something like this
var db = require(__dirname + '/components/database.js')({
port:3306,
});
//or
var options = {};
options.port = 3306;
var Database = require(__dirname + '/components/database.js')
var db = Database(options);