# arena-position2/p2-sim architecture

> Architecture diagram of the GitHub repository arena-position2/p2-sim, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arena-position2/p2-sim
- Repository: https://github.com/arena-position2/p2-sim

## Overview

Sim is a workspace for building, deploying, and managing AI agents and workflows. The main user journey is to create a workflow visually, conversationally, or in code; connect models and integrations; execute it; then inspect activity or use it through chat. Files, knowledge, tables, and scheduled tasks are additional workspace capabilities. The README documents these product areas, while the sampled source shows execution, uploads, diffs, and realtime room managers. Many cross-subsystem links are therefore shown as unverified rather than asserted as inspected call paths.

Main entry points: [`apps/sim/executor/execution/engine.ts`](https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/sim/executor/execution/engine.ts) (Execution engine), [`packages/workflow-renderer/src/workflow-block/workflow-block-view.tsx`](https://github.com/arena-position2/p2-sim/blob/version-5.2-main/packages/workflow-renderer/src/workflow-block/workflow-block-view.tsx) (Workflow editor), [`apps/sim/tools/notion/query_database.ts`](https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/sim/tools/notion/query_database.ts) (Integration tools), [`apps/sim/lib/workflows/diff/diff-engine.ts`](https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/sim/lib/workflows/diff/diff-engine.ts) (Workflow diffs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_authoring["Workflow authoring"]
  node_workflow_editor["Workflow editor"]
  node_workflow_diff["Workflow diffs<br/>[diff-engine.ts]"]
  node_workflow_types["Workflow model<br/>[workflow.ts]"]
end

subgraph group_execution["Agent execution"]
  node_execution_engine["Execution engine<br/>[engine.ts]"]
  node_integrations["Integration tools<br/>[query_database.ts]"]
  node_code_tools["Code integrations<br/>[codepipeline.ts]"]
  node_scheduled_tasks["Scheduled tasks"]
end

subgraph group_workspace["Workspace data"]
  node_file_storage[("File storage<br/>[storage-service.ts]")]
  node_knowledge_sync["Knowledge sync<br/>[sync-engine.ts]"]
  node_workspace_tables[("Workspace tables")]
end

subgraph group_surfaces["User surfaces"]
  node_resume_ui["Run resume UI"]
  node_chat_ui["Agent chat<br/>[chat.tsx]"]
  node_activity_monitor["Run monitoring<br/>[logs-callout.tsx]"]
end

subgraph group_platform["Platform services"]
  node_realtime_rooms["Realtime rooms<br/>[redis-manager.ts]"]
  node_db[("PostgreSQL data<br/>[db.ts]")]
  node_oauth_storage[("OAuth credentials<br/>[storage.ts]")]
  node_browser_storage["Browser preferences<br/>[browser-storage.ts]"]
end

node_user(("Workspace user"))
node_external_services{{"Models and services"}}

node_user -->|"creates workflows"| node_workflow_editor
node_user -->|"uses agent chat"| node_chat_ui
node_workflow_editor -.->|"edits state"| node_workflow_diff
node_workflow_editor -.->|"authors workflows"| node_workflow_types
node_workflow_diff -.->|"updates model"| node_workflow_types
node_workflow_editor -.->|"starts runs"| node_execution_engine
node_execution_engine -.->|"invokes tools"| node_integrations
node_execution_engine -.->|"runs code"| node_code_tools
node_execution_engine -.->|"provides run state"| node_resume_ui
node_user -->|"uploads files"| node_file_storage
node_file_storage -.->|"supplies documents"| node_knowledge_sync
node_user -->|"manages data"| node_workspace_tables
node_scheduled_tasks -.->|"triggers runs"| node_execution_engine
node_user -->|"inspects activity"| node_activity_monitor
node_execution_engine -.->|"publishes updates"| node_realtime_rooms
node_execution_engine -.->|"persists run data"| node_db
node_integrations -.->|"uses credentials"| node_oauth_storage
node_integrations -.->|"calls services"| node_external_services
node_user -.->|"keeps preferences"| node_browser_storage

click node_workflow_editor "https://github.com/arena-position2/p2-sim/blob/version-5.2-main/packages/workflow-renderer/src/workflow-block/workflow-block-view.tsx"
click node_workflow_diff "https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/sim/lib/workflows/diff/diff-engine.ts"
click node_workflow_types "https://github.com/arena-position2/p2-sim/blob/version-5.2-main/packages/workflow-types/src/workflow.ts"
click node_execution_engine "https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/sim/executor/execution/engine.ts"
click node_resume_ui "https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/sim/app/(interfaces)/resume/%5BworkflowId%5D/%5BexecutionId%5D/resume-page-client.tsx"
click node_chat_ui "https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/sim/app/(interfaces)/chat/%5Bidentifier%5D/chat.tsx"
click node_integrations "https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/sim/tools/notion/query_database.ts"
click node_code_tools "https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/sim/blocks/blocks/codepipeline.ts"
click node_file_storage "https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/sim/lib/uploads/core/storage-service.ts"
click node_knowledge_sync "https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/sim/lib/knowledge/connectors/sync-engine.ts"
click node_workspace_tables "https://github.com/arena-position2/p2-sim/tree/version-5.2-main/apps/sim"
click node_scheduled_tasks "https://github.com/arena-position2/p2-sim/tree/version-5.2-main/apps/sim"
click node_activity_monitor "https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/sim/app/(landing)/components/features/components/logs-callout/logs-callout.tsx"
click node_realtime_rooms "https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/realtime/src/rooms/redis-manager.ts"
click node_db "https://github.com/arena-position2/p2-sim/blob/version-5.2-main/packages/db/db.ts"
click node_oauth_storage "https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/sim/lib/mcp/oauth/storage.ts"
click node_browser_storage "https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/sim/lib/core/utils/browser-storage.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_workflow_editor,node_workflow_diff,node_workflow_types,node_user toneBlue
class node_execution_engine,node_integrations,node_code_tools,node_scheduled_tasks toneAmber
class node_file_storage,node_knowledge_sync,node_workspace_tables toneMint
class node_resume_ui,node_chat_ui,node_activity_monitor toneRose
class node_realtime_rooms,node_db,node_oauth_storage,node_browser_storage,node_external_services toneIndigo
```

## Components

### Workflow authoring

- [Workflow editor](https://github.com/arena-position2/p2-sim/blob/version-5.2-main/packages/workflow-renderer/src/workflow-block/workflow-block-view.tsx): `packages/workflow-renderer/src/workflow-block/workflow-block-view.tsx`
- [Workflow diffs](https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/sim/lib/workflows/diff/diff-engine.ts): `apps/sim/lib/workflows/diff/diff-engine.ts`
- [Workflow model](https://github.com/arena-position2/p2-sim/blob/version-5.2-main/packages/workflow-types/src/workflow.ts): `packages/workflow-types/src/workflow.ts`

### Agent execution

- [Execution engine](https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/sim/executor/execution/engine.ts): `apps/sim/executor/execution/engine.ts`
- [Integration tools](https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/sim/tools/notion/query_database.ts): `apps/sim/tools/notion/query_database.ts`
- [Code integrations](https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/sim/blocks/blocks/codepipeline.ts): `apps/sim/blocks/blocks/codepipeline.ts`
- [Scheduled tasks](https://github.com/arena-position2/p2-sim/tree/version-5.2-main/apps/sim): `apps/sim`

### Workspace data

- [File storage](https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/sim/lib/uploads/core/storage-service.ts): `apps/sim/lib/uploads/core/storage-service.ts`
- [Knowledge sync](https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/sim/lib/knowledge/connectors/sync-engine.ts): `apps/sim/lib/knowledge/connectors/sync-engine.ts`
- [Workspace tables](https://github.com/arena-position2/p2-sim/tree/version-5.2-main/apps/sim): `apps/sim`

### User surfaces

- [Run resume UI](https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/sim/app/(interfaces)/resume/%5BworkflowId%5D/%5BexecutionId%5D/resume-page-client.tsx): `apps/sim/app/(interfaces)/resume/[workflowId]/[executionId]/resume-page-client.tsx`
- [Agent chat](https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/sim/app/(interfaces)/chat/%5Bidentifier%5D/chat.tsx): `apps/sim/app/(interfaces)/chat/[identifier]/chat.tsx`
- [Run monitoring](https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/sim/app/(landing)/components/features/components/logs-callout/logs-callout.tsx): `apps/sim/app/(landing)/components/features/components/logs-callout/logs-callout.tsx`

### Platform services

- [Realtime rooms](https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/realtime/src/rooms/redis-manager.ts): `apps/realtime/src/rooms/redis-manager.ts`
- [PostgreSQL data](https://github.com/arena-position2/p2-sim/blob/version-5.2-main/packages/db/db.ts): `packages/db/db.ts`
- [OAuth credentials](https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/sim/lib/mcp/oauth/storage.ts): `apps/sim/lib/mcp/oauth/storage.ts`
- [Browser preferences](https://github.com/arena-position2/p2-sim/blob/version-5.2-main/apps/sim/lib/core/utils/browser-storage.ts): `apps/sim/lib/core/utils/browser-storage.ts`

### Other components

- **Workspace user**
- **Models and services**

## Connections

- Workspace user → Workflow editor: creates workflows (evidence: `README.md`)
- Workspace user → Agent chat: uses agent chat (evidence: `README.md`)
- Workflow editor → Workflow diffs: edits state
- Workflow editor → Workflow model: authors workflows
- Workflow diffs → Workflow model: updates model
- Workflow editor → Execution engine: starts runs
- Execution engine → Integration tools: invokes tools
- Execution engine → Code integrations: runs code
- Execution engine → Run resume UI: provides run state
- Workspace user → File storage: uploads files (evidence: `README.md`)
- File storage → Knowledge sync: supplies documents
- Workspace user → Workspace tables: manages data (evidence: `README.md`)
- Scheduled tasks → Execution engine: triggers runs
- Workspace user → Run monitoring: inspects activity (evidence: `README.md`)
- Execution engine → Realtime rooms: publishes updates
- Execution engine → PostgreSQL data: persists run data
- Integration tools → OAuth credentials: uses credentials
- Integration tools → Models and services: calls services
- Workspace user → Browser preferences: keeps preferences
