title: AngularJS enterprise data access solution for complex REST APIs
body: <p>I'm developing an angular-js web frontend for a "group-role-user" system. The frontend invokes a REST API that has many-many endpoints.
  When I started the development, the REST API had much less endpoints, so It seemed to be a good idea to create an AngularJS service as proxy, create methods for all the endpoints and invoke service via them. As a result of that I have methods for example: addGroup, addRole, addUserToRole, addUserToGroup, etc. It's quiet ugly and unmanageble to use this pattern in complex situations. It made my controllers untestable and they are full of business-logic. I would like to handle data OOP like via (business-)entity objects, somehow like LINQ To SQL does It in .NET.</p>
  
  <p>What pattern should I follow?
  Is It a good solution If I create client-side models for service entities that has relationships with each other via methods and properties? I could access them via Providers from my controllers. (Basically manually inserting and implementing one more tier between controllers and service where I can translate business operations to service invokes.) Or should I stay at the 3-tier model and use rest-angular, $resources  or something else?</p>
  
  <p>What is a real enterprise-solution for this problem? How could I handle this If I want to keep my controllers clean?</p>
  
  <p>Thanks in advance!</p>