← back to Watches

MOBILE_PWA_GUIDE.md

446 lines

# Omega Watch Price History - Mobile PWA Guide

## Overview

The Omega Watch Price History app is now a full Progressive Web App (PWA) with extensive mobile features, offline capabilities, and native-like functionality.

## Access the App

**Web URL:** http://45.61.58.125:7600

## PWA Features

### 1. Installable App

#### Android (Chrome/Edge)
1. Visit http://45.61.58.125:7600 on your Android device
2. Tap the menu (three dots)
3. Select "Install app" or "Add to Home Screen"
4. App will appear on your home screen like a native app

You may also see an install banner at the bottom of the screen after 10 seconds.

#### iOS (Safari)
1. Visit http://45.61.58.125:7600 in Safari
2. Tap the Share button (square with arrow)
3. Scroll down and tap "Add to Home Screen"
4. Name it "Omega Prices" and tap "Add"
5. App icon will appear on your home screen

#### Desktop (Chrome/Edge)
1. Visit http://45.61.58.125:7600
2. Look for install icon in address bar (computer with down arrow)
3. Click "Install" to add to desktop

### 2. Offline Capabilities

The app works completely offline after first visit:

**Cached Features:**
- All 32 watch models and data
- Price history charts
- Watch comparisons
- Favorites and watchlist
- Full UI and styling

**What Works Offline:**
- Browse previously viewed watches
- View cached price charts
- Search and filter watches
- Add to favorites
- Compare watches side-by-side
- Dark mode toggle
- All animations and transitions

**Automatic Sync:**
- Changes sync when back online
- Background sync for pending actions
- Smart cache updates

**Offline Indicator:**
- Yellow banner at top when offline
- Green notification when back online
- Seamless transition between states

### 3. Mobile-Optimized UI

**Responsive Design:**
- Optimized layouts for all screen sizes
- Touch-friendly buttons and controls
- Swipe gestures for navigation
- Mobile-first card layouts
- Collapsible sections on small screens

**Performance:**
- Fast loading with skeleton screens
- Lazy loading for images
- Optimized bundle size (255KB main bundle)
- Efficient caching strategy
- Smooth 60fps animations

**Mobile Inputs:**
- 16px font size to prevent iOS auto-zoom
- Clean iOS styling
- Touch-optimized search
- Mobile-friendly filters

### 4. Native Features

#### Web Share API
Share watches with friends:
- Native share sheet on mobile
- Includes watch details and link
- Fallback to clipboard copy

#### Push Notifications (Ready)
Infrastructure in place for:
- Price alerts
- New watch additions
- Market updates
- Custom notifications

To enable:
1. Grant notification permission
2. Subscribe to push notifications
3. Receive alerts even when app is closed

#### App Shortcuts
Long-press app icon to see:
- Dashboard
- Watch List
- Trending Watches

#### Deep Linking
Share direct links to watches:
- http://45.61.58.125:7600?watch=speedmaster-moonwatch-1969
- Links open directly in installed app

### 5. Data Management

#### IndexedDB Storage
- Persistent offline storage
- Stores all watch data locally
- Favorites and watchlist
- Pending sync actions

#### Cache Strategy
- **Static assets:** Cache-first (instant load)
- **API data:** Network-first (fresh data)
- **Images:** Cache-first (fast display)
- **Stale-while-revalidate:** Updates in background

#### Storage Limits
- Typical: 50-100MB available
- Efficient compression
- Automatic cache cleanup

### 6. Performance Metrics

**Loading Times:**
- First load: ~2-3 seconds
- Subsequent loads: <1 second (cached)
- Offline load: Instant

**Bundle Sizes:**
- Main JavaScript: 255KB (74KB gzipped)
- Charts library: 207KB (70KB gzipped)
- Animations: 115KB (37KB gzipped)
- Styles: 17KB (4KB gzipped)
- Total: ~627KB (195KB gzipped)

**Lighthouse Scores** (Target):
- Performance: 90+
- Accessibility: 95+
- Best Practices: 100
- SEO: 100
- PWA: 100

## Installation Instructions

### For Users

1. **Visit the App**
   - Go to http://45.61.58.125:7600 on mobile or desktop

2. **Install (Optional but Recommended)**
   - Follow platform-specific instructions above
   - Enjoy native app experience

3. **Use Offline**
   - Browse once while online
   - Data cached automatically
   - Works completely offline afterwards

4. **Stay Updated**
   - App updates automatically
   - Service worker manages updates
   - No manual updates needed

### For Developers

#### Prerequisites
```bash
Node.js 18+
npm or yarn
```

#### Setup
```bash
cd /root/Projects/watches

# Install dependencies
npm install

# Run development server
npm run dev

# Build for production
npm run build

# Start production server
npm start
```

