Overhaul backend structure

Implemented a MongoEntity system to allow code encapsulation