IONIC app with its own backend

Hi, I am planning to develop an app which will hold the backend and database in the phone (no external API or cloud allowed)

Is this possible with IONIC? I am new to IONIC and I can’t find examples of a similar scenario.

Thanks

Hi You can use Data Storage to store data in phone.

Thanks Alita, that seems to have support to save key/value pairs and even sqllite but where the backend can run? Is it possible to have a backend say nodejs or NET core running withing the app?

Can you explain why you would want to do this? At first glance, it would seem to be introducing lots of complexity and overhead on what is typically the most resource-starved aspect of an Ionic app ecosystem - the phone. I can’t think of an upside.

Hi rapropos,

The information that this app will gather from users is sensitive and don’t want to get trouble of data breaches handling this information in a server. Also it adds peace of mind to users knowing their I formatio wont leave the phone (unless they make a backup and store it somewhere else which any way will be user’s responsibility). Additionally the I formation gathered doesn’t need to be shared so for me it makes sense having everything within the app. I have used other apps with similar approach i.e. Home Budget.

I have been consireding other Frameworks like Flutter where this would be possible without any complexity. I am a full stack developer with some experience in Angular and React in frontend and NodeJS and NET core in backed so I am trying to find out if IONIC will support this use case, otherwise will need to learn dart and flutter.

Thanks.

In that case, I wouldn’t even have a “backend” in the traditional sense.

A well-structured (IMHO, at least) “backend”-having Angular application already has a bright line of demarcation between the presentation layer (pages and components) and the business object data layer (service providers that talk to the “backend” over a network).

So your presentation layer should already be totally isolated from HTTP - it should only be injecting services that provide things like Observable<BusinessObject[]>. It should be straightforward for you to short-circuit a typical HttpClient.get() idiom in the service with something that speaks directly to SQLite.

There is a community Capacitor SQLite plugin that gives you access to the full SQL API of SQLite. If you’re planning on doing middleware logic in Node.js anyway, you might as well just write the “backend” as an elaborate Angular service.

That will be more performant and easier to configure. The only downside I can think of would be that it would be more work to change your mind later and actually break things out to a real networked backend. It would also protect you from the irritation that I would think would be inevitable that a typical “real backend” (and the libraries that one would tend to use therein) are going to expect they’re running on a real OS as opposed to the paranoid sandbox environment that is iOS or Android.

1 Like

That sounds like a good alternative instead of thinking of a real backend given the limitation I have, I will look into that in more detail to consider this option, I agree that everything will be kind of mix up but with a good design it might be workable.

Thank you very much