# bhavadharani412/collaborative-text-editor architecture

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

- Interactive diagram: https://gitdiagram.com/bhavadharani412/collaborative-text-editor
- Repository: https://github.com/bhavadharani412/collaborative-text-editor

## Overview

Collaborative Docs is a browser-based document editor with a React home screen, rich-text editing, and multi-user collaboration. Users create or find documents on the home screen, open an ID-routed editor, and edit through Quill. The editor combines local Yjs state and offline persistence with a WebSocket sync server; it also supports live presence, title synchronization, and PDF/DOCX export. A separate Socket.IO path handles document snapshots and coarse-grained transfers through a bounded in-memory store. The README and excerpts support these flows; some editor internals and export implementation details were not sampled.

Main entry points: [`client/src/components/Editor.jsx`](https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/components/Editor.jsx) (Document Editor), [`client/src/services/yjsProvider.js`](https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/services/yjsProvider.js) (Yjs Provider Setup), [`client/src/components/DocsPage.jsx`](https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/components/DocsPage.jsx) (Document Home), [`client/src/App.jsx`](https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/App.jsx) (Route App)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_navigation["Document Navigation"]
  node_app["Route App<br/>[App.jsx]"]
  node_docs["Document Home<br/>[DocsPage.jsx]"]
  node_doclist[("Local Document List<br/>[storage.js]")]
  node_idgen["Document ID<br/>[generateId.js]"]
end

subgraph group_editing["Editing and Export"]
  node_editor["Document Editor<br/>[Editor.jsx]"]
  node_quill["Rich Text Surface<br/>[Editor.jsx]"]
  node_wordcount["Live Word Count<br/>[Editor.jsx]"]
  node_pdf["PDF Export<br/>[Editor.jsx]"]
  node_docx["DOCX Export<br/>[Editor.jsx]"]
end

subgraph group_collaboration["Live Collaboration"]
  node_yprovider["Yjs Provider Setup<br/>[yjsProvider.js]"]
  node_ydoc["Shared Yjs Document<br/>[Editor.jsx]"]
  node_presence["Presence and Titles<br/>[Editor.jsx]"]
  node_idb[("Offline Document Cache<br/>[yjsProvider.js]")]
end

subgraph group_backend["Backend Services"]
  node_yws["Yjs WebSocket Relay<br/>[index.js]"]
  node_socket["Socket.IO Events<br/>[index.js]"]
  node_snapshot[("Snapshot Store<br/>[index.js]")]
  node_health["Health Endpoint<br/>[index.js]"]
end

node_user(("Document User"))

node_user -->|"manages documents"| node_docs
node_user -->|"edits document"| node_editor
node_app -->|"routes home"| node_docs
node_app -->|"routes by ID"| node_editor
node_docs -->|"reads and saves"| node_doclist
node_docs -->|"generates ID"| node_idgen
node_editor -->|"mounts and configures"| node_quill
node_editor -->|"updates count"| node_wordcount
node_editor -->|"exports PDF"| node_pdf
node_editor -->|"exports DOCX"| node_docx
node_editor -->|"creates collaboration"| node_yprovider
node_editor -->|"joins and transfers"| node_socket
node_yprovider -->|"creates"| node_ydoc
node_yprovider -->|"persists offline"| node_idb
node_quill -->|"binds edits"| node_ydoc
node_editor -->|"tracks peers and titles"| node_presence
node_yprovider -->|"syncs over WebSocket"| node_yws
node_yws -->|"relays updates"| node_ydoc
node_socket -->|"loads and saves"| node_snapshot
node_health -->|"counts documents"| node_snapshot

