System Architecture
AppFlowy follows a client-first architecture where most business logic runs locally on the client, with optional cloud synchronization for collaboration.Technology Stack
Frontend
- Flutter (v3.13.19+): Cross-platform UI framework
- Dart: Programming language for Flutter
- State Management: BLoC pattern
- FFI Bridge: dart-ffi for Rust interop
Backend
- Rust (v1.70+): High-performance systems language
- SQLite: Local data persistence
- CRDT: Conflict-free replicated data types (Yrs)
- Protobuf: Serialization protocol
Core Components
Flutter Frontend
The Flutter frontend is organized into feature-based modules:- Workspace: Workspace and page management
- Document: Rich text editor with collaborative editing
- Database: Grid, board, calendar, and kanban views
- AI Chat: AI-powered chat and assistance
- User: Authentication and user profile
- Settings: Application configuration
Rust Backend
The Rust backend provides core business logic through modular crates:| Module | Purpose |
|---|---|
flowy-core | Central coordinator and dependency injection |
flowy-user | User authentication and profile management |
flowy-folder | Workspace and folder hierarchy |
flowy-document | Document editing with CRDT |
flowy-database2 | Database views and data management |
flowy-ai | AI integration and services |
flowy-storage | File storage and management |
flowy-search | Full-text search capabilities |
dart-ffi | FFI bridge to Flutter |
lib-dispatch | Event dispatch and routing |
Communication Layer
FFI Bridge
AppFlowy uses Foreign Function Interface (FFI) to enable seamless communication between Flutter (Dart) and Rust:Handler processes request
The appropriate Rust handler processes the request and executes business logic
Event Dispatch System
The event dispatch system (lib-dispatch) provides a type-safe, high-performance request-response mechanism:
Data Synchronization
Local-First Architecture
AppFlowy prioritizes local-first data management:- All data is stored locally in SQLite
- Changes are applied immediately to the local database
- Optional sync to AppFlowy Cloud for collaboration
- Conflict resolution using CRDT algorithms
CRDT Integration
For collaborative editing, AppFlowy uses Conflict-free Replicated Data Types (CRDT):- Based on Yrs (Yjs implementation in Rust)
- Enables real-time collaboration without conflicts
- Supports offline editing with automatic merge on reconnect
Design Principles
Data Privacy First
User data is encrypted and stored locally. Cloud sync is optional and user-controlled.
Native Performance
Rust backend provides native performance for all platforms with minimal overhead.
Cross-Platform
Single codebase supports macOS, Windows, Linux, iOS, and Android.
Extensible
Plugin architecture allows for community-driven features and customization.
Modularity
The architecture emphasizes:- Separation of concerns: Clear boundaries between UI, business logic, and data
- Testability: Each layer can be tested independently
- Maintainability: Features are organized into self-contained modules
- Scalability: New features can be added without modifying core systems
Build Targets
AppFlowy compiles to multiple platforms with platform-specific optimizations:- Desktop
- Mobile
- macOS: Universal binary (arm64 + x86_64)
- Windows: x64 executable
- Linux: x64 and arm64 binaries
The Rust backend is compiled as a static library (.a) for macOS/iOS and a dynamic library (.dll/.so) for Windows/Linux/Android.
Next Steps
Flutter Frontend
Explore the Flutter app structure and state management
Rust Backend
Deep dive into the Rust workspace and core modules