This document provides a technical introduction to the AFFiNE codebase, its architecture, and core technologies. It covers the high-level system design, monorepo organization, technology stack, and platform support. For detailed information about specific subsystems:
Sources: README.md1-110 package.json1-173
AFFiNE is an open-source, all-in-one workspace platform that combines document editing, whiteboard drawing, and database management into a unified experience. It serves as a privacy-focused, local-first alternative to tools like Notion and Miro README.md13-15
Sources: README.md55-75 packages/frontend/apps/electron/package.json11 packages/frontend/apps/ios/package.json4
Architecture Overview
The system follows a layered architecture with clear separation between client applications, shared frontend logic, backend services, and data persistence:
@affine/core, reusable UI components in @affine/component, the BlockSuite collaborative editor, and the @toeverything/infra framework packages/frontend/core/package.json10-47For details, see Architecture Overview.
Sources: README.md69-75 packages/frontend/core/package.json1-97 packages/common/infra/package.json1-42 packages/backend/server/package.json27-113 packages/frontend/native/package.json6-15
| Technology | Version | Purpose | Package References |
|---|---|---|---|
| React | 19.2.1 | UI framework | @affine/core, @affine/component packages/frontend/core/package.json82 |
| TypeScript | 5.9.3 | Type system | All packages package.json90 |
| Rspack | ^2.0.8 | Build tool | @affine-tools/cli tools/cli/package.json21 |
| SWC | ^1.10.1 | TypeScript compiler | @affine-tools/cli tools/cli/package.json24 |
| Jotai | ^2.10.3 | State management | @affine/core, @affine/component packages/frontend/core/package.json71 |
| Yjs | ^13.6.27 | CRDT implementation | @affine/core, @toeverything/infra packages/frontend/core/package.json96 |
| Socket.io Client | ^4.8.3 | Real-time sync | @affine/core packages/frontend/core/package.json92 |
| React Router | ^6.30.4 | Routing | @affine/core, @affine/admin packages/frontend/core/package.json85 |
| Technology | Version | Purpose | Package References |
|---|---|---|---|
| Electron | ^39.0.0 | Desktop runtime | @affine/electron packages/frontend/apps/electron/package.json60 |
| Capacitor | ^8.4.2 | Mobile bridge | @affine/ios, @affine/android packages/frontend/apps/ios/package.json28 |
| NAPI-RS | 3.5.0 | Rust-TypeScript bridge | @affine/native packages/frontend/native/package.json28 |
Sources: package.json52-94 packages/frontend/core/package.json10-116 yarn.lock1-20 packages/frontend/native/package.json28
Workspace Structure
The monorepo uses Yarn Berry workspaces to manage dependencies across packages organized into main categories:
packages/frontend/*): Core application logic (@affine/core), reusable UI components (@affine/component), and platform-specific applications (e.g., @affine/web, @affine/electron, @affine/ios, @affine/android, @affine/mobile, @affine/admin) package.json10-11 packages/frontend/core/package.json1-9 packages/frontend/component/package.json1-11 packages/frontend/admin/package.json1-10packages/backend/*): The NestJS-based server (@affine/server) and Rust native modules for the backend (@affine/server-native) packages/backend/server/package.json1-7 packages/backend/native/package.json1-7packages/common/*): Shared libraries for infrastructure (@toeverything/infra), environment configuration (@affine/env), GraphQL types and clients (@affine/graphql), and the notebook store (@affine/nbstore) packages/common/infra/package.json1-13 packages/common/env/package.json1-16blocksuite/*): The collaborative editor framework (@blocksuite/affine) integrated as a workspace package.json9tools/*): Build system (@affine-tools/cli) and shared utilities (@affine-tools/utils) tools/cli/package.json1-13 tools/cli/package.json18tests/*): Test utilities (@affine-test/kit) and E2E test suites for each platform (e.g., @affine-test/affine-local, @affine-test/affine-desktop, @affine-test/affine-cloud) package.json15 yarn.lock15-88For details, see Monorepo Structure.
Sources: package.json7-16 packages/frontend/core/package.json1-9 tools/cli/package.json1-9 packages/frontend/component/package.json1-11 packages/frontend/admin/package.json1-10 packages/backend/server/package.json1-7 packages/backend/native/package.json1-7 packages/common/infra/package.json1-13 packages/common/env/package.json1-16 yarn.lock15-88
The web application is built as a single-page application providing the full AFFiNE experience in modern browsers.
The desktop application (@affine/electron) uses Electron's architecture with native functionality provided by native modules packages/frontend/apps/electron/package.json5 packages/frontend/apps/electron/package.json39
Mobile platforms use Capacitor to wrap the web application in native containers, allowing access to native APIs like haptics and keyboard management packages/frontend/apps/ios/package.json28-31 packages/frontend/apps/android/package.json22-26
Sources: packages/frontend/apps/electron/package.json1-97 packages/frontend/apps/ios/package.json1-50 packages/frontend/apps/android/package.json1-43
Refresh this wiki
This wiki was recently refreshed. Please wait 6 days to refresh again.