MarkdownHub#
Collaborative Markdown editor with real-time preview, version history, and multi-file repository support.
Phase 1 — Solo Editor MVP (current)#
What's built:
- Auth: Email/password registration and login, plus GitHub/Google OAuth stubs
- Repositories: Create repos with name, description, visibility (private/public/unlisted)
- File management: Create, browse, view, and edit Markdown files within repos
- Split-pane editor: CodeMirror 6 on the left, rendered Markdown on the right
- Auto-save: Saves content after 2s of inactivity (no version created)
- Manual save with version: Creates a named snapshot for version history
- Version history: List all versions, select two to compare
- Diff viewer: Side-by-side diff with line-level add/delete highlighting
- Server-side rendering: Go templates, goldmark for Markdown rendering
Stack#
| Layer | Tech |
|---|---|
| Backend | Go (net/http, gorilla/sessions, gorilla/websocket) |
| Database | SQLite (WAL mode) |
| Editor | CodeMirror 6 |
| Markdown | goldmark (server), API-based preview (client) |
| Diff | sergi/go-diff |
| Auth | bcrypt + OAuth2 (GitHub, Google) |
| Deploy | fly.io |
Running locally#
# Set env vars (or use defaults for dev)
export SESSION_SECRET="your-secret-here"
export BASE_URL="http://127.0.0.1:8080"
# Optional: OAuth (skip for password-only auth)
export GITHUB_CLIENT_ID="..."
export GITHUB_CLIENT_SECRET="..."
export GOOGLE_CLIENT_ID="..."
export GOOGLE_CLIENT_SECRET="..."
# Build and run
go build -o markdownhub ./cmd/server
./markdownhub
Server starts on :8080.
What's next#
Phase 2 — Comments#
- Line-anchored comments with content hash drift detection
- Threaded replies (one level)
- Resolve/unresolve
- Gutter indicators in editor
Phase 3 — Collaborative Editing#
- Yjs CRDT via WebSocket
- Real-time multi-user editing
- Presence indicators (cursors, selections)
- Awareness protocol
Project structure#
markdownhub/
├── cmd/server/main.go # Entry point, routing
├── internal/
│ ├── auth/ # Sessions, password hashing, OAuth config
│ ├── db/ # SQLite queries and migrations
│ ├── handler/ # HTTP handlers
│ ├── middleware/ # Auth injection, logging
│ ├── model/ # Data structs
│ ├── render/ # Goldmark Markdown rendering
│ └── version/ # Diff computation
├── migrations/ # SQL migration files
├── static/css/ # Stylesheets
├── templates/ # Go HTML templates
├── Dockerfile
└── fly.toml
Note on CodeMirror#
The editor template references CodeMirror 6 modules at /static/vendor/codemirror.js and /static/vendor/codemirror-lang-markdown.js. You'll need to bundle these yourself (or use a CDN). A quick way:
npm init -y
npm install @codemirror/state @codemirror/view @codemirror/lang-markdown codemirror
npx esbuild --bundle --format=esm --outfile=static/vendor/codemirror.js node_modules/codemirror/dist/index.js
npx esbuild --bundle --format=esm --outfile=static/vendor/codemirror-lang-markdown.js node_modules/@codemirror/lang-markdown/dist/index.js