Web App & Mobile App Database

When you are building a solution that will have both a web and mobile app, do you use the same database for both?

If you don't how do you go about syncing them and which database do you make your primary?

The application will primary be a mobile app but parts of it will need to be web based.

Thanks in advance.

Yes, I used the same database to help keep things in sync the data between the two. However I used different projects to host my server connects for the app.

Ok thank you

Have no clue where I am going, but I am going to try to get there :slight_smile:

1 Like

Feel free to ask lots of questions! But one database is easier to manange.

2 Likes

Check out PocketDB and PouchDB. They are offline capable local syncable databases. I have one in a test environment right now looking like its working to sync changes automatically upon reconnect. Seems ideal, but I don't know much beyond the great Wappler community videos and support docs.

As of now I use a live connection to the same database for mobile and web uses on all published sites. The issue PouchDB might solve would be to allow mobile users to continue using the app normally even without an active data connection.

I like this idea as the app I am building there may be areas where there is no cell service.

silly question... if you are building an app today is node.js always or do some folks still use PHP?

I am thinking about using PHP for my application due to the fact I don't need any push real time updates

I just used PHP. Unless you need websockets or scheduling there really is no advantage to using Node in my opinion. You are really only building your API which is really the same in either platform.

This is a basic leaderboard app

User register for the site
User signs up for event
User enter entry into event (upload image and measurement)
Users will be able to see their entry and other entries and where they rank for the event

event director will be able to create events
event director will be able to see the entry to judge it and then confirm it is a valid entry

I can't think of a reason to need websockets or scheduling, unless I want a leaderboard to refresh automatically when a new entry is submitted.

Unless it updates very frequently it really isn't worth it. To me anyways.

I'm not trying to talk you out of Node ... PHP is just easier to host. Host anywhere. :wink:

We used to use PHP for everything but since moving over to Node there really is no going back (thanks to @JonL for poking the monkey). Not sure why so many Users have issues with hosting? Every Project we have deployed has been seamless with little configuration. We stick to Digital Ocean for everything. Each Droplet costs us about €10.00 a month when you factor in the Database Cluster we also provision through Digital Ocean (€15 a month but we have multiple DBs running spread across several Projects). All this cut-price hosting and the hassle is not worth it to save a couple of Euro's a month, not when it comes to ease of usage and reliability (as well as full backups of our Droplets and databases).

Bit of a Red v Blue issue though...

:slight_smile:

3 Likes

The simplest approach is to have the database only on the web app and use server connect APIs to pull the data into the mobile app. The downside is that if the mobile app is offline, the user will not be able to use it.

I've been thinking about the concept of local first for the app I'm building. It might be worth investigating. If you build a mechanism to sync the data to the web server, this will create a mirror copy of data on the mobile app and allow it to work offline.

The only downside I see so far is creating most of the table structure twice—once for the web app and once for the mobile app—and implementing something like https://replicache.dev/ or https://www.powersync.com/. But you'll gain a lot of benefits from it.

More here: https://localfirstweb.dev/

Wappler recently introduced Couch and Pouch, but I only briefly tested it and decided it was missing data separation when you have multiple accounts/clients in the same database schema. It'll be a little more work, but you can accomplish most of what Couch and Pouch do with APIs and/or sockets minus the conflict resolution.

1 Like

I have never had an issue hosting node.js either, but I moved away from using shared hosts long ago. Digital Ocean, Linode, and all the other new VPS hosts were a better option.

1 Like

But it seems every second post on the community is either node and/or cloud hosting related. Never see a post with shared hosting issues. I just look at the sheer number of issues reported here for cloud hosting and docker etc, that it is very off putting. :slight_smile:

Not dissing Node at all, just more complicated and expensive to work with.

I think most of that is User system related and not being ready (or prepared) locally. It is the same with PHP and package dependency issues. If the host system is set-up correctly then there should be no issues whatsoever. Docker is the same. The ground-work has to be done otherwise it is a game of cat and mouse, and again the same with any hosting environment. Then chuck the OS on top and their respective configurations and it makes it all look messy. With regards to being more expensive we actually save money using Node and Docker. A Droplet is around €6.50 a month on Digital Ocean for the basics of what you need to get going (if you run your database in Docker that is it). Obviously you can configure your Droplet to a higher specification but for the most part and for many this is not necessarily required. Therefore I'm not sure where the more expensive claim lays? Droplets can be backed up for 0.02 Cents per GB, and if you purchase a Database Cluster for €15.00 a month (can host several DBs on there if you wish), it includes daily backups and encryption at rest, then all-in-all it is a total bargain! We hosted our own dedicated servers which run us at about €450.00 a month. Replacing them with Droplets on Digital Ocean has saved us around €400.00 a month, and scaling is simple too! Suppose its all swings and roundabouts when it comes down to it though... Digital Ocean regularly offer a sign-up credit of anywhere between €100.00 - €200.00 so your running costs for the first several months can be virtually nil, and if you don't like it you don't pay. Bargain all-round!

2 Likes

Is that per project? That is about $11.00 a month Canadian. For $3/month Canadian I can host a 10 small projects on the same plan at OrangeHost with no docker or cloud hassles. I'm just too old and cheap to learn these new things you young kids are using these days. :wink:

1 Like

On average yes but this is mostly a Client cost not our cost. When you have Clients used to paying ten times this amount then they are more than happy to switch.

Hahahahaha yeah that Canadian Rupee ain't worth a lot!

:smiley:

If it works for you that is all that matters.

I'm over fifty! Still nice to be refered to as a young kid though!

:smiling_face_with_three_hearts:

It's probably all the cheese you eat.

1 Like

Ironically I don't really like cheese unless it is melted with ham, mushrooms, salami, and peppers! I much prefer the herbal variant. Specifically the U.K variety!

But as you mention it this could be the secret to my newly found youth...

:sunglasses:

1 Like

Compared to me you are! My profile picture is a very old photo :wink:

1 Like