Zero Sources
Overview
Zero Sources is a monorepo that hosts various utilities and custom change source implementations designed to integrate with @rocicorp/zero. The primary goal is to provide building blocks and ready-to-use change sources for developers looking to extend or customize Zero's caching and synchronization features.
🚀 Featured: MongoDB Array Unwinding
The MongoDB change source now supports array unwinding in table mappings, enabling you to normalize MongoDB documents with embedded arrays into separate Zero table rows using aggregation pipeline stages.
- ~200x Performance Improvement: Identity-based array diffing generates minimal change events.
- Discriminated Union Architecture: Type-safe pipeline with compile-time checking.
- Fluent Builder API: Readable, chainable pipeline construction.
import { pipelineBuilder } from '@cbnsndwch/zero-contracts';
const mapping = pipelineBuilder<Member>('accounts')
.match({ bundle: 'ENTERPRISE' })
.unwind('$members')
.addFields({
accountId: '$_id',
userId: '$members.id',
role: '$members.role'
})
.build();
🏗️ Repository Structure
We use pnpm Workspaces and Turborepo to manage multiple packages effectively:
apps/zrocket: Unified ZRocket demo showcasing discriminated union tables with MongoDB.apps/source-mongodb-server: General-purpose MongoDB change source server.libs/zero-contracts: TypeScript contracts and utilities for Zero.libs/zero-source-mongodb: MongoDB change source with discriminated unions.
🏗️ Look Inside the ZRocket Demo
The ZRocket demo showcases how multiple Zero tables can be derived from a single MongoDB collection using filter-based discrimination:
chatsTable:roomscollection with filter{ t: 'd' }(direct messages).channelsTable:roomscollection with filter{ t: 'c' }(public channels).systemMessages:messagescollection with filter{ t: { $exists: true } }.
🛣️ Roadmap & Future Plans
- Stripe Integration: API-based initial sync with webhook support.
- GoHighLevel Integration: Webhook-based change source.
- Deno + Bun Support: Expanding beyond the current Node.js v22+ baseline.
For full details, check out the Repository README.
Tech Stack
- TypeScript
- NodeJS
- NestJS
- MongoDB
- Turborepo
- Zero Sync
- Sync Engines
- Local First
Latest Updates
View allWinter Stabilization: Pushing to NPM & Core Upgrades
We have officially released the first set of core packages and modernized our data layer with MongoDB v7 and Mongoose v9.The Modern Stack: React 19, NestJS 11, and Vite 7
A massive infrastructure upgrade migrating the entire project to React 19, NestJS 11, and Vite 7.Deploy Anywhere: ARM Support & Docker Enhancements
Natively support ARM architecture for Apple Silicon and Graviton instances, plus self-hosted documentation support.Documentation Reimagined: Interactive Examples and Live Demos
Our documentation has been completely restructured using Fumadocs, featuring interactive examples and live code tabs.Building with Privacy: Integrated Feedback System
A new privacy-focused feedback system integrated directly into our documentation using GitHub and NocoDB.