Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What should I use as backend in electron application? [closed]

I understand I can design the UI with HTML CSS JavaScript or any other frontend framework. I even understand that I can connect to any remote API. what if I want a standalone application with database. How should I connect to the database ? where should I write my application logic? I feel like there is a missing part in electron do I supposed to use a node JS web Framework like Express? or I should write all the program logics in pure node JS without using any framework? What is the best approach to write electron applications if possible please point me any working example.

like image 266
Adi Avatar asked Dec 14 '22 15:12

Adi


1 Answers

It is entirely up to you.

While the client/server (frontend/backend) model we've got used to in web applications is a good idea (separation of concerns), it's not the only way to do things when the client and the server are on the same machine.

Electron is built on top of Node.js. So you can use the usual npm modules in order to connect to whatever database system you want to use and do away with frameworks. For example you can write code to fetch data from the database right into your onclick event handler if you desire so.

Having said that, odds are you will find yourself dealing with an unmanageable bunch of spaghetti code if you're not careful. So, some kind of structure is recommended even if you don't want an entire client/server system.

Also, your "client" and your "server" don't have to communicate through HTTP. The interface can be just plain function (and/or method) calls. Electron also has a message passing system (for example: https://electronjs.org/docs/api/ipc-main that you may use.

like image 77
cyco130 Avatar answered Dec 28 '22 10:12

cyco130