I want to create a desktop application.

The application must be able to accept database transactions even if internet connection is lost, but as soon as internet connection is available the application should start synchronization data to the web server automatically.

What would be a good architectural approach to this?


2 Answers 2


You cannot do a transaction without a connection to the server, that's physically impossible. But you can accept commands and data, e.g. let the user create a new foo.

Have a look into event sourcing. Also take a look at how react.js manages state. These should give you plenty of inspiration and ideas to solve your Problem.

  • You are not getting my points. Yeah there will be server connection but It would be used only if internet connection is available
    – A J
    Jul 2, 2018 at 14:38
  • Does your application logic depend on up-to-date data from your server?
    – marstato
    Jul 2, 2018 at 15:56
  • yes...............
    – A J
    Jul 3, 2018 at 13:47
  • actually there would be two servers local & remote
    – A J
    Jul 3, 2018 at 13:48
  • 1
    Then what i said is totally correct. If your logic depends on the online server, you CANNOT complete a transaction wihtout talking to it. Plain impossible, just like you cannot know what barack obama is thinking right now without actually talking to him. What you can do, is: record what the user intends to do. Then, when you next have a connection, attempt to actually do those things on the server. But that might fail.
    – marstato
    Jul 3, 2018 at 17:41

Seems like you need one of the distributed nosql (not only sql) databases. You will need a local database server. It can synchronise with the remote servers, when it has a connection. You will have eventual consistency.

Have a look at CAP theorem, then at nosql (there are many).

To help with eventual consistency, see non-mutable data.

  • I want to use sqllite as local database and mysql as server side database but I don't know how sync will happen.
    – A J
    Jul 3, 2018 at 20:01
  • It should work if you have one client, but if you have multiple clients. You will have to do some trick things, you will end up with all the consistency of a distributed system, and all of the complexities of relational. Jul 3, 2018 at 23:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.