#### PWA Files Structure
```
/root/Projects/watches/
├── public/
│   ├── service-worker.js       # Service worker for offline
│   ├── manifest.json            # PWA manifest
│   ├── offline.html             # Offline fallback page
│   └── icons/                   # App icons (various sizes)
│       ├── icon-72x72.png
│       ├── icon-96x96.png
│       ├── icon-128x128.png
│       ├── icon-144x144.png
│       ├── icon-152x152.png
│       ├── icon-192x192.png
│       ├── icon-384x384.png
│       └── icon-512x512.png
├── src/
│   ├── components/
│   │   ├── InstallPrompt.jsx   # Install banner
│   │   ├── OfflineIndicator.jsx # Offline status
│   │   └── ShareButton.jsx      # Native sharing
│   └── utils/
│       ├── pwaUtils.js          # PWA utilities
│       └── offlineStorage.js    # IndexedDB wrapper
└── utils/
    └── generate-icons.js        # Icon generator
```

#### Generate Icons
```bash
# Generate SVG icons
node utils/generate-icons.js

# Convert to PNG (open in browser)
# Visit: http://45.61.58.125:7600/icons/icon-converter.html
# Right-click each canvas and save as PNG
```

## Technical Details

### Service Worker

**Cache Names:**
- `omega-watches-v1.0.0` - Static assets
- `omega-api-cache-v1.0.0` - API responses
- `omega-images-v1.0.0` - Watch images

**Caching Strategy:**
- Static assets: Cache-first
- API data: Network-first with cache fallback
- Images: Cache-first with network fallback

**Update Mechanism:**
- Automatic update checks every 60 seconds
- Shows update notification when available
- User can refresh to get new version

### Offline Storage

**IndexedDB Structure:**
- `watches` - All watch data
- `favorites` - User favorites
- `watchlist` - User watchlist
- `pendingActions` - Sync queue
- `cacheMetadata` - Cache stats

**Storage Management:**
- Automatic cleanup of old data
- Storage quota management
- Compression for efficiency

### Mobile Optimization

**CSS:**
- Mobile-first breakpoints
- Touch-friendly sizes (44px minimum)
- Optimized fonts for mobile
- Hardware-accelerated animations

**JavaScript:**
- Code splitting by route
- Lazy component loading
- Debounced scroll handlers
- Efficient re-renders with React

**Network:**
- Aggressive caching
- Prefetching critical resources
- Background sync when available
- Offline queue for actions

## Browser Support

### Fully Supported
- Chrome 90+ (Android/Desktop)
- Edge 90+ (Android/Desktop)
- Safari 15+ (iOS/macOS)
- Firefox 88+ (Android/Desktop)
- Samsung Internet 14+

### Partial Support
- Opera Touch
- UC Browser
- Brave Browser

### Not Supported
- Internet Explorer (any version)
- Legacy browsers without service worker support

## Future Enhancements

### Planned Features

1. **Camera Integration**
   - Scan watch serial numbers
   - Visual watch identification
   - AR try-on feature

2. **Biometric Authentication**
   - Touch ID / Face ID support
   - Secure favorites
   - Protected watchlist

3. **Location Features**
   - Dealer finder
   - Auction locations
   - Local watch events

4. **Enhanced Notifications**
   - Price drop alerts
   - Watchlist updates
   - Market trend notifications

5. **Social Features**
   - Share collections
   - Compare with friends
   - Community insights

6. **Advanced Analytics**
   - ML price predictions
   - Market sentiment analysis
   - Investment recommendations

7. **Wallet Integration**
   - Apple Pay support
   - Google Pay support
   - Payment for premium features

8. **App Store Distribution**
   - Native iOS app wrapper
   - Native Android app wrapper
   - Distribution via app stores

## Troubleshooting

### PWA Not Installing

**Android:**
- Check Chrome is updated
- Clear browser cache
- Ensure manifest.json loads correctly

**iOS:**
- Use Safari (only browser with PWA support on iOS)
- Check iOS version (13+)
- Manually add to home screen

### Offline Mode Not Working

1. Check service worker registration in DevTools
2. Clear cache and reload page once while online
3. Verify IndexedDB has watch data
4. Check console for errors

### Slow Performance

1. Clear app cache
2. Uninstall and reinstall PWA
3. Check network throttling is disabled
4. Verify device has sufficient storage

### Updates Not Applying

1. Close all app instances
2. Clear cache
3. Reload page
4. Accept update notification when shown

## Testing

### Manual Testing Checklist

- [ ] Install on Android device
- [ ] Install on iOS device
- [ ] Test offline functionality
- [ ] Verify cache is working
- [ ] Test share functionality
- [ ] Check responsive layouts
- [ ] Test dark mode
- [ ] Verify deep linking
- [ ] Test all watch pages
- [ ] Check comparison tool
- [ ] Verify search/filters
- [ ] Test performance

### DevTools Testing

```javascript
// Check service worker status
navigator.serviceWorker.ready.then(reg => {
  console.log('Service Worker Ready:', reg);
});

// Check cache
caches.keys().then(console.log);

// Check storage
navigator.storage.estimate().then(console.log);

// Force update
navigator.serviceWorker.getRegistration().then(reg => {
  reg.update();
});
```

## Support

For issues, questions, or feature requests:
- Check the main README.md
- Review console logs in browser DevTools
- Test in incognito/private mode
- Try clearing cache and data

## License

Educational purposes only. Omega is a registered trademark of Swatch Group.

---

**Last Updated:** November 17, 2025
**Version:** 1.0.0
**Server:** http://45.61.58.125:7600