restructured angular-js backend