From 8e6646499f971a1377b932fba967159d280bab7b Mon Sep 17 00:00:00 2001 From: Tim Bendt Date: Tue, 28 Apr 2026 23:59:45 -0400 Subject: [PATCH] docs: add project planning documents --- docs/adrs/adr-001-tech-stack.md | 53 +++ docs/adrs/adr-002-sync-protocol.md | 81 +++++ docs/adrs/adr-003-ssr-strategy.md | 67 ++++ docs/adrs/adr-004-auth-strategy.md | 74 ++++ docs/adrs/adr-005-storage-strategy.md | 68 ++++ docs/adrs/adr-006-email-strategy.md | 79 +++++ docs/adrs/adr-007-security-model.md | 69 ++++ docs/architecture-overview.md | 316 +++++++++++++++++ docs/milestones/milestone-01-foundation.md | 118 +++++++ docs/milestones/milestone-02-sync-protocol.md | 143 ++++++++ .../milestones/milestone-03-authentication.md | 134 +++++++ docs/milestones/milestone-04-collaboration.md | 171 +++++++++ docs/milestones/milestone-05-search-ui.md | 195 +++++++++++ docs/milestones/milestone-06-production.md | 150 ++++++++ docs/project-plan.md | 328 ++++++++++++++++++ docs/specs/simplesync-protocol.md | 297 ++++++++++++++++ 16 files changed, 2343 insertions(+) create mode 100644 docs/adrs/adr-001-tech-stack.md create mode 100644 docs/adrs/adr-002-sync-protocol.md create mode 100644 docs/adrs/adr-003-ssr-strategy.md create mode 100644 docs/adrs/adr-004-auth-strategy.md create mode 100644 docs/adrs/adr-005-storage-strategy.md create mode 100644 docs/adrs/adr-006-email-strategy.md create mode 100644 docs/adrs/adr-007-security-model.md create mode 100644 docs/architecture-overview.md create mode 100644 docs/milestones/milestone-01-foundation.md create mode 100644 docs/milestones/milestone-02-sync-protocol.md create mode 100644 docs/milestones/milestone-03-authentication.md create mode 100644 docs/milestones/milestone-04-collaboration.md create mode 100644 docs/milestones/milestone-05-search-ui.md create mode 100644 docs/milestones/milestone-06-production.md create mode 100644 docs/project-plan.md create mode 100644 docs/specs/simplesync-protocol.md diff --git a/docs/adrs/adr-001-tech-stack.md b/docs/adrs/adr-001-tech-stack.md new file mode 100644 index 0000000..02a889d --- /dev/null +++ b/docs/adrs/adr-001-tech-stack.md @@ -0,0 +1,53 @@ +# ADR-001: Go Backend with Preact Frontend + +## Status +Accepted + +## Context +We need to choose a backend language/framework and frontend technology for a documentation platform with these requirements: +- Ultra-fast performance +- Minimal external dependencies +- No vendor lock-in +- Battle-tested security +- Server-side rendering for non-interactive pages +- Offline-capable web client + +## Decision +**Backend**: Go 1.22+ with standard library plus minimal, well-audited packages +**Frontend**: Preact 10 with TypeScript, Vite build system + +## Consequences + +### Positive +- Go's standard library is comprehensive and security-audited +- Single static binary deployment — no runtime dependencies +- Preact is 10KB (vs 40KB+ React) with identical API +- Go's `html/template` provides safe SSR with auto-escaping +- TypeScript gives type safety without runtime overhead +- Both ecosystems have excellent supply-chain security (Go modules with checksums, npm audit) + +### Negative +- Go template syntax is less expressive than JSX +- WebSocket sync logic must be implemented manually (no framework like Socket.io) +- Preact ecosystem smaller than React (mitigated by using mostly native APIs) + +## Alternatives Considered + +### Rust + Axum +- **Pros**: Memory safety guarantees, excellent performance +- **Cons**: Longer compile times, smaller talent pool, steeper learning curve for team +- **Rejected**: Go's pragmatic balance of safety and velocity better fits project timeline + +### Deno Fresh +- **Pros**: Island architecture, native TypeScript, no build step +- **Cons**: Newer ecosystem, fewer audited libraries, Deno runtime less battle-tested than Go +- **Rejected**: Go's maturity and deployment simplicity preferred + +### Next.js / React Server Components +- **Pros**: Mature ecosystem, built-in SSR +- **Cons**: Heavy bundle size, complex build system, RSC lock-in, many dependencies +- **Rejected**: Violates "minimal dependencies" and "no vendor lock-in" principles + +## References +- Go Security Policy: https://go.dev/security +- Preact Size Comparison: https://bundlephobia.com/package/preact@10.19.3 diff --git a/docs/adrs/adr-002-sync-protocol.md b/docs/adrs/adr-002-sync-protocol.md new file mode 100644 index 0000000..ff424b3 --- /dev/null +++ b/docs/adrs/adr-002-sync-protocol.md @@ -0,0 +1,81 @@ +# ADR-002: SimpleSync Protocol + +## Status +Accepted + +## Context +Users need to edit markdown files on their local filesystem (using any editor) and have changes reflected on the web automatically. Multiple users should be able to work on different files simultaneously without conflicts. We need a sync mechanism simpler than git but robust enough for production use. + +## Decision +Implement **SimpleSync**: a content-addressed, Merkle-tree-inspired sync protocol over WebSocket with the following characteristics: + +1. **Content-addressed storage**: All files identified by SHA-256 hash +2. **File-level granularity**: Parallel editing of different files is conflict-free +3. **Automatic sync**: File watcher detects changes and pushes to server +4. **Three-way merge**: Only when same file edited concurrently +5. **No branches/commits**: Just current state + history log + +## Protocol Flow + +### Client → Server: Sync Request +```json +{ + "type": "sync_request", + "client_root_hash": "abc123...", + "client_files": { + "getting-started.md": "hash1", + "api-reference.md": "hash2" + } +} +``` + +### Server → Client: Sync Response +```json +{ + "type": "sync_response", + "server_root_hash": "def456...", + "missing_from_client": ["hash3", "hash4"], + "missing_from_server": ["hash5"], + "conflicts": ["getting-started.md"] +} +``` + +### Content Transfer +Files transferred by hash: `GET /content/{hash}` or WebSocket binary frames + +## Consequences + +### Positive +- Dramatically simpler mental model than git +- Automatic — no user commands needed +- Works with any text editor +- Immutable file store provides natural deduplication +- Easy to implement offline queue: just store hashes and content + +### Negative +- No offline branching (by design) +- Conflict resolution UI must be built +- No rebase/squash history manipulation (intentional simplicity) +- Large binary files could bloat content store (mitigated by size limits) + +## Alternatives Considered + +### Git-based sync +- **Pros**: Mature, well-understood, existing tools +- **Cons**: Requires git on client, complex merge UX, repo-level locking +- **Rejected**: Too complex for notes; overkill for target use case + +### CRDTs (Yjs, Automerge) +- **Pros**: Real-time collaborative editing, automatic conflict resolution +- **Cons**: Complex to implement correctly, memory overhead, designed for real-time not async +- **Rejected**: Requirement is async-only; CRDTs are overkill + +### rsync / Unison +- **Pros**: Battle-tested file sync +- **Cons**: No concept of "versions" or "comments", no web integration +- **Rejected**: Doesn't meet collaboration requirements + +## References +- Content-addressable storage: https://en.wikipedia.org/wiki/Content-addressable_storage +- Merkle trees: https://en.wikipedia.org/wiki/Merkle_tree +- WebSocket RFC: https://tools.ietf.org/html/rfc6455 diff --git a/docs/adrs/adr-003-ssr-strategy.md b/docs/adrs/adr-003-ssr-strategy.md new file mode 100644 index 0000000..fa9c6e5 --- /dev/null +++ b/docs/adrs/adr-003-ssr-strategy.md @@ -0,0 +1,67 @@ +# ADR-003: SSR Strategy - Go Templates with Preact Hydration + +## Status +Accepted + +## Context +The application needs to serve document pages that are readable without JavaScript (for performance and accessibility), while providing rich interactivity (comments, editing, search) when JavaScript is available. We need a server-side rendering strategy that works with our Go backend and Preact frontend. + +## Decision +**Strategy C**: Go's `html/template` renders initial HTML for all pages. Preact hydrates interactive components on the client. + +### Implementation Details + +1. **Server Rendering**: + - Go handlers query database for document content + - Markdown parsed to HTML server-side (Goldmark) + - `html/template` renders full page with document HTML embedded + - No JavaScript required for reading + +2. **Client Hydration**: + - Preact components mount into designated DOM containers + - Comments, search, editor are Preact islands + - Static content remains server-rendered HTML + - `preact-iso` handles client-side navigation between pages + +3. **Data Passing**: + - Initial state embedded as JSON in `