# CLAUDE.md ## Project Overview `datascape` is a minimal personal wiki where **the folder structure is the wiki**. No database, no CMS, no abstraction layer — every folder is a page, and `index.md` in a folder is that page's content. ## Build & Deploy ```bash # Local build (host architecture) go build . # Deploy to NAS make deploy ``` ### Editor bundle (the one build-pipeline exception) The page editor uses CodeMirror 6, vendored as a single pre-built IIFE at `assets/editor/vendor/codemirror.bundle.js` and embedded via `embed.FS`. This is the **only** deliberate exception to the "no build pipeline" rule below — it is a one-time, committed artifact, not a runtime build. `go build` / `make deploy` never touch Node and only consume the committed bundle. Regenerate the bundle **only** when upgrading the `@codemirror/*` versions: ```bash # bump versions in editor-build/package.json first, then: make editor # runs `npm ci && npm run build` in editor-build/, rewrites the vendored bundle ``` Commit the regenerated `codemirror.bundle.js` and the updated `editor-build/package-lock.json`. `editor-build/node_modules/` is gitignored. ## HTTP API Surface | Method | Path | Behaviour | |--------|------|-----------| | GET | `/{path}/` | If folder exists: render `index.md` + list contents. If not: show empty create prompt. | | GET | `/{path}/?edit` | CodeMirror 6 editor initialized with `index.md` content | | POST | `/{path}` | Write `index.md` to disk; creates the folder if it does not exist yet | Non-existent paths without a trailing slash redirect to the slash form (GET only — POSTs are not redirected because `path.Clean` strips the trailing slash from `PostURL` and the content would be lost). Do not add new endpoints without a concrete stated need. ## Code Structure When adding a new special folder type, create a new `.go` file. Do not add type-specific logic to `main.go` or `render.go`. Prefer separate, human-readable `.html` files over inlined HTML strings in Go. Embed them via `embed.FS` if needed. ## Architecture Rules - **Single binary** — no installer, no runtime dependencies, no Docker - **Go stdlib `net/http`** only — no web framework - **`goldmark`** for Markdown rendering — no other Markdown libraries - **`embed.FS`** for all assets — no external serving, no CDN - **No database** of any kind - **No indexing or caching** unless explicitly requested and justified - Keep dependencies to an absolute minimum; if stdlib can do it, use stdlib ## Frontend Rules - Vanilla JS only — no frameworks, no build pipeline (the single exception is the vendored CodeMirror editor bundle; see Build & Deploy) - Each feature gets its own JS file; global behaviour goes in `global-shortcuts.js` - Do not inline JS in templates or merge unrelated features into one file - `ALT+SHIFT` is the modifier for all keyboard shortcuts — do not introduce others - Editor toolbar buttons use `data-action` + `data-key`; adding `data-key` auto-registers the shortcut - For mutating modals (anything that POSTs and then navigates), call `closeModal()` and then `postReplace(action, body, target)` from `page/actions.js`. Do NOT use `