# rxodhks/live_template architecture

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

- Interactive diagram: https://gitdiagram.com/rxodhks/live_template
- Repository: https://github.com/rxodhks/live_template

## Overview

Madang is a template workspace for design, coding, and documents, with personal and invite-enabled collaborative spaces. The user journey runs from sign-in and account setup to a dashboard or template workspace, where edits are saved locally and backed up or synchronized; inviting members enables live collaboration. The README also documents timelines, encrypted secret notes, version history, presence, chat, and access controls. The graph combines documented capabilities with shown routing and module references; unsampled feature internals are represented at their existing paths, without asserting unverified call sequences.

Main entry points: [`worker/src/index.ts`](https://github.com/rxodhks/live_template/blob/main/worker/src/index.ts) (HTTP and WebSocket routes), [`client/src/workspace/Workspace.tsx`](https://github.com/rxodhks/live_template/blob/main/client/src/workspace/Workspace.tsx) (Workspace shell), [`client/src/App.tsx`](https://github.com/rxodhks/live_template/blob/main/client/src/App.tsx) (App routing), [`client/src/lib/auth.ts`](https://github.com/rxodhks/live_template/blob/main/client/src/lib/auth.ts) (Auth client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_app["App routing<br/>[App.tsx]"]
  node_dashboard["Template dashboard<br/>[Dashboard.tsx]"]
  node_join["Invite entry<br/>[JoinPage.tsx]"]
  node_templates["Template state<br/>[templates.ts]"]
  node_api["HTTP API client<br/>[api.ts]"]
end

subgraph group_workspace["Workspace editing"]
  node_workspacepage["Workspace shell<br/>[Workspace.tsx]"]
  node_design["Design editor<br/>[DesignModule.tsx]"]
  node_code["Code editor<br/>[CodeModule.tsx]"]
  node_notes["Secret notes<br/>[NotesModule.tsx]"]
  node_localdata[("Local persistence<br/>[local.ts]")]
end

subgraph group_collab["Collaboration"]
  node_timeline["Activity timelines<br/>[timeline.ts]"]
  node_realtime["Realtime provider<br/>[yprovider.ts]"]
  node_protocol["Realtime protocol<br/>[protocol.ts]"]
  node_schema["Shared data schema<br/>[schema.ts]"]
end

subgraph group_identity["Identity and access"]
  node_authui["Sign-in screens<br/>[Auth.tsx]"]
  node_session["Session state<br/>[session.ts]"]
  node_authclient["Auth client<br/>[auth.ts]"]
end

subgraph group_server["Worker services"]
  node_worker["HTTP and WebSocket routes<br/>[index.ts]"]
  node_directory[("Accounts and invites<br/>[directory.ts]")]
  node_room[("Collaboration room<br/>[room.ts]")]
  node_mail["Authentication email<br/>[mail.ts]"]
  node_passkey["Passkey verification<br/>[passkey.ts]"]
  node_versionhistory["Version history<br/>[versions.ts]"]
end

node_user(("Workspace user"))
node_oauth(("OAuth providers"))
node_emailservice["Email delivery"]

node_user -->|"signs in"| node_authui
node_user -->|"opens workspace"| node_dashboard
node_user -->|"opens invite"| node_join
node_app -->|"routes to"| node_authui
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_workspacepage
node_authui -->|"authenticates with"| node_authclient
node_authclient -->|"requests via"| node_api
node_authclient -->|"updates"| node_session
node_api -->|"sends requests"| node_worker
node_oauth -.->|"authorizes"| node_worker
node_worker -->|"dispatches account work"| node_directory
node_worker -->|"dispatches room work"| node_room
node_worker -->|"sends login code"| node_mail
node_directory -->|"verifies credentials"| node_passkey
node_mail -.->|"delivers email"| node_emailservice
node_dashboard -.->|"reads templates"| node_templates
node_workspacepage -.->|"renders editor"| node_design
node_workspacepage -.->|"renders editor"| node_code
node_workspacepage -->|"renders editor"| node_notes
node_workspacepage -->|"provides collaboration"| node_realtime
node_design -.->|"saves edits"| node_localdata
node_code -.->|"saves edits"| node_localdata
node_notes -->|"stores encrypted notes"| node_localdata
node_realtime -->|"exchanges messages"| node_protocol
node_protocol -->|"defines room messages"| node_room
node_room -->|"manages retention"| node_versionhistory
node_timeline -.->|"loads activity"| node_worker
node_schema -.->|"defines shared data"| node_directory

click node_app "https://github.com/rxodhks/live_template/blob/main/client/src/App.tsx"
click node_authui "https://github.com/rxodhks/live_template/blob/main/client/src/pages/Auth.tsx"
click node_dashboard "https://github.com/rxodhks/live_template/blob/main/client/src/pages/Dashboard.tsx"
click node_join "https://github.com/rxodhks/live_template/blob/main/client/src/pages/JoinPage.tsx"
click node_workspacepage "https://github.com/rxodhks/live_template/blob/main/client/src/workspace/Workspace.tsx"
click node_design "https://github.com/rxodhks/live_template/blob/main/client/src/modules/design/DesignModule.tsx"
click node_code "https://github.com/rxodhks/live_template/blob/main/client/src/modules/code/CodeModule.tsx"
click node_notes "https://github.com/rxodhks/live_template/blob/main/client/src/modules/notes/NotesModule.tsx"
click node_timeline "https://github.com/rxodhks/live_template/blob/main/client/src/lib/timeline.ts"
click node_templates "https://github.com/rxodhks/live_template/blob/main/client/src/store/templates.ts"
click node_session "https://github.com/rxodhks/live_template/blob/main/client/src/store/session.ts"
click node_authclient "https://github.com/rxodhks/live_template/blob/main/client/src/lib/auth.ts"
click node_api "https://github.com/rxodhks/live_template/blob/main/client/src/lib/api.ts"
click node_localdata "https://github.com/rxodhks/live_template/blob/main/client/src/lib/local.ts"
click node_realtime "https://github.com/rxodhks/live_template/blob/main/client/src/lib/yprovider.ts"
click node_protocol "https://github.com/rxodhks/live_template/blob/main/shared/protocol.ts"
click node_worker "https://github.com/rxodhks/live_template/blob/main/worker/src/index.ts"
click node_directory "https://github.com/rxodhks/live_template/blob/main/worker/src/directory.ts"
click node_room "https://github.com/rxodhks/live_template/blob/main/worker/src/room.ts"
click node_mail "https://github.com/rxodhks/live_template/blob/main/worker/src/mail.ts"
click node_passkey "https://github.com/rxodhks/live_template/blob/main/worker/src/passkey.ts"
click node_schema "https://github.com/rxodhks/live_template/blob/main/shared/schema.ts"
click node_versionhistory "https://github.com/rxodhks/live_template/blob/main/worker/src/versions.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_app,node_dashboard,node_join,node_templates,node_api,node_user toneBlue
class node_workspacepage,node_design,node_code,node_notes,node_localdata toneAmber
class node_timeline,node_realtime,node_protocol,node_schema toneMint
class node_authui,node_session,node_authclient toneRose
class node_worker,node_directory,node_room,node_mail,node_passkey,node_versionhistory,node_oauth,node_emailservice toneIndigo
```

## Components

### Client experience

- [App routing](https://github.com/rxodhks/live_template/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Template dashboard](https://github.com/rxodhks/live_template/blob/main/client/src/pages/Dashboard.tsx): `client/src/pages/Dashboard.tsx`
- [Invite entry](https://github.com/rxodhks/live_template/blob/main/client/src/pages/JoinPage.tsx): `client/src/pages/JoinPage.tsx`
- [Template state](https://github.com/rxodhks/live_template/blob/main/client/src/store/templates.ts): `client/src/store/templates.ts`
- [HTTP API client](https://github.com/rxodhks/live_template/blob/main/client/src/lib/api.ts): `client/src/lib/api.ts`

### Workspace editing

- [Workspace shell](https://github.com/rxodhks/live_template/blob/main/client/src/workspace/Workspace.tsx): `client/src/workspace/Workspace.tsx`
- [Design editor](https://github.com/rxodhks/live_template/blob/main/client/src/modules/design/DesignModule.tsx): `client/src/modules/design/DesignModule.tsx`
- [Code editor](https://github.com/rxodhks/live_template/blob/main/client/src/modules/code/CodeModule.tsx): `client/src/modules/code/CodeModule.tsx`
- [Secret notes](https://github.com/rxodhks/live_template/blob/main/client/src/modules/notes/NotesModule.tsx): `client/src/modules/notes/NotesModule.tsx`
- [Local persistence](https://github.com/rxodhks/live_template/blob/main/client/src/lib/local.ts): `client/src/lib/local.ts`

### Collaboration

- [Activity timelines](https://github.com/rxodhks/live_template/blob/main/client/src/lib/timeline.ts): `client/src/lib/timeline.ts`
- [Realtime provider](https://github.com/rxodhks/live_template/blob/main/client/src/lib/yprovider.ts): `client/src/lib/yprovider.ts`
- [Realtime protocol](https://github.com/rxodhks/live_template/blob/main/shared/protocol.ts): `shared/protocol.ts`
- [Shared data schema](https://github.com/rxodhks/live_template/blob/main/shared/schema.ts): `shared/schema.ts`

### Identity and access

- [Sign-in screens](https://github.com/rxodhks/live_template/blob/main/client/src/pages/Auth.tsx): `client/src/pages/Auth.tsx`
- [Session state](https://github.com/rxodhks/live_template/blob/main/client/src/store/session.ts): `client/src/store/session.ts`
- [Auth client](https://github.com/rxodhks/live_template/blob/main/client/src/lib/auth.ts): `client/src/lib/auth.ts`

### Worker services

- [HTTP and WebSocket routes](https://github.com/rxodhks/live_template/blob/main/worker/src/index.ts): `worker/src/index.ts`
- [Accounts and invites](https://github.com/rxodhks/live_template/blob/main/worker/src/directory.ts): `worker/src/directory.ts`
- [Collaboration room](https://github.com/rxodhks/live_template/blob/main/worker/src/room.ts): `worker/src/room.ts`
- [Authentication email](https://github.com/rxodhks/live_template/blob/main/worker/src/mail.ts): `worker/src/mail.ts`
- [Passkey verification](https://github.com/rxodhks/live_template/blob/main/worker/src/passkey.ts): `worker/src/passkey.ts`
- [Version history](https://github.com/rxodhks/live_template/blob/main/worker/src/versions.ts): `worker/src/versions.ts`

### Other components

- **Workspace user**
- **OAuth providers**
- **Email delivery**

## Connections

- Workspace user → Sign-in screens: signs in
- Workspace user → Template dashboard: opens workspace
- Workspace user → Invite entry: opens invite
- App routing → Sign-in screens: routes to (evidence: `client/src/App.tsx`)
- App routing → Template dashboard: routes to (evidence: `client/src/App.tsx`)
- App routing → Workspace shell: routes to (evidence: `client/src/App.tsx`)
- Sign-in screens → Auth client: authenticates with (evidence: `client/src/pages/Auth.tsx`)
- Auth client → HTTP API client: requests via (evidence: `client/src/lib/auth.ts`)
- Auth client → Session state: updates (evidence: `client/src/lib/auth.ts`)
- HTTP API client → HTTP and WebSocket routes: sends requests (evidence: `client/src/lib/api.ts`)
- OAuth providers → HTTP and WebSocket routes: authorizes
- HTTP and WebSocket routes → Accounts and invites: dispatches account work (evidence: `worker/src/index.ts`)
- HTTP and WebSocket routes → Collaboration room: dispatches room work (evidence: `worker/src/index.ts`)
- HTTP and WebSocket routes → Authentication email: sends login code (evidence: `worker/src/index.ts`)
- Accounts and invites → Passkey verification: verifies credentials (evidence: `worker/src/directory.ts`)
- Authentication email → Email delivery: delivers email
- Template dashboard → Template state: reads templates
- Workspace shell → Design editor: renders editor
- Workspace shell → Code editor: renders editor
- Workspace shell → Secret notes: renders editor
- Workspace shell → Realtime provider: provides collaboration
- Design editor → Local persistence: saves edits
- Code editor → Local persistence: saves edits
- Secret notes → Local persistence: stores encrypted notes
- Realtime provider → Realtime protocol: exchanges messages
- Realtime protocol → Collaboration room: defines room messages (evidence: `shared/protocol.ts`)
- Collaboration room → Version history: manages retention (evidence: `worker/src/room.ts`)
- Activity timelines → HTTP and WebSocket routes: loads activity
- Shared data schema → Accounts and invites: defines shared data
