# taonga07/driftwood-cms architecture

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

- Interactive diagram: https://gitdiagram.com/taonga07/driftwood-cms
- Repository: https://github.com/taonga07/driftwood-cms

## Overview

Driftwood is a shared, browser-based Git CMS for Hugo sites. A site admin signs in through the shared Worker, connects a GitHub repository, edits content and site configuration in the browser, then publishes changes directly to GitHub. The Worker handles tenant-specific authentication and OAuth exchange; site content does not pass through it. The graph preserves documented editing, media, revisions, settings, and theme capabilities. Some editor internals and Worker routes were not sampled, so their detailed connections are omitted.

Main entry points: [`public/fs.js`](https://github.com/taonga07/driftwood-cms/blob/master/public/fs.js) (Git virtual filesystem), [`public/app.js`](https://github.com/taonga07/driftwood-cms/blob/master/public/app.js) (Panel router), [`public/editors/content-editor.js`](https://github.com/taonga07/driftwood-cms/blob/master/public/editors/content-editor.js) (Content editor), [`public/worker-auth.js`](https://github.com/taonga07/driftwood-cms/blob/master/public/worker-auth.js) (Worker auth client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Admin application"]
  node_shell["Panel router<br/>[app.js]"]
  node_site_config["CMS configuration<br/>[admin-config.js]"]
  node_theme["Theme controls<br/>[theme.js]"]
end

subgraph group_edit["Editing panels"]
  node_content["Content editor<br/>[content-editor.js]"]
  node_media["Media editor<br/>[media-editor.js]"]
  node_config_editors["Config and data<br/>[config-editor.js]"]
  node_cms_config["This CMS panel"]
  node_templates["Templates and code<br/>[template-editor.js]"]
  node_raw_browser["Raw file browser"]
  node_settings["Settings and accounts<br/>[settings-editor.js]"]
  node_dashboard["Dashboard<br/>[dashboard.js]"]
  node_hugo_schema["Hugo schema<br/>[hugo-schema.js]"]
  node_object_editor["Structured object editor<br/>[object-editor.js]"]
  node_file_tree["File tree<br/>[file-tree.js]"]
  node_codearea["Code editor widget<br/>[codearea.js]"]
end

subgraph group_repo["Repository workflow"]
  node_github_api["GitHub API"]
  node_fs["Git virtual filesystem<br/>[fs.js]"]
  node_browser_db[("Draft and cache store<br/>[db.js]")]
  node_github_client["GitHub API client<br/>[github.js]"]
  node_revisions["Revisions and publish"]
end

subgraph group_identity["Authentication"]
  node_onboarding["Onboarding screens<br/>[onboarding.js]"]
  node_worker_auth["Worker auth client<br/>[worker-auth.js]"]
  node_worker["Auth and OAuth API<br/>[worker.js]"]
  node_d1[("Tenant accounts")]
end

node_admin(("Site admin"))
node_github_oauth["GitHub OAuth"]

node_admin -->|"opens admin"| node_shell
node_shell -->|"checks session"| node_worker_auth
node_shell -->|"starts setup"| node_onboarding
node_shell -->|"loads config"| node_site_config
node_shell -->|"routes panels"| node_content
node_worker_auth -->|"calls auth API"| node_worker
node_onboarding -->|"uses auth client"| node_worker_auth
node_onboarding -->|"opens OAuth"| node_github_oauth
node_worker -->|"exchanges code"| node_github_oauth
node_worker -->|"checks accounts"| node_d1
node_worker_auth -->|"stores session"| node_browser_db
node_shell -->|"connects repository"| node_fs
node_fs -->|"reads drafts and cache"| node_browser_db
node_fs -->|"fetches and commits"| node_github_client
node_github_client -->|"requests repository"| node_github_api
node_content -->|"reads and drafts"| node_fs
node_media -->|"manages media"| node_fs
node_config_editors -->|"reads and drafts"| node_fs
node_cms_config -->|"reads and drafts"| node_fs
node_templates -->|"reads and drafts"| node_fs
node_raw_browser -->|"reads and drafts"| node_fs
node_settings -->|"manages accounts"| node_worker_auth
node_settings -->|"reconnects GitHub"| node_onboarding
node_revisions -->|"switches revisions"| node_fs
node_revisions -->|"compares branches"| node_github_client
node_dashboard -->|"summarizes repository"| node_fs
node_content -->|"edits frontmatter"| node_object_editor
node_content -->|"selects content"| node_file_tree
node_content -->|"loads shortcode schemas"| node_hugo_schema
node_config_editors -->|"edits structured config"| node_object_editor
node_templates -->|"edits source"| node_codearea
node_raw_browser -->|"renders navigation"| node_file_tree
node_raw_browser -->|"edits source"| node_codearea
node_object_editor -->|"chooses image"| node_media
node_shell -->|"sets theme"| node_theme

click node_shell "https://github.com/taonga07/driftwood-cms/blob/master/public/app.js"
click node_site_config "https://github.com/taonga07/driftwood-cms/blob/master/public/admin-config.js"
click node_onboarding "https://github.com/taonga07/driftwood-cms/blob/master/public/onboarding.js"
click node_worker_auth "https://github.com/taonga07/driftwood-cms/blob/master/public/worker-auth.js"
click node_worker "https://github.com/taonga07/driftwood-cms/blob/master/worker.js"
click node_fs "https://github.com/taonga07/driftwood-cms/blob/master/public/fs.js"
click node_browser_db "https://github.com/taonga07/driftwood-cms/blob/master/public/db.js"
click node_github_client "https://github.com/taonga07/driftwood-cms/blob/master/public/github.js"
click node_content "https://github.com/taonga07/driftwood-cms/blob/master/public/editors/content-editor.js"
click node_media "https://github.com/taonga07/driftwood-cms/blob/master/public/editors/media-editor.js"
click node_config_editors "https://github.com/taonga07/driftwood-cms/blob/master/public/editors/config-editor.js"
click node_cms_config "https://github.com/taonga07/driftwood-cms/blob/master/public/editors/cms-config-editor.js"
click node_templates "https://github.com/taonga07/driftwood-cms/blob/master/public/editors/template-editor.js"
click node_raw_browser "https://github.com/taonga07/driftwood-cms/blob/master/public/components/raw-file-browser.js"
click node_settings "https://github.com/taonga07/driftwood-cms/blob/master/public/editors/settings-editor.js"
click node_revisions "https://github.com/taonga07/driftwood-cms/blob/master/public/editors/revisions-editor.js"
click node_dashboard "https://github.com/taonga07/driftwood-cms/blob/master/public/editors/dashboard.js"
click node_hugo_schema "https://github.com/taonga07/driftwood-cms/blob/master/public/hugo-schema.js"
click node_object_editor "https://github.com/taonga07/driftwood-cms/blob/master/public/components/object-editor.js"
click node_file_tree "https://github.com/taonga07/driftwood-cms/blob/master/public/components/file-tree.js"
click node_codearea "https://github.com/taonga07/driftwood-cms/blob/master/public/components/codearea.js"
click node_theme "https://github.com/taonga07/driftwood-cms/blob/master/public/theme.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_shell,node_site_config,node_theme toneBlue
class node_content,node_media,node_config_editors,node_cms_config,node_templates,node_raw_browser,node_settings,node_dashboard,node_hugo_schema,node_object_editor,node_file_tree,node_codearea toneAmber
class node_github_api,node_fs,node_browser_db,node_github_client,node_revisions toneMint
class node_onboarding,node_worker_auth,node_worker,node_d1 toneRose
class node_admin,node_github_oauth toneIndigo
```

## Components

### Admin application

- [Panel router](https://github.com/taonga07/driftwood-cms/blob/master/public/app.js): `public/app.js`
- [CMS configuration](https://github.com/taonga07/driftwood-cms/blob/master/public/admin-config.js): `public/admin-config.js`
- [Theme controls](https://github.com/taonga07/driftwood-cms/blob/master/public/theme.js): `public/theme.js`

### Editing panels

- [Content editor](https://github.com/taonga07/driftwood-cms/blob/master/public/editors/content-editor.js): `public/editors/content-editor.js`
- [Media editor](https://github.com/taonga07/driftwood-cms/blob/master/public/editors/media-editor.js): `public/editors/media-editor.js`
- [Config and data](https://github.com/taonga07/driftwood-cms/blob/master/public/editors/config-editor.js): `public/editors/config-editor.js`
- [This CMS panel](https://github.com/taonga07/driftwood-cms/blob/master/public/editors/cms-config-editor.js): `public/editors/cms-config-editor.js`
- [Templates and code](https://github.com/taonga07/driftwood-cms/blob/master/public/editors/template-editor.js): `public/editors/template-editor.js`
- [Raw file browser](https://github.com/taonga07/driftwood-cms/blob/master/public/components/raw-file-browser.js): `public/components/raw-file-browser.js`
- [Settings and accounts](https://github.com/taonga07/driftwood-cms/blob/master/public/editors/settings-editor.js): `public/editors/settings-editor.js`
- [Dashboard](https://github.com/taonga07/driftwood-cms/blob/master/public/editors/dashboard.js): `public/editors/dashboard.js`
- [Hugo schema](https://github.com/taonga07/driftwood-cms/blob/master/public/hugo-schema.js): `public/hugo-schema.js`
- [Structured object editor](https://github.com/taonga07/driftwood-cms/blob/master/public/components/object-editor.js): `public/components/object-editor.js`
- [File tree](https://github.com/taonga07/driftwood-cms/blob/master/public/components/file-tree.js): `public/components/file-tree.js`
- [Code editor widget](https://github.com/taonga07/driftwood-cms/blob/master/public/components/codearea.js): `public/components/codearea.js`

### Repository workflow

- **GitHub API**
- [Git virtual filesystem](https://github.com/taonga07/driftwood-cms/blob/master/public/fs.js): `public/fs.js`
- [Draft and cache store](https://github.com/taonga07/driftwood-cms/blob/master/public/db.js): `public/db.js`
- [GitHub API client](https://github.com/taonga07/driftwood-cms/blob/master/public/github.js): `public/github.js`
- [Revisions and publish](https://github.com/taonga07/driftwood-cms/blob/master/public/editors/revisions-editor.js): `public/editors/revisions-editor.js`

### Authentication

- [Onboarding screens](https://github.com/taonga07/driftwood-cms/blob/master/public/onboarding.js): `public/onboarding.js`
- [Worker auth client](https://github.com/taonga07/driftwood-cms/blob/master/public/worker-auth.js): `public/worker-auth.js`
- [Auth and OAuth API](https://github.com/taonga07/driftwood-cms/blob/master/worker.js): `worker.js`
- **Tenant accounts**

### Other components

- **Site admin**
- **GitHub OAuth**

## Connections

- Site admin → Panel router: opens admin (evidence: `README.md`)
- Panel router → Worker auth client: checks session (evidence: `public/app.js`)
- Panel router → Onboarding screens: starts setup (evidence: `public/app.js`)
- Panel router → CMS configuration: loads config (evidence: `public/app.js`)
- Panel router → Content editor: routes panels (evidence: `public/app.js`)
- Worker auth client → Auth and OAuth API: calls auth API (evidence: `public/worker-auth.js`)
- Onboarding screens → Worker auth client: uses auth client (evidence: `public/onboarding.js`)
- Onboarding screens → GitHub OAuth: opens OAuth (evidence: `public/onboarding.js`)
- Auth and OAuth API → GitHub OAuth: exchanges code (evidence: `README.md`)
- Auth and OAuth API → Tenant accounts: checks accounts (evidence: `README.md`)
- Worker auth client → Draft and cache store: stores session (evidence: `public/worker-auth.js`)
- Panel router → Git virtual filesystem: connects repository (evidence: `public/app.js`)
- Git virtual filesystem → Draft and cache store: reads drafts and cache (evidence: `public/fs.js`)
- Git virtual filesystem → GitHub API client: fetches and commits (evidence: `public/fs.js`)
- GitHub API client → GitHub API: requests repository (evidence: `public/github.js`)
- Content editor → Git virtual filesystem: reads and drafts (evidence: `public/editors/content-editor.js`)
- Media editor → Git virtual filesystem: manages media (evidence: `public/editors/media-editor.js`)
- Config and data → Git virtual filesystem: reads and drafts (evidence: `public/editors/config-editor.js`)
- This CMS panel → Git virtual filesystem: reads and drafts (evidence: `public/editors/cms-config-editor.js`)
- Templates and code → Git virtual filesystem: reads and drafts (evidence: `public/editors/template-editor.js`)
- Raw file browser → Git virtual filesystem: reads and drafts (evidence: `public/components/raw-file-browser.js`)
- Settings and accounts → Worker auth client: manages accounts (evidence: `public/editors/settings-editor.js`)
- Settings and accounts → Onboarding screens: reconnects GitHub (evidence: `public/editors/settings-editor.js`)
- Revisions and publish → Git virtual filesystem: switches revisions (evidence: `public/editors/revisions-editor.js`)
- Revisions and publish → GitHub API client: compares branches (evidence: `public/editors/revisions-editor.js`)
- Dashboard → Git virtual filesystem: summarizes repository (evidence: `public/editors/dashboard.js`)
- Content editor → Structured object editor: edits frontmatter (evidence: `public/editors/content-editor.js`)
- Content editor → File tree: selects content (evidence: `public/editors/content-editor.js`)
- Content editor → Hugo schema: loads shortcode schemas (evidence: `public/editors/content-editor.js`)
- Config and data → Structured object editor: edits structured config (evidence: `public/editors/config-editor.js`)
- Templates and code → Code editor widget: edits source (evidence: `public/editors/template-editor.js`)
- Raw file browser → File tree: renders navigation (evidence: `public/components/raw-file-browser.js`)
- Raw file browser → Code editor widget: edits source (evidence: `public/components/raw-file-browser.js`)
- Structured object editor → Media editor: chooses image (evidence: `public/components/object-editor.js`)
- Panel router → Theme controls: sets theme (evidence: `public/app.js`)
