Abstracted away the storage/index/factory concerns and hid them under a common Repository interface.
A mongodb-like cursor object is returned in lieu of actual results, supporting chaining query criteria during repository calls.
Also reworked the main server file so that it uses the new interface.

The sorting code remains largely untested.