Introduction
The@brainbox/client package provides a complete client-side API for building local-first applications with Brainbox. It handles local SQLite databases, synchronization with the server, and provides type-safe queries and mutations.
Installation
The client package is included in the Brainbox monorepo:Package Exports
The client package exposes several modules:Core Services
AppService
The main entry point for the client application. Manages servers, accounts, and workspaces.AccountService
Manages a single account, including its workspaces and authentication.WorkspaceService
Provides access to workspace-specific services:Mediator Pattern
TheMediator class provides a centralized way to execute queries and mutations:
Local Databases
Brainbox uses SQLite for local storage with separate databases for:- App Database: Stores servers, accounts, and global metadata
- Account Database: Stores workspace metadata for an account
- Workspace Database: Stores nodes, documents, and workspace-specific data
Database Access
Error Handling
Query Errors
Mutation Errors
Type System
Query Types
All queries extend the baseQueryMap interface:
Mutation Types
All mutations extend the baseMutationMap interface:
Synchronization
The client automatically syncs local changes to the server:Next Steps
Queries
Browse all available query functions
Mutations
Explore mutation functions for data updates
Node Types
Learn about different node types