Monorepo Overview
The monorepo uses npm workspaces for package management and Turbo for build orchestration and caching.
Apps
Server (apps/server/)
Fastify-based API server with WebSocket support for real-time collaboration.
Key directories:
- Fastify - Web framework
- Kysely - Type-safe SQL query builder
- PostgreSQL - Primary database
- Redis - Message queue and caching
- BullMQ - Background job processing
- Yjs - CRDT for document collaboration
Web (apps/web/)
React-based web application with offline-first capabilities.
Key directories:
- React 19 - UI framework
- Vite - Build tool and dev server
- TailwindCSS v4 - Styling
- TanStack Query - Data fetching and caching
- SQLite WASM - Client-side database
- TipTap/ProseMirror - Rich text editor
Desktop (apps/desktop/)
Electron application with native SQLite database.
Key directories:
- Electron - Desktop framework
- better-sqlite3 - Native SQLite bindings
- Electron Forge - Build and packaging
- Vite - Renderer bundling
Packages
Core (packages/core/)
Shared TypeScript types, Zod schemas, and business logic.
Key directories:
space- Workspace containerfolder- Organizational folderpage- Rich text documentdatabase- Structured data tabledatabase-view- Table, kanban, calendar viewsrecord- Database rowfield- Database columnfile- File attachmentschannel- Chat channelmessage- Chat message
CRDT (packages/crdt/)
Yjs-based CRDT implementation for collaborative editing.
Key features:
- Document collaboration with Yjs
- Conflict-free merging
- Undo/redo support
- Cursor awareness
Client (packages/client/)
Client-side sync engine, local database, and data access layer.
Key directories:
- Local SQLite database (WASM on web, better-sqlite3 on desktop)
- Optimistic updates to local DB
- WebSocket sync with server
- Conflict resolution via CRDT
UI (packages/ui/)
Shared component library built with Radix and TailwindCSS.
Key directories:
- Radix UI - Accessible primitives
- TailwindCSS v4 - Utility-first CSS
- Flat design - Minimal shadows
- Consistent spacing and typography
Configuration Files
Root Configuration
Workspace Configuration
Defined in rootpackage.json:
Turbo Pipeline
Defined inturbo.json:
Data Flow Architecture
nodes-updates- Node attributes and hierarchydocument-updates- Rich text document changescollaborations- Real-time presencenode-reactions- Emoji reactionsnode-interactions- Views, edits trackingnode-tombstones- Soft deletesusers- User profile updates
Package Dependencies
Dependency graph:Use
@brainbox/* imports for internal packages. The * workspace protocol in package.json ensures local linking during development.Development Guidelines
Adding a New Node Type
- Define in
packages/core/src/registry/nodes/my-node.ts - Export from
packages/core/src/registry/nodes/index.ts - Create database migration in
apps/server/src/data/migrations/ - Add UI components and routes
- Implement queries and mutations
Adding a New Sync Type
- Define schema in
packages/core/src/synchronizers/ - Implement handler in
packages/client/src/handlers/ - Implement broadcaster in
apps/server/src/synchronizers/ - Register in sync engine
Code Organization Principles
- Shared types in core - All TypeScript types in
@brainbox/core - Validation with Zod - Runtime schema validation
- Type-safe SQL - Use Kysely for database queries
- No circular dependencies - Enforce with ESLint
- Consistent imports - Use absolute imports with
@brainbox/*
Next Steps
- Set up your development environment
- Run the project locally
- Review CLAUDE.md for detailed architecture
- Check CONTRIBUTING.md for contribution workflow