A production-ready Flutter application demonstrating true offline-first architecture using Isar (local database) and Appwrite (backend) with clean architecture principles and intelligent auto-sync.
Note: This implementation uses
isar_communitypackage (version 3.3.0-dev.3) with Appwrite's latest TablesDB API for optimal performance and future compatibility.
-
π Automatic Sync: Zero-configuration auto-sync based on connectivity
- Online: Changes sync to cloud immediately
- Offline: Changes saved locally and queued for sync
- Reconnect: Pending changes sync automatically within seconds
- No Manual Sync Required: Works like Google Docs, Notion, etc.
-
π± Offline-First: Full functionality without internet connection
- All data stored locally first using Isar
- Real-time UI updates from local database
- Seamless transition between online/offline modes
-
π Project Management: Complete CRUD operations
- Create, edit, and delete projects
- Track budget, dates, and status
- Beautiful Material Design 3 UI
-
β Task Management: Organize work within projects
- Manage tasks with due dates
- Link tasks to projects
- Real-time task updates
-
β‘ Smart Conflict Resolution:
- Last-Write-Wins (LWW) for edits based on timestamps
- Deletion-First: Deletions always take priority over edits
- Prevents accidental data restoration
-
ποΈ Clean Architecture: Production-ready code structure
- Domain, Data, and Presentation layers
- Dependency injection via Riverpod
- Testable and maintainable
-
π Connectivity-Aware: Intelligent network handling
- Real-time connectivity monitoring
- Graceful degradation when offline
- Visual indicators for online/offline status
The app follows clean architecture with a hybrid repository pattern for auto-sync:
lib/
βββ core/
β βββ services/ # Core services
β βββ connectivity_service.dart # Network monitoring
β βββ sync_orchestrator.dart # Background sync
βββ domain/
β βββ entities/ # Business entities (Project, Task)
β βββ repositories/ # Repository interfaces
βββ data/
β βββ models/ # Data models with Isar & Appwrite mappings
β βββ datasources/ # Data sources
β β βββ local/ # Isar (local database)
β β βββ remote/ # Appwrite TablesDB (cloud)
β βββ repositories/ # Repository implementations
β βββ *_hybrid_repository.dart # Auto-sync repositories (NEW!)
β βββ *_repository_impl.dart # Legacy local/remote repos
βββ presentation/
βββ providers/ # Riverpod providers & state
βββ screens/ # UI screens (Projects, Tasks, Forms)
The Hybrid Repository automatically routes operations based on connectivity:
User Action β Hybrid Repository
β
Check Connectivity
β β
Online Offline
β β
Remote Local
+ Cache (needsSync)
β β
Local DB β β β β
β
UI Stream
Benefits:
- No manual sync button clicks
- Automatic fallback on network errors
- Local-first UI for instant feedback
- Smart caching strategy
- Flutter 3.x: Cross-platform UI framework
- Isar Community 3.3.0-dev.3: Fast local NoSQL database with real-time queries
- Appwrite 20.3.0: Backend as a Service (using TablesDB API)
- Riverpod 3.0: Modern state management and dependency injection
- Connectivity Plus: Real-time network status monitoring
- UUID: Unique identifier generation
- Flutter Dotenv: Environment configuration
See QUICK_START.md for a quick overview of the auto-sync feature.
- Flutter 3.x or higher
- Dart 3.0 or higher
- FVM (recommended for version management)
- An Appwrite account (free at cloud.appwrite.io)
flutter pub getdart run build_runner build --delete-conflicting-outputsOption A: Use the Setup Script (Recommended) See SETUP.md for detailed Appwrite configuration instructions.
Option B: Manual Setup
- Create an Appwrite account at cloud.appwrite.io
- Create a new project
- Create a database
- Create two tables (collections):
Projects Table:
Table ID: projects
Attributes:
- projectName (string, 128 chars)
- description (string, 1000 chars)
- startDate (datetime, optional)
- endDate (datetime, optional)
- budget (double)
- status (string, 50 chars)
- createdAt (datetime, required)
- updatedAt (datetime, required)
- isDeleted (boolean, default: false)
Tasks Table:
Table ID: tasks
Attributes:
- name (string, 128 chars)
- description (string, 1000 chars)
- dueDate (datetime, optional)
- projectId (string, 36 chars)
- createdAt (datetime, required)
- updatedAt (datetime, required)
- isDeleted (boolean, default: false)
- Create
environments/.env.local:
APPWRITE_ENDPOINT=https://cloud.appwrite.io/v1
APPWRITE_PROJECT_ID=your_project_id_here
APPWRITE_DATABASE_ID=your_database_id_here
APPWRITE_PROJECTS_COLLECTION_ID=projects
APPWRITE_TASKS_COLLECTION_ID=tasks- Get your IDs from Appwrite Console β Settings
# Using FVM (recommended)
fvm flutter run
# Or standard Flutter
flutter run
# For specific environment
flutter run --dart-define=ENV=localThat's it! The app will automatically handle sync based on connectivity. β¨
User creates/edits/deletes β Hybrid Repository
β
Try write to Remote (Appwrite)
β
Success? β Update Local Cache
β
UI Updates Instantly
Result: Changes sync to cloud immediately. Available on all devices.
User creates/edits/deletes β Hybrid Repository
β
Save to Local (Isar)
β
Mark needsSync = true
β
UI Updates Instantly
Result: Changes saved locally. Will sync when back online.
Connectivity Restored
β
Sync Orchestrator Triggered
β
1. Push pending local changes (needsSync=true)
2. Pull remote changes from other devices
3. Apply smart conflict resolution
4. Update local cache
β
All Devices In Sync!
Timing: Usually syncs within 1-5 seconds of reconnection.
For Edits - Last Write Wins (LWW):
Device A edits at 10:00 AM β updatedAt: 10:00
Device B edits at 11:00 AM β updatedAt: 11:00
Sync β Device B wins (newer timestamp)
For Deletions - Deletion Always Wins:
Device A deletes at 10:00 AM β isDeleted: true
Device B edits at 11:00 AM β isDeleted: false
Sync β Device A wins (deletion takes priority)
Why? Deletions are intentional user actions that should take precedence over any edit, preventing accidental data restoration.
When fetching from remote, the hybrid repository:
- Checks if local has
needsSync: true - If yes, keeps local version (don't overwrite pending changes)
- If no, updates with remote version
- Sync orchestrator then pushes pending changes
This ensures offline changes are never lost when going back online.
ProjectHybridRepository: Routes project operations based on connectivityTaskHybridRepository: Routes task operations based on connectivity- Automatically writes to remote when online
- Falls back to local when offline
- Preserves pending changes (
needsSync: true)
- Monitors connectivity changes via
ConnectivityService - Triggers sync immediately on reconnection
- Performs periodic sync every 5 minutes when online
- Implements deletion-first + LWW conflict resolution
- Manages sync status (idle, syncing, success, error)
Local (Isar):
IsarLocalDatasource: Base Isar implementationProjectLocalDatasource: Project-specific operationsTaskLocalDatasource: Task-specific operations- Fast NoSQL database with real-time queries
- Watches for data changes via streams
Remote (Appwrite TablesDB):
AppwriteRemoteDatasource: Base Appwrite client setupAppwriteProjectRemoteDatasource: Project cloud operationsAppwriteTaskRemoteDatasource: Task cloud operations- Uses latest TablesDB API (not deprecated Databases API)
- Easily swappable with Supabase, Firebase, etc.
ConnectivityService: Real-time network monitoringSyncOrchestrator: Coordinates sync operations- Both initialized automatically via Riverpod
- Auto-Sync Architecture: Zero-config automatic synchronization
- Hybrid Repository Pattern: Smart online/offline routing
- Deletion-First Sync: Deletions always take priority
- Appwrite TablesDB Integration: Using latest non-deprecated API
- Complete CRUD: Projects and tasks fully functional
- Conflict Resolution: LWW for edits, deletion-first for removals
- Real-time UI: Local-first with instant updates
- Connectivity Monitoring: Live online/offline indicators
- Clean Architecture: Production-ready code structure
- State Management: Riverpod with dependency injection
- Error Handling: Graceful fallbacks and user feedback
- Material Design 3: Beautiful, modern UI
- β Create/edit/delete projects while online β Syncs immediately
- β Create/edit/delete projects while offline β Syncs on reconnect
- β Delete project offline β Deletion syncs correctly (not restored)
- β Multi-device scenario β Changes merge correctly
- β Network errors β Graceful fallback to local
- β Timestamp conflicts β LWW resolution works
- β Flutter analyze β No issues or deprecated members
Phase 1 - Core Features:
- User authentication and authorization
- Multi-user collaboration
- Real-time sync using Appwrite Realtime API
- Pagination for large datasets
Phase 2 - Extended Features:
- File attachments and media
- Advanced search and filtering
- Data export (CSV, PDF)
- Analytics and reports
- Notifications and reminders
Phase 3 - Polish:
- Dark mode
- Offline indicators on items
- Sync queue UI (show pending changes)
- Retry mechanism with exponential backoff
- Data compression for faster sync
- QUICK_START.md - Quick reference guide
- AUTO_SYNC_GUIDE.md - Complete technical architecture
- IMPLEMENTATION_SUMMARY.md - What changed and why
- CHANGES.md - Detailed change log
- SETUP.md - Appwrite configuration guide
- ARCHITECTURE.md - System architecture details
flutter testflutter test integration_test# Using FVM
fvm flutter analyze
# Standard Flutter
flutter analyzeNone! All major issues have been resolved:
- β Offline deletions now sync correctly
- β No deprecated API warnings
- β Pending changes preserved during reconnection
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
MIT License - see LICENSE file for details
- Isar - Fast and lightweight NoSQL database
- Appwrite - Open-source Backend as a Service
- Riverpod - Modern Flutter state management
- Flutter Team - Amazing framework
For questions or issues:
- Check the documentation
- Review ARCHITECTURE.md for technical details
- Open an issue on GitHub
Built with β€οΈ using Flutter and Offline-First principles
Last Updated: November 2025