@@ -37,7 +37,7 @@ Swach is a modern color palette manager built as a menubar/system tray Electron
3737- ** Build Tool** : Vite (via @embroider/vite for fast dev and optimized production)
3838- ** Desktop** : Electron with Electron Forge (menubar app using ` menubar ` package)
3939- ** Data Layer** : Orbit.js (client-side ORM with sync strategies)
40- - ** Storage** : IndexedDB (local), AWS Cognito + API Gateway (cloud sync )
40+ - ** Storage** : IndexedDB (local), Supabase (auth + remote database )
4141- ** Color Picker** : hue-hunter package (cross-platform magnifying color picker with Rust-powered pixel sampling)
4242
4343### Ember + Electron Integration
@@ -83,20 +83,26 @@ Swach uses Orbit.js for sophisticated offline-first data management with three s
8383** Data Sources** (` app/data-sources/ ` ):
8484- ` store ` - In-memory cache (primary interface, ember-orbit Store)
8585- ` backup ` - IndexedDB persistence (local backup)
86- - ` remote ` - JSON : API remote sync (AWS API Gateway, authenticated users only)
86+ - ` remote ` - Supabase backend ( authenticated users only)
8787
8888** Models** (` app/data-models/ ` ):
8989- ` palette ` - Collection of colors with metadata (name, isColorHistory, isFavorite, isLocked, colorOrder array)
9090- ` color ` - Individual color with RGBA values, computed hex/hsl/rgba getters
9191
9292** Sync Strategies** (` app/data-strategies/ ` ):
93- Coordinate data flow between sources. Key strategies :
94- - ` store-backup-sync ` - Persist all store changes to IndexedDB backup
95- - ` store-beforequery-remote-query ` - Query remote before local queries ( when authenticated)
96- - ` store-beforeupdate-remote-update ` - Push local updates to remote ( when authenticated)
97- - ` remote-store-sync ` - Pull remote changes to store
93+ Coordinate data flow between sources. Orbit handles ALL data synchronization :
94+ - ` store-backup-sync ` - Persist all store changes to IndexedDB backup (blocking)
95+ - ` store-beforequery-remote-query ` - Query remote before local queries when authenticated (non-blocking )
96+ - ` store-beforeupdate-remote-update ` - Push local updates to remote when authenticated (non-blocking, optimistic UI )
97+ - ` remote-store-sync ` - Pull remote changes to store (blocking)
9898- Error handling strategies for remote failures
9999
100+ ** Sync Behavior** :
101+ - Initial sync on app startup fetches all palettes/colors from Supabase
102+ - Local changes are immediately reflected (optimistic UI), then synced to remote in background
103+ - Pull-based sync before queries ensures fresh data when needed
104+ - No realtime subscriptions - sync is handled via Orbit's strategies only
105+
100106** Data Service** (` app/services/data.ts ` ):
101107- Manages coordinator activation and synchronization
102108- Ensures single color history palette exists
@@ -133,20 +139,26 @@ Coordinate data flow between sources. Key strategies:
133139
134140### Authentication & Cloud Sync
135141
136- ** AWS Cognito** (` ember-cognito ` addon):
137- - User pools for authentication
138- - Identity pools for AWS credentials
139- - Config in ` config/environment.js ` (poolId, clientId, identityPoolId)
142+ ** Supabase** :
143+ - Authentication via email OTP (passwordless)
144+ - Remote database (PostgreSQL) for palettes and colors
145+ - Row-level security ensures users only access their own data
146+ - Config in ` config/environment.js ` (supabaseUrl, supabaseAnonKey)
140147
141148** Session Service** (` app/services/session.ts ` ):
142- - Wraps ember-simple-auth session
143- - Provides ` isAuthenticated ` state
149+ - Manages authentication state
150+ - Provides ` isAuthenticated ` and ` userId ` properties
151+
152+ ** Supabase Service** (` app/services/supabase.ts ` ):
153+ - Provides Supabase client instance
154+ - Used ONLY for auth and as remote API
155+ - No realtime subscriptions - all sync is handled by Orbit
144156
145- ** Remote Sync** :
157+ ** Remote Sync** ( ` app/data-sources/remote.ts ` ) :
146158- Only activates when user is authenticated
147- - JSON : API communication with AWS API Gateway
148- - Coordinates palettes and colors bidirectionally
149- - Handles conflict resolution (remote preferred for color history palette)
159+ - Implements Orbit source interface for Supabase backend
160+ - Transforms between Orbit records and Supabase rows
161+ - All synchronization coordinated by Orbit strategies, not Supabase realtime
150162
151163### Component Structure
152164
0 commit comments