Reputation:
I'm building a REST API for an app that I'm writing for a client. The way that I shared information across apps and websites before was that I would use the API for both. I'm wondering if it is a good decision or not to connect the site directly to the DB, as well as connecting the API to the same database.
Update: Specifically, the web site will be for admins and agents to view information about the clients for the company. They will be able to contact, view contracts, etc. There will not be more than maybe 50 people using it. The app is to collect geolocation data, checkins, and other personal information. The client has specifically requested this. It probably won't exceed more than 1000 users. For something of this size, I thought it will be fine if the admin site connects directly to the DB instead of going through the API layer. I'm not sure if this is a totally wise decision, and I'd like to hear reasons about why one approach is better than the other.
Upvotes: 2
Views: 316
Reputation:
More than a year later, I'd like to return to this question and answer it. The way I intended this system to be designed was for mobile applications to use a database, and for the website to skip that layer and just use the database directly. I now realize that if I'm going to be using a service based architecture, I might as well use it throughout the entire system to be consistent. The positives of the first approach are that it is simpler to code by using the DB directly, and probably faster as well since it doesn't require as much network traffic. However, I am duplicating code on two separate applications. The second approach allows me to define a layer of logic, that will remain universal throughout my applications.
Upvotes: 2