Workspace Structure
The Rust codebase is located infrontend/rust-lib/ and organized as a Cargo workspace:
Core Modules
dart-ffi - FFI Bridge
The FFI layer bridges Dart/Flutter with Rust:
Purpose
Exposes Rust functions to Dart through C-compatible FFI
Crate Type
Compiled as staticlib (macOS/iOS) or cdylib (Windows/Linux/Android)
- Receives events from Flutter through FFI
- Marshals data between Dart and Rust
- Routes events to the dispatch system
- Sends responses back to Flutter
flowy-core - Central Coordinator
The core module orchestrates all other modules:
- Application lifecycle management
- Module initialization and dependency injection
- Configuration and environment setup
- Cross-module coordination
flowy-user - User Management
Handles authentication and user profiles:
flowy-folder - Workspace & Folders
Manages workspace hierarchy and organization:
- Workspace creation and management
- Folder hierarchy with nesting
- View organization and ordering
- Trash and restore functionality
- Favorites and recent items
flowy-document - Document Editor
Rich text editing with collaborative features:
CRDT-based
Uses Yrs (Yjs in Rust) for conflict-free collaborative editing
Block-based
Document is composed of blocks (paragraphs, headings, lists)
- Paragraph, headings (H1-H6)
- Lists (bulleted, numbered, toggle)
- Checkboxes and to-do lists
- Code blocks with syntax highlighting
- Images and embeds
- Tables and dividers
flowy-database2 - Database Views
Provides multiple views over structured data:
- Grid
- Board
- Calendar
- Gallery
Spreadsheet-like table view with cells, rows, and columns
- Multiple field types (text, number, date, select, etc.)
- Filters and sorts
- Grouping and aggregation
- Cell editing and validation
- Real-time updates
flowy-ai - AI Services
Integrates AI capabilities:
- AI chat interface
- Text generation and completion
- Document summarization
- Translation and rewriting
- Integration with OpenAI, local LLMs
flowy-storage - File Storage
Manages file uploads and storage:
- Local file caching
- Cloud storage integration
- Image optimization
- File download and upload
flowy-search - Search Functionality
Full-text search powered by Tantivy:
Infrastructure Modules
lib-dispatch - Event Dispatch System
The event dispatch system is the backbone of the architecture:
Event structure:
lib-infra - Infrastructure
Shared infrastructure utilities:
- Async runtime utilities
- Error handling and result types
- Serialization helpers
- Platform detection
lib-log - Logging
Structured logging across all modules:
Data Layer
SQLite Integration
flowy-sqlite provides database access:
Database Schema
Each module maintains its own tables:| Module | Tables |
|---|---|
flowy-user | user_table, user_profile |
flowy-folder | workspace, folder, view |
flowy-document | document, block |
flowy-database2 | database, row, field |
Collaborative Features
CRDT Integration
AppFlowy uses the collab crates for CRDT support:Sync Protocol
CRDT ensures that concurrent edits from multiple users are merged without conflicts.
Build System
Cargo Workspace
All crates are part of a single workspace:Shared Dependencies
Common dependencies are defined at the workspace level:Platform Compilation
Target Platforms
- macOS
- iOS
- Android
- Linux
- Windows
Feature Flags
Compile-time features control functionality:Testing
Unit Tests
Integration Tests
Code Style
Rust code follows therustfmt.toml configuration:
Next Steps
Setup Environment
Set up your development environment
Building Desktop
Build the Rust backend for desktop