Mobile application and database

Hello everybody !

In order to discover React, i made a QCM application with React and then I did the backend with node.js and a MongoDB database. All is working fine.

Now I would like to make it become a mobile application and I wonder how to manage the data (the results of the user for each questions). I don’t need the data to be shared with other users (actually the QCM can be entirely offline). But I need the data to be persistent.

I don’t know if I can keep the same backend and put a MongoDB database in the installing file of the application.

Do you have some idea about it or some directions for my research of a solution ?

Many courses I find on the web describe how to make a react native application but don’t explain anything about the backend.

By the way, i was thinking about react native but I discovered the progressive web app and it could be something to consider. I tell it just in case it changes anything related to my question. In case I choose a react native application, I will have to make a new application for the frontend.

I am a React Native developer. If you know React, you already know 90% of React Native.

If you don’t need to store the data off the device, then you have access to AsyncStorage, which works similar to how Local Storage works in a browser.

I don’t know if I can keep the same backend and put a MongoDB database in the installing file of the application.

I don’t understand your confusion. You don’t install the backend on the mobile device. You put the backend on a server and have it access your DB. Presumably, you would hit the exact same endpoints that your web app does. I don’t know, perhaps if you have a SSR app or something where your endpoints are integrated with your f/e somehow, but if you can break those apart and have API endpoints that just serve data, then it doesn’t know or care who is requesting data, as long as they have the credentials.

Thanks for your answer

I don’t understand your confusion. You don’t install the backend on the mobile device. You put the backend on a server and have it access your DB.

What I mean is this : for example, when i develop on my localhost, I use an API which isn’t on a server. It is on my computer, like the database. Actually I can use the application the same way a user would, except I use a computer. So that’s why I wondered if there was a way to do the same for the mobile app. The mobile application would be the same as the actual web application, except it would use React. I hope my explanation doesn’t make things more confusing

Thanks for the AsyncStorage, I will check this !

So, your app only works on a computer where your server and DB are running?

Why not host them somewhere? There are services that will do it for free.

How to set up an API and DB server on your phone for that app to use? I don’t know how to do that or why I would want to. At that point, why not just build it into the app?

I’m sure if you search around on npmjs you can find something, but I think you’re barking up the wrong tree.

Yes, because I am the only one who uses it during the development process and as i was a complete beginner when I started to make it, it was the easiest thing to do.

They are in the app.

Like when we install a game on our computer, all the game is installed on the computer, what we see, the algorithms which handles the AI and the saves files

Yeah, I get that. When I develop an app, I often deploy the API/DB locally. But you have to keep a mind towards scalability - namely scaling beyond one computer.

Rather than figuring out the difficult and dead-end idea of redeploying those on your cell phone (and I’m not even sure how that would work on an emulator), why not spend that time learning the much easier and infinitely more scalable option of learning how to deploy this in the normal manner. I used free services like Heroku to host my API server and mLab to host my DB. I’m sure there are other options.

I will take a look on this. Thanks !

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.