@@ -43,7 +43,7 @@ Swach is a modern color palette manager built as a menubar/system tray Electron
4343- ** Build Tool** : Vite (via @embroider/vite for fast dev and optimized production)
4444- ** Desktop** : Electron with Electron Forge (menubar app using ` menubar ` package)
4545- ** Data Layer** : Orbit.js (client-side ORM with sync strategies)
46- - ** Storage** : IndexedDB (local), AWS Cognito + API Gateway (cloud sync )
46+ - ** Storage** : IndexedDB (local), Supabase (auth + remote database )
4747- ** Color Picker** : Custom Rust binary for cross-platform pixel sampling
4848
4949### Ember + Electron Integration
@@ -88,20 +88,26 @@ Swach uses Orbit.js for sophisticated offline-first data management with three s
8888** Data Sources** (` app/data-sources/ ` ):
8989- ` store ` - In-memory cache (primary interface, ember-orbit Store)
9090- ` backup ` - IndexedDB persistence (local backup)
91- - ` remote ` - JSON : API remote sync (AWS API Gateway, authenticated users only)
91+ - ` remote ` - Supabase backend ( authenticated users only)
9292
9393** Models** (` app/data-models/ ` ):
9494- ` palette ` - Collection of colors with metadata (name, isColorHistory, isFavorite, isLocked, colorOrder array)
9595- ` color ` - Individual color with RGBA values, computed hex/hsl/rgba getters
9696
9797** Sync Strategies** (` app/data-strategies/ ` ):
98- Coordinate data flow between sources. Key strategies :
99- - ` store-backup-sync ` - Persist all store changes to IndexedDB backup
100- - ` store-beforequery-remote-query ` - Query remote before local queries ( when authenticated)
101- - ` store-beforeupdate-remote-update ` - Push local updates to remote ( when authenticated)
102- - ` remote-store-sync ` - Pull remote changes to store
98+ Coordinate data flow between sources. Orbit handles ALL data synchronization :
99+ - ` store-backup-sync ` - Persist all store changes to IndexedDB backup (blocking)
100+ - ` store-beforequery-remote-query ` - Query remote before local queries when authenticated (non-blocking )
101+ - ` store-beforeupdate-remote-update ` - Push local updates to remote when authenticated (non-blocking, optimistic UI )
102+ - ` remote-store-sync ` - Pull remote changes to store (blocking)
103103- Error handling strategies for remote failures
104104
105+ ** Sync Behavior** :
106+ - Initial sync on app startup fetches all palettes/colors from Supabase
107+ - Local changes are immediately reflected (optimistic UI), then synced to remote in background
108+ - Pull-based sync before queries ensures fresh data when needed
109+ - No realtime subscriptions - sync is handled via Orbit's strategies only
110+
105111** Data Service** (` app/services/data.ts ` ):
106112- Manages coordinator activation and synchronization
107113- Ensures single color history palette exists
@@ -139,20 +145,26 @@ Coordinate data flow between sources. Key strategies:
139145
140146### Authentication & Cloud Sync
141147
142- ** AWS Cognito** (` ember-cognito ` addon):
143- - User pools for authentication
144- - Identity pools for AWS credentials
145- - Config in ` config/environment.js ` (poolId, clientId, identityPoolId)
148+ ** Supabase** :
149+ - Authentication via email OTP (passwordless)
150+ - Remote database (PostgreSQL) for palettes and colors
151+ - Row-level security ensures users only access their own data
152+ - Config in ` config/environment.js ` (supabaseUrl, supabaseAnonKey)
146153
147154** Session Service** (` app/services/session.ts ` ):
148- - Wraps ember-simple-auth session
149- - Provides ` isAuthenticated ` state
155+ - Manages authentication state
156+ - Provides ` isAuthenticated ` and ` userId ` properties
157+
158+ ** Supabase Service** (` app/services/supabase.ts ` ):
159+ - Provides Supabase client instance
160+ - Used ONLY for auth and as remote API
161+ - No realtime subscriptions - all sync is handled by Orbit
150162
151- ** Remote Sync** :
163+ ** Remote Sync** ( ` app/data-sources/remote.ts ` ) :
152164- Only activates when user is authenticated
153- - JSON : API communication with AWS API Gateway
154- - Coordinates palettes and colors bidirectionally
155- - Handles conflict resolution (remote preferred for color history palette)
165+ - Implements Orbit source interface for Supabase backend
166+ - Transforms between Orbit records and Supabase rows
167+ - All synchronization coordinated by Orbit strategies, not Supabase realtime
156168
157169### Component Structure
158170
0 commit comments