I'm building a service that will consist of mobile and desktop apps, which will require me to build my own RESTful web API to easily keep the data for the service in sync. I am also building a web app in Ruby on Rails. Initially I plan to host everything on one server due to cost.
I'm curious which is a better design:
- Have the Rails app access the database strictly via calls to the API to allow for the future ability to host them on separate servers.
- Host the API and Rails app on the same server always, and have each access the database directly.
I'm currently planning on the API to be private, with the possibility of opening up a small portion of it later.
Disclaimer: This would be my first time building my own API