backend refactoring, added a favorites table