Overview
Paw & Care iOS app supports full offline functionality, allowing veterinarians to continue clinical workflows even without internet connectivity. All data is stored locally and automatically synced when the connection is restored. Offline Capabilities:- Full read access to previously loaded data
- Queue-based write operations
- Automatic background sync when online
- Conflict resolution for concurrent edits
How Offline Mode Works
Data Storage Strategy
The app uses a multi-tiered storage approach:IndexedDB
Primary storage for patient records, appointments, and medical notes. Provides structured querying and large storage capacity.
LocalStorage
Fallback storage for SOAP notes and draft records. Used when Supabase is not configured.
Memory Cache
In-memory cache for frequently accessed data like templates and recent patients.
Supabase Local-First
When configured, uses Supabase real-time subscriptions with local caching.
Network Detection
The app automatically detects connectivity status:Offline Workflows
Reading Data
All previously loaded data remains accessible offline: Available Offline:- Patient records (pets, owners, medical history)
- Appointment schedule
- Medical record templates
- Recent SOAP notes
- Clinical insights from last session
- Real-time call monitoring
- New AI-generated content (requires server)
- Fresh dashboard metrics
- New appointment bookings from phone system
Creating Records Offline
When creating medical records offline, the app uses a queue-based system:Save to local storage
Record is saved to localStorage with offline flag:See
src/sections/DictationSOAP.tsx:432-443.Updating Existing Data
Updates to existing records follow a last-write-wins strategy: Conflict Resolution:- No conflict: Local version is newer → upload to server
- Server newer: Prompt user to review changes and merge manually
- Concurrent edits: Show diff view and allow user to choose version
Offline Features by Section
Dictation & SOAP Notes
Fully Offline:- Audio recording (stored locally as WebM)
- Manual text entry
- File upload (PDF, images, audio)
- Draft saving
- AI transcription (OpenAI Whisper API)
- SOAP note generation (OpenAI GPT-4)
- Clinical insights
src/sections/DictationSOAP.tsx:129-163 for implementation.
Patient Records
Offline Access:- View all previously loaded patient profiles
- Search and filter local patient database
- View medical history and attachments
- Add photos using device camera
- Update patient information
- Add vaccination records
- Create new patients
Appointments
Offline View:- Today’s appointment schedule
- Next 7 days of appointments
- Appointment details and notes
- Mark appointments as checked-in
- Add appointment notes
- Update appointment status
- Cannot create new appointments (requires server validation)
- No real-time updates from AI phone system
Dashboard
Offline Mode: Dashboard shows cached metrics with “Last updated” timestamp:Sync Queue Management
Queue Structure
The sync queue is an ordered list of pending operations:Sync Process
Retry Logic
Storage Limits
iOS Storage Quotas
WebView storage limits on iOS:| Storage Type | Typical Limit | Notes |
|---|---|---|
| IndexedDB | 50-500 MB | Depends on available device storage |
| LocalStorage | 5-10 MB | Limited, use for small data only |
| Cache API | 50 MB | For static assets |
| Total WebView | ~1 GB | iOS may clear if storage is low |
Managing Storage
Best Practices:- Store only essential data locally (last 30 days of records)
- Compress large files before storing
- Periodically clean up old cached data
- Prompt user when storage is >80% full
Offline Indicators
UI Feedback
The app provides clear offline status indicators:Status Badge
Persistent “Offline” badge in the header when network is unavailable.
Sync Status
Spinning sync icon when operations are being queued or synced.
Disabled Features
Grayed out buttons for features that require online connectivity.
Toast Notifications
Notifications when going offline/online and when sync completes.
User Messaging
Going Offline:Testing Offline Mode
Simulating Offline Conditions
Network Link Conditioner (iOS)
On device:
- Install Network Link Conditioner from Apple Developer Tools
- Enable various network conditions (3G, Edge, 100% Loss)
Chrome DevTools (Web)
During development:
- Open DevTools (F12)
- Go to Network tab
- Select Offline from throttling dropdown
Test Scenarios
Critical Workflows to Test:- Create new SOAP note while offline → go online → verify sync
- Update patient record offline → update same record online elsewhere → test conflict resolution
- Record audio offline → upload when online → verify transcription
- Load app offline → verify dashboard shows cached data
- Toggle network rapidly → ensure queue doesn’t duplicate operations
Advanced Configuration
Sync Settings
Configure offline behavior in your app:Background Sync
iOS Background Modes can enable sync while app is backgrounded: Enable in Xcode:- Select project → Signing & Capabilities
- Add Background Modes capability
- Check Background fetch
- Check Background processing
Troubleshooting
Sync Not Working
Check:- Verify network connectivity with ping to server
- Check browser console for sync errors
- Inspect sync queue:
localStorage.getItem('sync_queue') - Ensure Supabase client is initialized correctly
Data Loss
Prevention:- Never clear localStorage without user confirmation
- Always backup queued operations before clearing
- Use Supabase real-time subscriptions for critical data
- Implement periodic cloud backups
Duplicate Records
Causes:- Multiple sync attempts without proper deduplication
- Concurrent writes from different devices
- Use unique ID generation (
local-${Date.now()}-${Math.random()}) - Check for existing records before creating new ones
- Implement idempotent sync operations
Best Practices
Optimize for Offline
Assume offline-first. Design workflows that work without connectivity.
Clear Feedback
Always show sync status and queue progress to users.
Graceful Degradation
Disable features that require online, but keep core workflows functional.
Test Extensively
Test all offline scenarios including edge cases and network transitions.
Next Steps
iOS App
Learn about the iOS app architecture and setup
Dictation
Explore voice recording features and offline transcription
Native Features
Discover Capacitor plugins for native iOS functionality
Database
Understand Supabase schema and sync strategies