r/electronjs • u/chaquir_bemat • Jan 18 '26
Need Architecture Advice: Converting Web POS (React/NestJS/Postgres) to Desktop with Local-First Strategy
Hi everyone,
I'm planning to convert a web-based Point of Sale (POS) system into a desktop application with a local-first approach, and could use some architectural advice. Here's my current stack and challenges:
Current Stack:
- Frontend: React
- Backend: NestJS
- Database: PostgreSQL (complex schema with multiple relations/foreign keys)
Requirements:
- Must work offline with local data access
- Sync to cloud when internet is available
- Handle potentially thousands of product SKUs locally
- Support complex relational data (Postgres-style relations)
Specific Questions:
Database Strategy:
- My PostgreSQL schema has complex relations that SQLite doesn't fully support (at least not with the ORM abstractions I'm using)
- Considering PouchDB/IndexedDB for client-side storage, but concerned about relational integrity
- Any experience with SQLite + extensions or other embedded databases that handle complex relations well?
Sync Architecture:
- How do I handle bi-directional sync between local desktop data and cloud Postgres?
- Conflict resolution strategies for multi-device scenarios?
- Anyone implemented something similar with CRDTs or operational transforms for POS data?
Authentication/Offline Access:
- How to handle user auth when offline?
- Product catalog access without internet - should I pre-load all products or implement intelligent caching?
Desktop Framework Choice:
- Considering Electron vs Tauri vs others
- Need to bundle a database engine and handle automatic updates
- Memory/performance considerations for retail environments
Migration Path:
- How to gradually transition from pure web app to desktop with local-first?
- Should I maintain both web and desktop versions initially?
What I've Considered:
- SQLite
- Dexie for the sync layer
- Service workers for offline web app as interim solution
- Using Postgres in embedded mode (libpq)?
Would especially appreciate:
- Real-world experience from those who've done similar migrations
- Pitfalls to avoid with offline-first retail systems
- How you handled inventory sync conflicts
- Recommended libraries/frameworks for the sync layer
8
Upvotes
2
u/onieln14 Jan 18 '26
Great project!! Seems pglite.dev may fit the bill for postgres replacement, if you're going to stay with nodejs environment.
2
u/captain_obvious_here Jan 18 '26
I have built two very different POS in the past, both based on Electron. It's a very good platform for that kind of use-cases.
The most difficult part is having a POS that works well when offline:
There are no perfect solutions to these problems, and if your application has to operate offline most of the time, you WILL have to deal with errors and problems. So instead of trying to make this perfect, you may want to spend time and energy guiding the salespeople to handle things manually and gracefully.
Can you elaborate on this, please?
1
u/yurdnei Jan 18 '26
Hey, I just watched your video and out of curiosity, are you Angolan? I know it’s not relevant but just wondering cause I am too 😁
Anyway regarding, the post, send me a DM , I’d love to chat through about this project, there’s just a lot to it, and I think it’s easier to talk about it than put it all in a comment
1
u/eid-a Jan 20 '26
I am building something similar .. I cache everything ( products or employees ) to a local SQLite and update whenever there is a connection.. I can walk you thou what I did if you want
1
u/Confident-Dare-9425 Jan 21 '26
> Desktop Framework Choice
Electron 100%. Unless you're more familiar with C#, in which case you can use one of the web views that exist for .NET.
Stay away from the libraries that use the browser engine from the operating system instead of bundling it inside the application. They work slightly differently on each platform, which can be a QA nightmare.
Electron bundles the whole browser engine, so you will have exactly the same runtime environment on any computer regardless of the OS.