# shubhmhatre940/doc-clone-using-mern architecture

> Architecture diagram of the GitHub repository shubhmhatre940/doc-clone-using-mern, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shubhmhatre940/doc-clone-using-mern
- Repository: https://github.com/shubhmhatre940/doc-clone-using-mern

## Overview

This is a Google Docs-style collaborative writing application. Users sign in, browse or organize documents, and open an editor to create, import, edit, and autosave content; they can then collaborate through live sync, comments, sharing, history, and activity features. The graph emphasizes documented frontend routing, document/version controller calls, and server registration. Several feature branches are documented in the README or route registration, but their internal implementation paths are unsampled, so those connections are left broad or unverified.

Main entry points: [`client/src/pages/EditorPage.jsx`](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/client/src/pages/EditorPage.jsx) (Editor workspace), [`server/routes/documentRoutes.js`](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/routes/documentRoutes.js) (Document routes), [`server/controllers/documentController.js`](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/controllers/documentController.js) (Document operations), [`server/controllers/versionController.js`](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/controllers/versionController.js) (Version history)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_app["App routes<br/>[App.jsx]"]
  node_authui["Auth context<br/>[AuthContext.jsx]"]
  node_dashboard["Document dashboard<br/>[DashboardPage.jsx]"]
  node_editor["Editor workspace<br/>[EditorPage.jsx]"]
  node_editorui["Rich text editor<br/>[TiptapEditor.jsx]"]
  node_autosave["Autosave<br/>[useAutosave.js]"]
  node_docapi["Document API client<br/>[documents.js]"]
end

subgraph group_api["API and access"]
  node_server["Express application<br/>[server.js]"]
  node_docroutes["Document routes<br/>[documentRoutes.js]"]
  node_auth["JWT authentication<br/>[auth.js]"]
  node_permissions["Document permissions<br/>[permissions.js]"]
end

subgraph group_content["Document services"]
  node_doccontroller["Document operations"]
  node_export["Import and export"]
  node_versions["Version history"]
end

subgraph group_collab["Collaboration"]
  node_collabserver["Live collaboration<br/>[collabServer.js]"]
  node_comments["Comments and mentions"]
  node_sharing["Sharing and roles<br/>[shareController.js]"]
  node_activity["Activity log<br/>[activityService.js]"]
  node_notifications["Notifications"]
end

subgraph group_state["Persistent state"]
  node_docmodel[("Documents<br/>[Document.js]")]
  node_versionmodel[("Document versions<br/>[DocumentVersion.js]")]
  node_commentmodel[("Comments<br/>[Comment.js]")]
  node_activitymodel[("Activity records<br/>[ActivityLog.js]")]
  node_notificationmodel[("Notification records<br/>[Notification.js]")]
  node_userdb[("User records<br/>[User.js]")]
end

node_user(("Writer"))
node_mongodb[("MongoDB")]

node_user -->|"uses"| node_app
node_app -->|"provides auth"| node_authui
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_editor
node_editor -->|"renders"| node_editorui
node_editor -->|"uses"| node_autosave
node_autosave -->|"saves through"| node_docapi
node_dashboard -->|"loads documents"| node_docapi
node_docapi -.->|"HTTP requests"| node_server
node_server -->|"mounts"| node_docroutes
node_server -->|"initializes"| node_collabserver
node_docroutes -->|"protects routes"| node_auth
node_docroutes -->|"checks access"| node_permissions
node_docroutes -->|"routes requests"| node_doccontroller
node_docroutes -->|"routes exports"| node_export
node_docroutes -->|"routes sharing"| node_sharing
node_docroutes -->|"routes activity"| node_activity
node_auth -->|"loads user"| node_userdb
node_permissions -->|"checks document"| node_docmodel
node_doccontroller -->|"reads and writes"| node_docmodel
node_doccontroller -->|"creates snapshots"| node_versions
node_doccontroller -->|"records actions"| node_activity
node_doccontroller -.->|"persists"| node_mongodb
node_versions -->|"reads and writes"| node_versionmodel
node_versions -->|"restores document"| node_docmodel
node_versions -->|"broadcasts restore"| node_collabserver
node_versions -->|"records restore"| node_activity
node_activity -->|"writes entries"| node_activitymodel
node_comments -->|"reads and writes"| node_commentmodel
node_comments -->|"loads document"| node_docmodel
node_comments -->|"creates alerts"| node_notifications
node_comments -->|"broadcasts changes"| node_collabserver
node_notifications -->|"writes records"| node_notificationmodel
node_sharing -->|"updates sharing"| node_docmodel
node_sharing -->|"looks up users"| node_userdb
node_sharing -->|"notifies collaborators"| node_notifications
node_docmodel -.->|"stores data"| node_mongodb
node_versionmodel -.->|"stores snapshots"| node_mongodb
node_commentmodel -.->|"stores threads"| node_mongodb
node_activitymodel -.->|"stores entries"| node_mongodb
node_notificationmodel -.->|"stores alerts"| node_mongodb
node_userdb -.->|"stores users"| node_mongodb
node_editor -.->|"syncs live"| node_collabserver
node_editor -.->|"manages comments"| node_comments
node_editor -.->|"views history"| node_versions
node_editor -.->|"manages access"| node_sharing
node_editor -.->|"exports content"| node_export
node_dashboard -.->|"organizes files"| node_doccontroller

