This document describes the high-level architecture of the Sim platform, including the monorepo structure, major system components, technology stack, state management patterns, and real-time collaboration architecture. For specific implementation details of individual subsystems, see:
Sim is a full-stack TypeScript application built as a monorepo using Turborepo package.json12 The system follows a layered architecture with clear separation between frontend presentation, backend services, data persistence, and background job processing. All components communicate through well-defined interfaces and leverage real-time WebSocket connections for collaborative editing.
The platform consists of:
apps/sim): Next.js 16.1.6 application serving the workflow editor and execution UI apps/sim/package.json145apps/docs): Next.js application with Fumadocs for public documentation apps/docs/package.json26-31@sim/db), logger (@sim/logger), and configuration utilities package.json7-10Sources: package.json1-10 apps/sim/package.json1-187 apps/docs/package.json1-51 bun.lock1-15
The system is organized into major layers that handle distinct concerns:
The frontend layer runs as a Next.js application using React 19.2.4 and the App Router apps/sim/package.json161
Key components:
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx:5-16.Cursors component apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx:37.Sources: apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx:1-92, apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/workflow-block.tsx:1-56
The backend uses Next.js API Routes and Better Auth for secure session management.
Core API functionality:
@sim/logger apps/sim/package.json88Sources: apps/sim/package.json96-100 apps/sim/next.config.ts157-174
Real-time collaboration is powered by Socket.IO, enabling multi-user editing with conflict resolution via an operation queue pattern.
Socket client hook: apps/sim/hooks/use-collaborative-workflow.ts apps/sim/hooks/use-collaborative-workflow.ts34-127
Operation Constants: Targets and operations defined in socket/constants apps/sim/hooks/use-collaborative-workflow.ts11-19
Sources: apps/sim/hooks/use-collaborative-workflow.ts114-158 apps/sim/stores/operation-queue/store.ts1-22
The frontend uses Zustand stores organized by domain. State is split between local UI state, workflow structure, and collaborative values.
| Store | Purpose | Key File |
|---|---|---|
useWorkflowRegistry | Manages workflow metadata and active selection | apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx:88 |
useWorkflowStore | Manages nodes (blocks), edges, and workflow structure | apps/sim/stores/workflows/workflow/store.ts114 |
useSubBlockStore | Manages specific input values for block parameters | apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/workflow-block.tsx:52 |
useUndoRedoStore | Handles action history for undo/redo functionality | apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx:85 |
Sources: apps/sim/stores/workflows/workflow/store.ts114-223 apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx:79-91
Blocks are the primary unit of the workflow. The system uses a centralized registry to manage block definitions.
Sources: apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx:31-42, apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/workflow-block.tsx:38-53
| Category | Technology |
|---|---|
| Framework | Next.js 16 (App Router), React 19 apps/sim/package.json145-161 |
| Runtime | Bun 1.3.11 package.json3 |
| Auth | Better Auth apps/sim/package.json96 |
| Database | PostgreSQL + Drizzle ORM apps/sim/package.json112-155 |
| Real-time | Socket.io apps/sim/package.json179 |
| Workflow UI | ReactFlow apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx:5-16 |
| State | Zustand apps/sim/package.json186 |
Sources: apps/sim/package.json1-187 package.json1-52 apps/sim/next.config.ts1-120