# sachin1395/distributed-collaborative-editor architecture

> Architecture diagram of the GitHub repository sachin1395/distributed-collaborative-editor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sachin1395/distributed-collaborative-editor
- Repository: https://github.com/sachin1395/distributed-collaborative-editor

## Overview

SyncDraft is a browser-based collaborative document editor. Users enter through the React app, authenticate with Supabase, manage documents, then edit a selected document in TipTap; Yjs maintains shared state and Hocuspocus distributes collaboration sessions, with Redis supporting scaling. The frontend also offers a public demo, invitations/presence, document export, and version-history UI; README notes long-term snapshots are planned. The backend exposes Prometheus metrics. Relationships involving unsampled internals are included only where the README documents them; source excerpts show app routing, document access, editor persistence, and metrics wiring.

Main entry points: [`syncraft/src/App.js`](https://github.com/sachin1395/distributed-collaborative-editor/blob/main/syncraft/src/App.js) (App routes), [`syncraft/src/components/editor.jsx`](https://github.com/sachin1395/distributed-collaborative-editor/blob/main/syncraft/src/components/editor.jsx) (Document editor), [`syncraft/src/components/supabase_client.js`](https://github.com/sachin1395/distributed-collaborative-editor/blob/main/syncraft/src/components/supabase_client.js) (Supabase client), [`server/custom_server.js`](https://github.com/sachin1395/distributed-collaborative-editor/blob/main/server/custom_server.js) (Hocuspocus sessions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend experience"]
  node_app["App routes<br/>[App.js]"]
  node_landing["Landing page<br/>[LandingPage.jsx]"]
  node_login["Authentication UI<br/>[login.jsx]"]
  node_documents["Document library<br/>[documents.jsx]"]
  node_demo["Public demo<br/>[demo_editor.jsx]"]
end

subgraph group_editing["Editing and collaboration"]
  node_editor["Document editor<br/>[editor.jsx]"]
  node_tiptap_controls["Editor controls<br/>[use-code-block.js]"]
  node_editor_utils["Editor utilities<br/>[tiptap-utils.js]"]
  node_invitations["Invitations and presence"]
  node_version_ui["Version history UI"]
  node_yjs["Yjs shared state"]
end

subgraph group_backend["Realtime backend"]
  node_hocuspocus["Hocuspocus sessions<br/>[custom_server.js]"]
  node_redis[("Redis scaling")]
end

subgraph group_operations["Operations and integrations"]
  node_supabase_client["Supabase client<br/>[supabase_client.js]"]
  node_supabase[("Supabase auth and metadata")]
  node_metrics["Metrics endpoint<br/>[custom_server.js]"]
  node_metric_registry["Metric registry<br/>[metrics.js]"]
end

node_user(("Writer"))
node_prometheus(("Metrics scraper"))

node_user -->|"opens"| node_app
node_app -->|"routes to"| node_landing
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_documents
node_app -->|"routes to"| node_editor
node_app -->|"routes to"| node_demo
node_app -->|"checks session"| node_supabase_client
node_login -->|"authenticates via"| node_supabase_client
node_documents -->|"manages metadata"| node_supabase_client
node_supabase_client -->|"connects to"| node_supabase
node_editor -->|"loads and saves"| node_supabase_client
node_editor -.->|"uses controls"| node_tiptap_controls
node_tiptap_controls -->|"calls helpers"| node_editor_utils
node_editor -->|"edits shared state"| node_yjs
node_editor -->|"syncs over WebSocket"| node_hocuspocus
node_hocuspocus -->|"scales through"| node_redis
node_editor -.->|"offers invitations"| node_invitations
node_editor -->|"opens history"| node_version_ui
node_version_ui -.->|"snapshot support planned"| node_yjs
node_hocuspocus -->|"updates gauge"| node_metric_registry
node_metrics -->|"serves metrics"| node_metric_registry
node_prometheus -->|"scrapes"| node_metrics

click node_app "https://github.com/sachin1395/distributed-collaborative-editor/blob/main/syncraft/src/App.js"
click node_landing "https://github.com/sachin1395/distributed-collaborative-editor/blob/main/syncraft/src/components/LandingPage.jsx"
click node_login "https://github.com/sachin1395/distributed-collaborative-editor/blob/main/syncraft/src/components/login.jsx"
click node_documents "https://github.com/sachin1395/distributed-collaborative-editor/blob/main/syncraft/src/components/documents.jsx"
click node_demo "https://github.com/sachin1395/distributed-collaborative-editor/blob/main/syncraft/src/components/demo_editor.jsx"
click node_supabase_client "https://github.com/sachin1395/distributed-collaborative-editor/blob/main/syncraft/src/components/supabase_client.js"
click node_editor "https://github.com/sachin1395/distributed-collaborative-editor/blob/main/syncraft/src/components/editor.jsx"
click node_tiptap_controls "https://github.com/sachin1395/distributed-collaborative-editor/blob/main/syncraft/src/%40/components/tiptap-ui/code-block-button/use-code-block.js"
click node_editor_utils "https://github.com/sachin1395/distributed-collaborative-editor/blob/main/syncraft/src/%40/lib/tiptap-utils.js"
click node_invitations "https://github.com/sachin1395/distributed-collaborative-editor/blob/main/syncraft/src/components/InviteCollaborator.jsx"
click node_version_ui "https://github.com/sachin1395/distributed-collaborative-editor/blob/main/syncraft/src/components/VersionHistoryModal.jsx"
click node_hocuspocus "https://github.com/sachin1395/distributed-collaborative-editor/blob/main/server/custom_server.js"
click node_metrics "https://github.com/sachin1395/distributed-collaborative-editor/blob/main/server/custom_server.js"
click node_metric_registry "https://github.com/sachin1395/distributed-collaborative-editor/blob/main/server/metrics.js"

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_app,node_landing,node_login,node_documents,node_demo toneBlue
class node_editor,node_tiptap_controls,node_editor_utils,node_invitations,node_version_ui,node_yjs toneAmber
class node_hocuspocus,node_redis toneMint
class node_supabase_client,node_supabase,node_metrics,node_metric_registry toneRose
class node_user,node_prometheus toneIndigo
```

## Components

### Frontend experience

- [App routes](https://github.com/sachin1395/distributed-collaborative-editor/blob/main/syncraft/src/App.js): `syncraft/src/App.js`
- [Landing page](https://github.com/sachin1395/distributed-collaborative-editor/blob/main/syncraft/src/components/LandingPage.jsx): `syncraft/src/components/LandingPage.jsx`
- [Authentication UI](https://github.com/sachin1395/distributed-collaborative-editor/blob/main/syncraft/src/components/login.jsx): `syncraft/src/components/login.jsx`
- [Document library](https://github.com/sachin1395/distributed-collaborative-editor/blob/main/syncraft/src/components/documents.jsx): `syncraft/src/components/documents.jsx`
- [Public demo](https://github.com/sachin1395/distributed-collaborative-editor/blob/main/syncraft/src/components/demo_editor.jsx): `syncraft/src/components/demo_editor.jsx`

### Editing and collaboration

- [Document editor](https://github.com/sachin1395/distributed-collaborative-editor/blob/main/syncraft/src/components/editor.jsx): `syncraft/src/components/editor.jsx`
- [Editor controls](https://github.com/sachin1395/distributed-collaborative-editor/blob/main/syncraft/src/%40/components/tiptap-ui/code-block-button/use-code-block.js): `syncraft/src/@/components/tiptap-ui/code-block-button/use-code-block.js`
- [Editor utilities](https://github.com/sachin1395/distributed-collaborative-editor/blob/main/syncraft/src/%40/lib/tiptap-utils.js): `syncraft/src/@/lib/tiptap-utils.js`
- [Invitations and presence](https://github.com/sachin1395/distributed-collaborative-editor/blob/main/syncraft/src/components/InviteCollaborator.jsx): `syncraft/src/components/InviteCollaborator.jsx`
- [Version history UI](https://github.com/sachin1395/distributed-collaborative-editor/blob/main/syncraft/src/components/VersionHistoryModal.jsx): `syncraft/src/components/VersionHistoryModal.jsx`
- **Yjs shared state**

### Realtime backend

- [Hocuspocus sessions](https://github.com/sachin1395/distributed-collaborative-editor/blob/main/server/custom_server.js): `server/custom_server.js`
- **Redis scaling**

### Operations and integrations

- [Supabase client](https://github.com/sachin1395/distributed-collaborative-editor/blob/main/syncraft/src/components/supabase_client.js): `syncraft/src/components/supabase_client.js`
- **Supabase auth and metadata**
- [Metrics endpoint](https://github.com/sachin1395/distributed-collaborative-editor/blob/main/server/custom_server.js): `server/custom_server.js`
- [Metric registry](https://github.com/sachin1395/distributed-collaborative-editor/blob/main/server/metrics.js): `server/metrics.js`

### Other components

- **Writer**
- **Metrics scraper**

## Connections

- Writer → App routes: opens
- App routes → Landing page: routes to (evidence: `syncraft/src/App.js`)
- App routes → Authentication UI: routes to (evidence: `syncraft/src/App.js`)
- App routes → Document library: routes to (evidence: `syncraft/src/App.js`)
- App routes → Document editor: routes to (evidence: `syncraft/src/App.js`)
- App routes → Public demo: routes to (evidence: `syncraft/src/App.js`)
- App routes → Supabase client: checks session (evidence: `syncraft/src/App.js`)
- Authentication UI → Supabase client: authenticates via (evidence: `syncraft/src/components/login.jsx`)
- Document library → Supabase client: manages metadata (evidence: `syncraft/src/components/documents.jsx`)
- Supabase client → Supabase auth and metadata: connects to (evidence: `syncraft/src/components/supabase_client.js`)
- Document editor → Supabase client: loads and saves (evidence: `syncraft/src/components/editor.jsx`)
- Document editor → Editor controls: uses controls
- Editor controls → Editor utilities: calls helpers (evidence: `syncraft/src/@/components/tiptap-ui/code-block-button/use-code-block.js`)
- Document editor → Yjs shared state: edits shared state (evidence: `syncraft/src/components/editor.jsx`)
- Document editor → Hocuspocus sessions: syncs over WebSocket
- Hocuspocus sessions → Redis scaling: scales through
- Document editor → Invitations and presence: offers invitations (evidence: `syncraft/src/components/editor.jsx`)
- Document editor → Version history UI: opens history (evidence: `syncraft/src/components/editor.jsx`)
- Version history UI → Yjs shared state: snapshot support planned
- Hocuspocus sessions → Metric registry: updates gauge (evidence: `server/custom_server.js`)
- Metrics endpoint → Metric registry: serves metrics (evidence: `server/custom_server.js`)
- Metrics scraper → Metrics endpoint: scrapes
