Access firestore directly from mobile app or via backend server?












0















System Design question:



I'm using firebase for my mobile app with firestore as the DB and firebase functions as the backend.



Do I:




  1. Access firestore directly from the mobile app

  2. Only allow indirect access via a middleware/backend server(e.g. firebase functions)


I'm looking for guidance from a system design standpoint which of the two alternatives is better.
Traditionally I think accessing the DB directly from the client would be frowned upon but in the official firestore documentation google seems to actually encourage direct access without any backend server in between.










share|improve this question



























    0















    System Design question:



    I'm using firebase for my mobile app with firestore as the DB and firebase functions as the backend.



    Do I:




    1. Access firestore directly from the mobile app

    2. Only allow indirect access via a middleware/backend server(e.g. firebase functions)


    I'm looking for guidance from a system design standpoint which of the two alternatives is better.
    Traditionally I think accessing the DB directly from the client would be frowned upon but in the official firestore documentation google seems to actually encourage direct access without any backend server in between.










    share|improve this question

























      0












      0








      0








      System Design question:



      I'm using firebase for my mobile app with firestore as the DB and firebase functions as the backend.



      Do I:




      1. Access firestore directly from the mobile app

      2. Only allow indirect access via a middleware/backend server(e.g. firebase functions)


      I'm looking for guidance from a system design standpoint which of the two alternatives is better.
      Traditionally I think accessing the DB directly from the client would be frowned upon but in the official firestore documentation google seems to actually encourage direct access without any backend server in between.










      share|improve this question














      System Design question:



      I'm using firebase for my mobile app with firestore as the DB and firebase functions as the backend.



      Do I:




      1. Access firestore directly from the mobile app

      2. Only allow indirect access via a middleware/backend server(e.g. firebase functions)


      I'm looking for guidance from a system design standpoint which of the two alternatives is better.
      Traditionally I think accessing the DB directly from the client would be frowned upon but in the official firestore documentation google seems to actually encourage direct access without any backend server in between.







      firebase model-view-controller architecture google-cloud-firestore system-design






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 26 '18 at 6:34









      deekay42deekay42

      737




      737
























          2 Answers
          2






          active

          oldest

          votes


















          0














          Both Firebase database products are designed to be used on the client. One of its killer features is the automatic realtime syncing of changes. So definitely its meant to be consumed from the client. Thats not to say you cant consume from the server as well. But its all about setting up your rules effectively so that you can query from the client. You will need to use Firebase Auth if you want to secure your database. Some links to relevant docs.



          Firestore Security Rules
          Example of some Security Rules for querying



          Firebase Auth



          And incase you already have an authentication method in place and cant migrate to Firebase Auth you can use Custom Auth where when you authenticate the person you issue them with a Firebase Token which you can login them in with in the app.






          share|improve this answer































            0















            I'm looking for guidance from a system design standpoint which of the two alternatives is better.




            IMHO, the question shouldn't be asked, which is better because each one of those products, Cloud Firestore and Cloud Functions for Firebase are two different products with different mechanisms but the same purpose.



            As also Jack Woodward mentioned in his answer, the first solution can help you keep your data in sync across client apps. As in case of Firebase realtime database the main feature is the realtime feature. In both bases your data is stored as JSON and synchronized in realtime to every connected client.



            Regarding the second option, as in the official documentation:




            Cloud Functions for Firebase lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests. Your code is stored in Google's cloud and runs in a managed environment. There's no need to manage and scale your own servers.




            If you are simply asking what can you do with Cloud Functions, please see the use cases of Cloud Functions:




            • Notify users when something interesting happens.

            • Perform Realtime Database sanitization and maintenance.

            • Execute intensive tasks in the cloud instead of in your app.

            • Integrate with third-party services and APIs.






            share|improve this answer
























            • Hi! Can I help you with other informations? If you think that my answer helped you, please consider accepting it by clicking the checkmark (✔️) on the left side under the vote arrows. Should change the color in green. I'd appreciate it. Thanks!

              – Alex Mamo
              Nov 27 '18 at 9:16











            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475832%2faccess-firestore-directly-from-mobile-app-or-via-backend-server%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Both Firebase database products are designed to be used on the client. One of its killer features is the automatic realtime syncing of changes. So definitely its meant to be consumed from the client. Thats not to say you cant consume from the server as well. But its all about setting up your rules effectively so that you can query from the client. You will need to use Firebase Auth if you want to secure your database. Some links to relevant docs.



            Firestore Security Rules
            Example of some Security Rules for querying



            Firebase Auth



            And incase you already have an authentication method in place and cant migrate to Firebase Auth you can use Custom Auth where when you authenticate the person you issue them with a Firebase Token which you can login them in with in the app.






            share|improve this answer




























              0














              Both Firebase database products are designed to be used on the client. One of its killer features is the automatic realtime syncing of changes. So definitely its meant to be consumed from the client. Thats not to say you cant consume from the server as well. But its all about setting up your rules effectively so that you can query from the client. You will need to use Firebase Auth if you want to secure your database. Some links to relevant docs.



              Firestore Security Rules
              Example of some Security Rules for querying



              Firebase Auth



              And incase you already have an authentication method in place and cant migrate to Firebase Auth you can use Custom Auth where when you authenticate the person you issue them with a Firebase Token which you can login them in with in the app.






              share|improve this answer


























                0












                0








                0







                Both Firebase database products are designed to be used on the client. One of its killer features is the automatic realtime syncing of changes. So definitely its meant to be consumed from the client. Thats not to say you cant consume from the server as well. But its all about setting up your rules effectively so that you can query from the client. You will need to use Firebase Auth if you want to secure your database. Some links to relevant docs.



                Firestore Security Rules
                Example of some Security Rules for querying



                Firebase Auth



                And incase you already have an authentication method in place and cant migrate to Firebase Auth you can use Custom Auth where when you authenticate the person you issue them with a Firebase Token which you can login them in with in the app.






                share|improve this answer













                Both Firebase database products are designed to be used on the client. One of its killer features is the automatic realtime syncing of changes. So definitely its meant to be consumed from the client. Thats not to say you cant consume from the server as well. But its all about setting up your rules effectively so that you can query from the client. You will need to use Firebase Auth if you want to secure your database. Some links to relevant docs.



                Firestore Security Rules
                Example of some Security Rules for querying



                Firebase Auth



                And incase you already have an authentication method in place and cant migrate to Firebase Auth you can use Custom Auth where when you authenticate the person you issue them with a Firebase Token which you can login them in with in the app.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 26 '18 at 9:14









                Jack WoodwardJack Woodward

                62149




                62149

























                    0















                    I'm looking for guidance from a system design standpoint which of the two alternatives is better.




                    IMHO, the question shouldn't be asked, which is better because each one of those products, Cloud Firestore and Cloud Functions for Firebase are two different products with different mechanisms but the same purpose.



                    As also Jack Woodward mentioned in his answer, the first solution can help you keep your data in sync across client apps. As in case of Firebase realtime database the main feature is the realtime feature. In both bases your data is stored as JSON and synchronized in realtime to every connected client.



                    Regarding the second option, as in the official documentation:




                    Cloud Functions for Firebase lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests. Your code is stored in Google's cloud and runs in a managed environment. There's no need to manage and scale your own servers.




                    If you are simply asking what can you do with Cloud Functions, please see the use cases of Cloud Functions:




                    • Notify users when something interesting happens.

                    • Perform Realtime Database sanitization and maintenance.

                    • Execute intensive tasks in the cloud instead of in your app.

                    • Integrate with third-party services and APIs.






                    share|improve this answer
























                    • Hi! Can I help you with other informations? If you think that my answer helped you, please consider accepting it by clicking the checkmark (✔️) on the left side under the vote arrows. Should change the color in green. I'd appreciate it. Thanks!

                      – Alex Mamo
                      Nov 27 '18 at 9:16
















                    0















                    I'm looking for guidance from a system design standpoint which of the two alternatives is better.




                    IMHO, the question shouldn't be asked, which is better because each one of those products, Cloud Firestore and Cloud Functions for Firebase are two different products with different mechanisms but the same purpose.



                    As also Jack Woodward mentioned in his answer, the first solution can help you keep your data in sync across client apps. As in case of Firebase realtime database the main feature is the realtime feature. In both bases your data is stored as JSON and synchronized in realtime to every connected client.



                    Regarding the second option, as in the official documentation:




                    Cloud Functions for Firebase lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests. Your code is stored in Google's cloud and runs in a managed environment. There's no need to manage and scale your own servers.




                    If you are simply asking what can you do with Cloud Functions, please see the use cases of Cloud Functions:




                    • Notify users when something interesting happens.

                    • Perform Realtime Database sanitization and maintenance.

                    • Execute intensive tasks in the cloud instead of in your app.

                    • Integrate with third-party services and APIs.






                    share|improve this answer
























                    • Hi! Can I help you with other informations? If you think that my answer helped you, please consider accepting it by clicking the checkmark (✔️) on the left side under the vote arrows. Should change the color in green. I'd appreciate it. Thanks!

                      – Alex Mamo
                      Nov 27 '18 at 9:16














                    0












                    0








                    0








                    I'm looking for guidance from a system design standpoint which of the two alternatives is better.




                    IMHO, the question shouldn't be asked, which is better because each one of those products, Cloud Firestore and Cloud Functions for Firebase are two different products with different mechanisms but the same purpose.



                    As also Jack Woodward mentioned in his answer, the first solution can help you keep your data in sync across client apps. As in case of Firebase realtime database the main feature is the realtime feature. In both bases your data is stored as JSON and synchronized in realtime to every connected client.



                    Regarding the second option, as in the official documentation:




                    Cloud Functions for Firebase lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests. Your code is stored in Google's cloud and runs in a managed environment. There's no need to manage and scale your own servers.




                    If you are simply asking what can you do with Cloud Functions, please see the use cases of Cloud Functions:




                    • Notify users when something interesting happens.

                    • Perform Realtime Database sanitization and maintenance.

                    • Execute intensive tasks in the cloud instead of in your app.

                    • Integrate with third-party services and APIs.






                    share|improve this answer














                    I'm looking for guidance from a system design standpoint which of the two alternatives is better.




                    IMHO, the question shouldn't be asked, which is better because each one of those products, Cloud Firestore and Cloud Functions for Firebase are two different products with different mechanisms but the same purpose.



                    As also Jack Woodward mentioned in his answer, the first solution can help you keep your data in sync across client apps. As in case of Firebase realtime database the main feature is the realtime feature. In both bases your data is stored as JSON and synchronized in realtime to every connected client.



                    Regarding the second option, as in the official documentation:




                    Cloud Functions for Firebase lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests. Your code is stored in Google's cloud and runs in a managed environment. There's no need to manage and scale your own servers.




                    If you are simply asking what can you do with Cloud Functions, please see the use cases of Cloud Functions:




                    • Notify users when something interesting happens.

                    • Perform Realtime Database sanitization and maintenance.

                    • Execute intensive tasks in the cloud instead of in your app.

                    • Integrate with third-party services and APIs.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 26 '18 at 10:33









                    Alex MamoAlex Mamo

                    42.7k82860




                    42.7k82860













                    • Hi! Can I help you with other informations? If you think that my answer helped you, please consider accepting it by clicking the checkmark (✔️) on the left side under the vote arrows. Should change the color in green. I'd appreciate it. Thanks!

                      – Alex Mamo
                      Nov 27 '18 at 9:16



















                    • Hi! Can I help you with other informations? If you think that my answer helped you, please consider accepting it by clicking the checkmark (✔️) on the left side under the vote arrows. Should change the color in green. I'd appreciate it. Thanks!

                      – Alex Mamo
                      Nov 27 '18 at 9:16

















                    Hi! Can I help you with other informations? If you think that my answer helped you, please consider accepting it by clicking the checkmark (✔️) on the left side under the vote arrows. Should change the color in green. I'd appreciate it. Thanks!

                    – Alex Mamo
                    Nov 27 '18 at 9:16





                    Hi! Can I help you with other informations? If you think that my answer helped you, please consider accepting it by clicking the checkmark (✔️) on the left side under the vote arrows. Should change the color in green. I'd appreciate it. Thanks!

                    – Alex Mamo
                    Nov 27 '18 at 9:16


















                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53475832%2faccess-firestore-directly-from-mobile-app-or-via-backend-server%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Lallio

                    Unable to find Lightning Node

                    Futebolista