skip to Main Content

Context

Hello, I have some questions about a project, and my ideas are not that clear.

I would create a local first application with ElectronJS, so basically store some data like user data, user history…

But I also want to send that data to a distant server when is online, to have some cloud features, and other features only available online. (To AdonisJS back)

My question now is: How can I setup this project ?

I thought about many solutions, like:

  • Have a datamanager on my local-first application, that will handle all changes from the user, store them if the user is offline to send them later.

  • Using something like PounchDB or RXDB

BUT

I want to avoid code duplication, and all the work related too, so basically do a pnpm monorepo or SDK or something like that to share requests, that the client will do its own requests with this code, and the server too.

I thought to use TRPC too…

Question

So, someone have an idea about the architecture I can have with this project? What technologies use? What will make my life easier.

The stack I want to use:

  • AdonisJS
  • ElectronJS

I’ve tried nothing for the moment, I really want to find the best stack and architecture for this project.

2

Answers


  1. If are willing to write a lot of syncing code you can use use RxDB, SQLite, WatermelonDB, or any other client-side database to durable store local state.

    If you want something that allows you to write a single Schema in Typescript and have that syncs to the server automatically while also being entirely local first, I’d recommend checking out Triplit.

    If you are tied to writing your own backend (e.g. in Adonis like you mentioned), you could setup a GraphQL backend to sync with either RxDB or a GraphQL client lib like URQL or Apollo. But fair warning that it is easy to create insidious bugs that only show up once you’re deployed to production and have multiple users using your app. I strongly recommend using something like Triplit or Electric SQL which have strong distributed systems foundations.

    Login or Signup to reply.
  2. Sibling comment mentioned ElectricSQL.

    In a similar vein to that, you can also consider PowerSync: https://www.powersync.com/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search