1

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.

1

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Yeah, I started to use Electric SQL, but missing things like Permissions, that should come soon, but still in beta and not for production..., I'll look at Triplit
Triplit looks really great. I think I'll use it, then for everything based on auth, etc, i'll do my backend with Adonis. Thanks for sharing!
1

Sibling comment mentioned ElectricSQL.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.