# mdsohail07/nexuspad architecture

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

- Interactive diagram: https://gitdiagram.com/mdsohail07/nexuspad
- Repository: https://github.com/mdsohail07/nexuspad

## Overview

NexusPad is a collaborative document editor. Users authenticate, manage documents from a searchable dashboard, open a document in the editor, and collaborate through Liveblocks; owners can also create view-only share links. PostgreSQL stores document metadata and share snapshots, while Liveblocks handles live editing and presence. The graph preserves these separate state paths. Several editor and sharing details are documented but their implementation files were not sampled, so those connections rely on README evidence; unsampled internals are not inferred.

Main entry points: [`app/actions/documents.ts`](https://github.com/mdsohail07/nexuspad/blob/main/app/actions/documents.ts) (Document actions), [`app/api/liveblocks-auth/route.ts`](https://github.com/mdsohail07/nexuspad/blob/main/app/api/liveblocks-auth/route.ts) (Room authorization), [`auth.ts`](https://github.com/mdsohail07/nexuspad/blob/main/auth.ts) (Auth.js), [`lib/prisma.ts`](https://github.com/mdsohail07/nexuspad/blob/main/lib/prisma.ts) (Prisma client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity"]
  node_auth_pages["Sign-in pages<br/>[page.tsx]"]
  node_auth_ui["Auth forms"]
  node_auth_actions["Auth actions<br/>[auth.ts]"]
  node_auth_core["Auth.js<br/>[auth.ts]"]
end

subgraph group_workspace["Document workspace"]
  node_dashboard_route["Dashboard route<br/>[page.tsx]"]
  node_dashboard_view["Dashboard view<br/>[dashboard-view.tsx]"]
  node_document_grid["Document grid<br/>[document-grid.tsx]"]
  node_document_cards["Document cards<br/>[document-card.tsx]"]
  node_document_cache["Document cache<br/>[use-documents.ts]"]
  node_document_actions["Document actions<br/>[documents.ts]"]
end

subgraph group_editing["Editing and collaboration"]
  node_document_route["Document route<br/>[page.tsx]"]
  node_document_room["Collaboration room<br/>[document-room.tsx]"]
  node_editor_shell["Editor interface<br/>[editor-shell.tsx]"]
  node_editor_controls["Editor controls<br/>[editor-toolbar.tsx]"]
  node_editor_commands["Editor commands<br/>[editor-commands.ts]"]
  node_presence["Presence display"]
  node_liveblocks_auth["Room authorization<br/>[route.ts]"]
end

subgraph group_sharing["Public sharing"]
  node_share_route["Shared document route<br/>[page.tsx]"]
  node_shared_view["Read-only view"]
end

subgraph group_storage["Persistence and services"]
  node_database[("PostgreSQL")]
  node_prisma["Prisma client<br/>[prisma.ts]"]
end

node_user(("User"))
node_google{{"Google OAuth"}}
node_liveblocks{{"Liveblocks"}}

node_user -->|"opens"| node_auth_pages
node_auth_pages -->|"renders"| node_auth_ui
node_auth_ui -->|"submits to"| node_auth_actions
node_auth_actions -->|"signs in"| node_auth_core
node_auth_core -->|"looks up users"| node_prisma
node_auth_core -->|"supports OAuth"| node_google
node_user -->|"opens"| node_dashboard_route
node_dashboard_route -->|"renders"| node_dashboard_view
node_dashboard_view -->|"renders"| node_document_grid
node_document_grid -->|"uses"| node_document_cache
node_document_grid -->|"renders"| node_document_cards
node_document_cache -->|"requests documents"| node_document_actions
node_document_actions -->|"reads and writes"| node_prisma
node_prisma -->|"persists metadata"| node_database
node_user -->|"opens document"| node_document_route
node_document_route -->|"loads document"| node_document_actions
node_document_route -->|"renders room"| node_document_room
node_document_room -->|"renders editor"| node_editor_shell
node_editor_shell -->|"provides controls"| node_editor_controls
node_editor_controls -->|"invokes"| node_editor_commands
node_document_room -.->|"requests room access"| node_liveblocks_auth
node_liveblocks_auth -->|"checks session"| node_auth_core
node_liveblocks_auth -->|"checks ownership"| node_prisma
node_liveblocks_auth -->|"authorizes room"| node_liveblocks
node_editor_shell -.->|"syncs edits"| node_liveblocks
node_liveblocks -.->|"provides presence"| node_presence
node_user -->|"opens link"| node_share_route
node_share_route -->|"loads shared snapshot"| node_document_actions
node_share_route -->|"renders snapshot"| node_shared_view
node_document_actions -->|"stores snapshots"| node_database

click node_auth_pages "https://github.com/mdsohail07/nexuspad/blob/main/app/login/page.tsx"
click node_auth_ui "https://github.com/mdsohail07/nexuspad/tree/main/components/auth"
click node_auth_actions "https://github.com/mdsohail07/nexuspad/blob/main/app/actions/auth.ts"
click node_auth_core "https://github.com/mdsohail07/nexuspad/blob/main/auth.ts"
click node_dashboard_route "https://github.com/mdsohail07/nexuspad/blob/main/app/page.tsx"
click node_dashboard_view "https://github.com/mdsohail07/nexuspad/blob/main/components/dashboard/dashboard-view.tsx"
click node_document_grid "https://github.com/mdsohail07/nexuspad/blob/main/components/dashboard/document-grid.tsx"
click node_document_cards "https://github.com/mdsohail07/nexuspad/blob/main/components/dashboard/document-card.tsx"
click node_document_cache "https://github.com/mdsohail07/nexuspad/blob/main/lib/hooks/use-documents.ts"
click node_document_actions "https://github.com/mdsohail07/nexuspad/blob/main/app/actions/documents.ts"
click node_document_route "https://github.com/mdsohail07/nexuspad/blob/main/app/documents/%5Bid%5D/page.tsx"
click node_document_room "https://github.com/mdsohail07/nexuspad/blob/main/components/editor/document-room.tsx"
click node_editor_shell "https://github.com/mdsohail07/nexuspad/blob/main/components/editor/editor-shell.tsx"
click node_editor_controls "https://github.com/mdsohail07/nexuspad/blob/main/components/editor/editor-toolbar.tsx"
click node_editor_commands "https://github.com/mdsohail07/nexuspad/blob/main/components/editor/editor-commands.ts"
click node_presence "https://github.com/mdsohail07/nexuspad/blob/main/components/editor/presence-avatars.tsx"
click node_liveblocks_auth "https://github.com/mdsohail07/nexuspad/blob/main/app/api/liveblocks-auth/route.ts"
click node_share_route "https://github.com/mdsohail07/nexuspad/blob/main/app/share/%5Btoken%5D/page.tsx"
click node_shared_view "https://github.com/mdsohail07/nexuspad/blob/main/components/editor/shared-document-view.tsx"
click node_prisma "https://github.com/mdsohail07/nexuspad/blob/main/lib/prisma.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_auth_pages,node_auth_ui,node_auth_actions,node_auth_core,node_user toneBlue
class node_dashboard_route,node_dashboard_view,node_document_grid,node_document_cards,node_document_cache,node_document_actions toneAmber
class node_document_route,node_document_room,node_editor_shell,node_editor_controls,node_editor_commands,node_presence,node_liveblocks_auth toneMint
class node_share_route,node_shared_view toneRose
class node_database,node_prisma,node_google,node_liveblocks toneIndigo
```

## Components

### Identity

- [Sign-in pages](https://github.com/mdsohail07/nexuspad/blob/main/app/login/page.tsx): `app/login/page.tsx`
- [Auth forms](https://github.com/mdsohail07/nexuspad/tree/main/components/auth): `components/auth`
- [Auth actions](https://github.com/mdsohail07/nexuspad/blob/main/app/actions/auth.ts): `app/actions/auth.ts`
- [Auth.js](https://github.com/mdsohail07/nexuspad/blob/main/auth.ts): `auth.ts`

### Document workspace

- [Dashboard route](https://github.com/mdsohail07/nexuspad/blob/main/app/page.tsx): `app/page.tsx`
- [Dashboard view](https://github.com/mdsohail07/nexuspad/blob/main/components/dashboard/dashboard-view.tsx): `components/dashboard/dashboard-view.tsx`
- [Document grid](https://github.com/mdsohail07/nexuspad/blob/main/components/dashboard/document-grid.tsx): `components/dashboard/document-grid.tsx`
- [Document cards](https://github.com/mdsohail07/nexuspad/blob/main/components/dashboard/document-card.tsx): `components/dashboard/document-card.tsx`
- [Document cache](https://github.com/mdsohail07/nexuspad/blob/main/lib/hooks/use-documents.ts): `lib/hooks/use-documents.ts`
- [Document actions](https://github.com/mdsohail07/nexuspad/blob/main/app/actions/documents.ts): `app/actions/documents.ts`

### Editing and collaboration

- [Document route](https://github.com/mdsohail07/nexuspad/blob/main/app/documents/%5Bid%5D/page.tsx): `app/documents/[id]/page.tsx`
- [Collaboration room](https://github.com/mdsohail07/nexuspad/blob/main/components/editor/document-room.tsx): `components/editor/document-room.tsx`
- [Editor interface](https://github.com/mdsohail07/nexuspad/blob/main/components/editor/editor-shell.tsx): `components/editor/editor-shell.tsx`
- [Editor controls](https://github.com/mdsohail07/nexuspad/blob/main/components/editor/editor-toolbar.tsx): `components/editor/editor-toolbar.tsx`
- [Editor commands](https://github.com/mdsohail07/nexuspad/blob/main/components/editor/editor-commands.ts): `components/editor/editor-commands.ts`
- [Presence display](https://github.com/mdsohail07/nexuspad/blob/main/components/editor/presence-avatars.tsx): `components/editor/presence-avatars.tsx`
- [Room authorization](https://github.com/mdsohail07/nexuspad/blob/main/app/api/liveblocks-auth/route.ts): `app/api/liveblocks-auth/route.ts`

### Public sharing

- [Shared document route](https://github.com/mdsohail07/nexuspad/blob/main/app/share/%5Btoken%5D/page.tsx): `app/share/[token]/page.tsx`
- [Read-only view](https://github.com/mdsohail07/nexuspad/blob/main/components/editor/shared-document-view.tsx): `components/editor/shared-document-view.tsx`

### Persistence and services

- **PostgreSQL**
- [Prisma client](https://github.com/mdsohail07/nexuspad/blob/main/lib/prisma.ts): `lib/prisma.ts`

### Other components

- **User**
- **Google OAuth**
- **Liveblocks**

## Connections

- User → Sign-in pages: opens (evidence: `app/login/page.tsx`)
- Sign-in pages → Auth forms: renders (evidence: `app/login/page.tsx`)
- Auth forms → Auth actions: submits to (evidence: `components/auth/login-form.tsx`)
- Auth actions → Auth.js: signs in (evidence: `app/actions/auth.ts`)
- Auth.js → Prisma client: looks up users (evidence: `auth.ts`)
- Auth.js → Google OAuth: supports OAuth (evidence: `auth.ts`)
- User → Dashboard route: opens (evidence: `app/page.tsx`)
- Dashboard route → Dashboard view: renders (evidence: `app/page.tsx`)
- Dashboard view → Document grid: renders (evidence: `components/dashboard/dashboard-view.tsx`)
- Document grid → Document cache: uses (evidence: `components/dashboard/document-grid.tsx`)
- Document grid → Document cards: renders (evidence: `components/dashboard/document-grid.tsx`)
- Document cache → Document actions: requests documents (evidence: `lib/hooks/use-documents.ts`)
- Document actions → Prisma client: reads and writes (evidence: `app/actions/documents.ts`)
- Prisma client → PostgreSQL: persists metadata
- User → Document route: opens document (evidence: `app/documents/[id]/page.tsx`)
- Document route → Document actions: loads document (evidence: `app/documents/[id]/page.tsx`)
- Document route → Collaboration room: renders room (evidence: `app/documents/[id]/page.tsx`)
- Collaboration room → Editor interface: renders editor (evidence: `components/editor/document-room.tsx`)
- Editor interface → Editor controls: provides controls (evidence: `components/editor/editor-toolbar.tsx`)
- Editor controls → Editor commands: invokes (evidence: `components/editor/editor-toolbar.tsx`)
- Collaboration room → Room authorization: requests room access
- Room authorization → Auth.js: checks session (evidence: `app/api/liveblocks-auth/route.ts`)
- Room authorization → Prisma client: checks ownership (evidence: `app/api/liveblocks-auth/route.ts`)
- Room authorization → Liveblocks: authorizes room (evidence: `app/api/liveblocks-auth/route.ts`)
- Editor interface → Liveblocks: syncs edits
- Liveblocks → Presence display: provides presence
- User → Shared document route: opens link
- Shared document route → Document actions: loads shared snapshot (evidence: `app/share/[token]/page.tsx`)
- Shared document route → Read-only view: renders snapshot (evidence: `app/share/[token]/page.tsx`)
- Document actions → PostgreSQL: stores snapshots
