$ show AppFlowy-IO/AppFlowy-Cloud
AppFlowy-Cloud is the Rust backend for the AppFlowy collaborative workspace platform, providing real-time document editing via CRDT (Yrs) with WebSocket sync, REST APIs for user/workspace management, AI features (chat, completion, embeddings), file storage (S3/MinIO), and background indexing. It follows a multi-service architecture with a main Actix-web server, a background worker (Axum), and an admin frontend (Axum/Askama), all orchestrated via Docker Compose. The codebase is extensive and well-structured, with many reusable libraries for database access, access control (Casbin), real-time protocol handling, and AI client integration. A significant portion is dedicated to integration tests covering collaborative sync, file uploads, and AI operations. However, this repository is explicitly marked as a legacy open-source release. The README states it is no longer maintained; active development has moved to a closed-source commercial fork. This results in some technical drift, such as deprecated endpoints, commented-out tests, and workarounds for known issues. Despite this, the code demonstrates high craftsmanship with clean abstractions (e.g., StreamRouter, ReconnectionManager, CollabStore trait) and robust patterns for distributed systems. It serves as a valuable reference for building real-time collaborative backends, but any reuse should account for its stale maintenance status and the need to update dependencies and fix known bugs.
The LLM identified 5 files worth highlighting for reuse:
Generic StreamRouter that multiplexes multiple Redis XREAD consumers over a connection pool, balanced by a round-robin arbiter pool. Handles lease acquisition, stream pruning, and live streaming. Isolated and reusable for any Redis stream-based message queue system.
Async Casbin enforcer with queue-based policy updates and three consistency modes (eventual, strong, bounded). Handles deadlock prevention and channel capacity management. Demonstrates a well-designed pattern for integrating access control policies in a distributed system.
ReconnectionManager with configurable exponential backoff, a ReconnectTarget trait for defining connection logic, and a spawn_reconnection helper. Includes extensive tests. Core pattern reusable for any WebSocket or TCP client reconnection logic.
Core sync protocol implementation (ClientSyncProtocol trait) for Yrs-based CRDT synchronization. Handles init sync, incremental updates, and awareness. Isolated and reusable for building other real-time collaboration systems using Yrs.
IndexerScheduler that polls unindexed collabs, generates OpenAI or Azure embeddings via a background thread pool, batches embeddings, and writes them to PostgreSQL. Includes retry on timeout and configurable batch size/interval. Extracted and reusable for any embedding pipeline.