'What the is best architecture for a Rails-Flutter application that also uses Heroku PostgreSQL? [closed]

I have built a Rails application that works fine and uses Heroku PostgreSQL as a database.

I am now working on implementing a Flutter app, that basically does the same thing as the website only as a mobile app (and offers additional native functionalities). The thing is I don't know what is the smartest way of connecting them. I am seeing two options

  1. The Flutter app makes an API request to the Rails application to get information about the "posts" and user data (via Rails Devise) on the website. The Rails application is connected to the Heroku PostgreSQL and will send the data to the Flutter app.

  2. The Flutter app is directly connected to the Heroku PostgreSQL to get all the information about the posts. Only for signing up users (via Rails Devise) it will connect to the Rails application via API.

Which way is better practice? I am seeing some speed advantage in option 2., as Rails is cut out as the "middleman". However, I also think this could make it a lot harder to control and debug.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source