click node_app "https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/App.jsx"
click node_docs "https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/components/DocsPage.jsx"
click node_doclist "https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/services/storage.js"
click node_idgen "https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/utils/generateId.js"
click node_editor "https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/components/Editor.jsx"
click node_quill "https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/components/Editor.jsx"
click node_wordcount "https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/components/Editor.jsx"
click node_pdf "https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/components/Editor.jsx"
click node_docx "https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/components/Editor.jsx"
click node_yprovider "https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/services/yjsProvider.js"
click node_ydoc "https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/components/Editor.jsx"
click node_presence "https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/components/Editor.jsx"
click node_idb "https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/services/yjsProvider.js"
click node_yws "https://github.com/bhavadharani412/collaborative-text-editor/blob/main/server/index.js"
click node_socket "https://github.com/bhavadharani412/collaborative-text-editor/blob/main/server/index.js"
click node_snapshot "https://github.com/bhavadharani412/collaborative-text-editor/blob/main/server/index.js"
click node_health "https://github.com/bhavadharani412/collaborative-text-editor/blob/main/server/index.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_docs,node_doclist,node_idgen,node_user toneBlue
class node_editor,node_quill,node_wordcount,node_pdf,node_docx toneAmber
class node_yprovider,node_ydoc,node_presence,node_idb toneMint
class node_yws,node_socket,node_snapshot,node_health toneRose
```

## Components

### Document Navigation

- [Route App](https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Document Home](https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/components/DocsPage.jsx): `client/src/components/DocsPage.jsx`
- [Local Document List](https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/services/storage.js): `client/src/services/storage.js`
- [Document ID](https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/utils/generateId.js): `client/src/utils/generateId.js`

### Editing and Export

- [Document Editor](https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/components/Editor.jsx): `client/src/components/Editor.jsx`
- [Rich Text Surface](https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/components/Editor.jsx): `client/src/components/Editor.jsx`
- [Live Word Count](https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/components/Editor.jsx): `client/src/components/Editor.jsx`
- [PDF Export](https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/components/Editor.jsx): `client/src/components/Editor.jsx`
- [DOCX Export](https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/components/Editor.jsx): `client/src/components/Editor.jsx`

### Live Collaboration

- [Yjs Provider Setup](https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/services/yjsProvider.js): `client/src/services/yjsProvider.js`
- [Shared Yjs Document](https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/components/Editor.jsx): `client/src/components/Editor.jsx`
- [Presence and Titles](https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/components/Editor.jsx): `client/src/components/Editor.jsx`
- [Offline Document Cache](https://github.com/bhavadharani412/collaborative-text-editor/blob/main/client/src/services/yjsProvider.js): `client/src/services/yjsProvider.js`

### Backend Services

- [Yjs WebSocket Relay](https://github.com/bhavadharani412/collaborative-text-editor/blob/main/server/index.js): `server/index.js`
- [Socket.IO Events](https://github.com/bhavadharani412/collaborative-text-editor/blob/main/server/index.js): `server/index.js`
- [Snapshot Store](https://github.com/bhavadharani412/collaborative-text-editor/blob/main/server/index.js): `server/index.js`
- [Health Endpoint](https://github.com/bhavadharani412/collaborative-text-editor/blob/main/server/index.js): `server/index.js`

### Other components

- **Document User**

## Connections

- Document User → Document Home: manages documents (evidence: `README.md`)
- Document User → Document Editor: edits document (evidence: `README.md`)
- Route App → Document Home: routes home (evidence: `client/src/App.jsx`)
- Route App → Document Editor: routes by ID (evidence: `client/src/App.jsx`)
- Document Home → Local Document List: reads and saves (evidence: `client/src/components/DocsPage.jsx`)
- Document Home → Document ID: generates ID (evidence: `client/src/components/DocsPage.jsx`)
- Document Editor → Rich Text Surface: mounts and configures (evidence: `README.md`)
- Document Editor → Live Word Count: updates count (evidence: `README.md`)
- Document Editor → PDF Export: exports PDF (evidence: `client/src/components/Editor.jsx`)
- Document Editor → DOCX Export: exports DOCX (evidence: `client/src/components/Editor.jsx`)
- Document Editor → Yjs Provider Setup: creates collaboration (evidence: `client/src/components/Editor.jsx`)
- Document Editor → Socket.IO Events: joins and transfers (evidence: `README.md`)
- Yjs Provider Setup → Shared Yjs Document: creates (evidence: `client/src/services/yjsProvider.js`)
- Yjs Provider Setup → Offline Document Cache: persists offline (evidence: `client/src/services/yjsProvider.js`)
- Rich Text Surface → Shared Yjs Document: binds edits (evidence: `README.md`)
- Document Editor → Presence and Titles: tracks peers and titles (evidence: `README.md`)
- Yjs Provider Setup → Yjs WebSocket Relay: syncs over WebSocket (evidence: `README.md`)
- Yjs WebSocket Relay → Shared Yjs Document: relays updates (evidence: `README.md`)
- Socket.IO Events → Snapshot Store: loads and saves (evidence: `server/index.js`)
- Health Endpoint → Snapshot Store: counts documents (evidence: `server/index.js`)