click node_app "https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/client/src/App.jsx"
click node_authui "https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/client/src/context/AuthContext.jsx"
click node_dashboard "https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/client/src/pages/DashboardPage.jsx"
click node_editor "https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/client/src/pages/EditorPage.jsx"
click node_editorui "https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/client/src/components/editor/TiptapEditor.jsx"
click node_autosave "https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/client/src/hooks/useAutosave.js"
click node_docapi "https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/client/src/api/documents.js"
click node_server "https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/server.js"
click node_docroutes "https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/routes/documentRoutes.js"
click node_auth "https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/middleware/auth.js"
click node_permissions "https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/middleware/permissions.js"
click node_doccontroller "https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/controllers/documentController.js"
click node_export "https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/controllers/exportController.js"
click node_versions "https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/controllers/versionController.js"
click node_collabserver "https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/services/collabServer.js"
click node_comments "https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/controllers/commentController.js"
click node_sharing "https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/controllers/shareController.js"
click node_activity "https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/services/activityService.js"
click node_notifications "https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/services/notificationService.js"
click node_docmodel "https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/models/Document.js"
click node_versionmodel "https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/models/DocumentVersion.js"
click node_commentmodel "https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/models/Comment.js"
click node_activitymodel "https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/models/ActivityLog.js"
click node_notificationmodel "https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/models/Notification.js"
click node_userdb "https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/models/User.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_authui,node_dashboard,node_editor,node_editorui,node_autosave,node_docapi toneBlue
class node_server,node_docroutes,node_auth,node_permissions,node_mongodb toneAmber
class node_doccontroller,node_export,node_versions toneMint
class node_collabserver,node_comments,node_sharing,node_activity,node_notifications toneRose
class node_docmodel,node_versionmodel,node_commentmodel,node_activitymodel,node_notificationmodel,node_userdb,node_user toneIndigo
```

## Components

### Client experience

- [App routes](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Auth context](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [Document dashboard](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/client/src/pages/DashboardPage.jsx): `client/src/pages/DashboardPage.jsx`
- [Editor workspace](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/client/src/pages/EditorPage.jsx): `client/src/pages/EditorPage.jsx`
- [Rich text editor](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/client/src/components/editor/TiptapEditor.jsx): `client/src/components/editor/TiptapEditor.jsx`
- [Autosave](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/client/src/hooks/useAutosave.js): `client/src/hooks/useAutosave.js`
- [Document API client](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/client/src/api/documents.js): `client/src/api/documents.js`

### API and access

- [Express application](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/server.js): `server/server.js`
- [Document routes](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/routes/documentRoutes.js): `server/routes/documentRoutes.js`
- [JWT authentication](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/middleware/auth.js): `server/middleware/auth.js`
- [Document permissions](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/middleware/permissions.js): `server/middleware/permissions.js`

### Document services

- [Document operations](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/controllers/documentController.js): `server/controllers/documentController.js`
- [Import and export](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/controllers/exportController.js): `server/controllers/exportController.js`
- [Version history](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/controllers/versionController.js): `server/controllers/versionController.js`

### Collaboration

- [Live collaboration](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/services/collabServer.js): `server/services/collabServer.js`
- [Comments and mentions](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/controllers/commentController.js): `server/controllers/commentController.js`
- [Sharing and roles](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/controllers/shareController.js): `server/controllers/shareController.js`
- [Activity log](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/services/activityService.js): `server/services/activityService.js`
- [Notifications](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/services/notificationService.js): `server/services/notificationService.js`

### Persistent state

- [Documents](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/models/Document.js): `server/models/Document.js`
- [Document versions](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/models/DocumentVersion.js): `server/models/DocumentVersion.js`
- [Comments](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/models/Comment.js): `server/models/Comment.js`
- [Activity records](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/models/ActivityLog.js): `server/models/ActivityLog.js`
- [Notification records](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/models/Notification.js): `server/models/Notification.js`
- [User records](https://github.com/shubhmhatre940/doc-clone-using-mern/blob/main/server/models/User.js): `server/models/User.js`

### Other components

- **Writer**
- **MongoDB**

## Connections

- Writer → App routes: uses (evidence: `client/src/App.jsx`)
- App routes → Auth context: provides auth (evidence: `client/src/App.jsx`)
- App routes → Document dashboard: routes to (evidence: `client/src/App.jsx`)
- App routes → Editor workspace: routes to (evidence: `client/src/App.jsx`)
- Editor workspace → Rich text editor: renders (evidence: `client/src/pages/EditorPage.jsx`)
- Editor workspace → Autosave: uses (evidence: `client/src/pages/EditorPage.jsx`)
- Autosave → Document API client: saves through (evidence: `client/src/hooks/useAutosave.js`)
- Document dashboard → Document API client: loads documents (evidence: `client/src/pages/DashboardPage.jsx`)
- Document API client → Express application: HTTP requests
- Express application → Document routes: mounts (evidence: `server/server.js`)
- Express application → Live collaboration: initializes (evidence: `server/server.js`)
- Document routes → JWT authentication: protects routes (evidence: `server/routes/documentRoutes.js`)
- Document routes → Document permissions: checks access (evidence: `server/routes/documentRoutes.js`)
- Document routes → Document operations: routes requests (evidence: `server/routes/documentRoutes.js`)
- Document routes → Import and export: routes exports (evidence: `server/routes/documentRoutes.js`)
- Document routes → Sharing and roles: routes sharing (evidence: `server/routes/documentRoutes.js`)
- Document routes → Activity log: routes activity (evidence: `server/routes/documentRoutes.js`)
- JWT authentication → User records: loads user (evidence: `server/middleware/auth.js`)
- Document permissions → Documents: checks document (evidence: `server/middleware/permissions.js`)
- Document operations → Documents: reads and writes (evidence: `server/controllers/documentController.js`)
- Document operations → Version history: creates snapshots (evidence: `server/controllers/documentController.js`)
- Document operations → Activity log: records actions (evidence: `server/controllers/documentController.js`)
- Document operations → MongoDB: persists
- Version history → Document versions: reads and writes (evidence: `server/controllers/versionController.js`)
- Version history → Documents: restores document (evidence: `server/controllers/versionController.js`)
- Version history → Live collaboration: broadcasts restore (evidence: `server/controllers/versionController.js`)
- Version history → Activity log: records restore (evidence: `server/controllers/versionController.js`)
- Activity log → Activity records: writes entries (evidence: `server/services/activityService.js`)
- Comments and mentions → Comments: reads and writes (evidence: `server/controllers/commentController.js`)
- Comments and mentions → Documents: loads document (evidence: `server/controllers/commentController.js`)
- Comments and mentions → Notifications: creates alerts (evidence: `server/controllers/commentController.js`)
- Comments and mentions → Live collaboration: broadcasts changes (evidence: `server/controllers/commentController.js`)
- Notifications → Notification records: writes records (evidence: `server/services/notificationService.js`)
- Sharing and roles → Documents: updates sharing (evidence: `server/controllers/shareController.js`)
- Sharing and roles → User records: looks up users (evidence: `server/controllers/shareController.js`)
- Sharing and roles → Notifications: notifies collaborators (evidence: `server/controllers/shareController.js`)
- Documents → MongoDB: stores data
- Document versions → MongoDB: stores snapshots
- Comments → MongoDB: stores threads
- Activity records → MongoDB: stores entries
- Notification records → MongoDB: stores alerts
- User records → MongoDB: stores users
- Editor workspace → Live collaboration: syncs live
- Editor workspace → Comments and mentions: manages comments
- Editor workspace → Version history: views history
- Editor workspace → Sharing and roles: manages access
- Editor workspace → Import and export: exports content
- Document dashboard → Document operations: organizes files
