CoCalc Architecture Overview
Maintenance note: Update this file when packages are added/removed or when the high-level architecture changes.
System Components
CoCalc is a TypeScript/JavaScript SaaS monorepo. The major runtime components are:
Component Roles
| Component | Package(s) | Role |
|---|---|---|
| Frontend | packages/frontend, packages/static | React SPA with Redux-style stores |
| Hub | packages/hub, packages/server | Central server, API dispatch, DB access |
| Next.js | packages/next | SSR pages, REST API routes, conat bridge |
| Conat | packages/conat | Messaging layer (pub/sub, DKV, request/response) |
| Project | packages/project | Per-user project daemon (exec, jupyter, files) |
| Database | packages/database | PostgreSQL schema and query layer |
| Sync | packages/sync, packages/sync-client | Real-time collaborative editing (OT/CRDT) |
| Util | packages/util | Shared types, utilities, DB schema definitions |
| Comm | packages/comm | WebSocket message type definitions |
Data Flow
User action in browser → frontend dispatches to Redux store and/or calls
webapp_clientmethodsFrontend → Hub: via conat over WebSocket (
hub.account.{account_id}.api)Hub → Database: via
getPool()from@cocalc/database/poolHub → Project: via conat subjects (
project.{project_id}.*.api)External API → Hub: HTTP POST to Next.js
/api/conat/hub→ conat bridgeReal-time sync: via conat pub/sub and DKV for collaborative editing
Package Dependency Direction
Shared code flows from util outward. The conat package is used by frontend, hub/server, and project — it is the central communication layer.