How alangrainger/share-note works
Project Type & Purpose
• This is an Obsidian “plugin” (client-side extension) that:
• Reads a Markdown note (with theme, attachments, frontmatter) from the user’s vault
• Optionally encrypts the note
• Compresses & packages the content + theme assets
• Uploads via REST API to share.note.sx (or self-hosted server)
• Returns a shareable URL back to the user
File Structure
• Top level:
• src/ → TypeScript modules
– UI.ts (command-palette integration, settings modal)
– main.ts (plugin lifecycle hooks)
– api.ts (REST calls to server)
– crypto.ts (encrypt/decrypt routines)
– Compressor.ts (gzip or similar)
– NoteTemplate.ts (HTML/CSS templating)
– StatusMessage.ts (in-UI feedback)
– settings.ts (user preferences, encryption toggle)
• manifest.json (Obsidian plugin manifest)
• esbuild.config.mjs (bundling)
• styles.css (plugin UI styling)
• No backend code here; external service is separate (self-hosted Docker or note.sx cloud).
Readme Insights
• Encryption is optional per-note or global
• First share uploads theme assets once; subsequent shares reuse them
• External dependencies: Obsidian API, fetch/XHR, Web Crypto API
Main Components
A. Obsidian Host (Electron/Browser)
• Vault (file system)
• Obsidian Core API
B. Share Note Plugin
1. UI Module
• Triggers “Share Note” command
• Settings & status feedback
2. Core Modules
• NoteTemplate (render HTML)
• Compressor (minify/compress payload)
• crypto (AES-GCM or similar encryption)
3. API Client (api.ts)
• HTTP POST /upload
• REST endpoints for theme, note, attachments
C. External Service
• .sx Cloud (or self-hosted)
• Ingress API layer
• Storage (S3 or database)
• CDN for assets
• (Optional) Database for metadata
D. User’s Browser/Recipient
• Renders shared note via encrypted link + key
Relationships & Data Flows
• Vault → Plugin (reads .md, assets, CSS)
• Plugin pipeline:
UI → Core modules (template → encrypt? → compress) → API Client
• API Client → note.sx REST API → returns id & (if encrypted) no-content partial response
• Plugin → UI (copy share URL + key fragment)
• Recipient’s Browser → CDN/API (fetch encrypted payload + decrypt with key from URL)
Architectural Patterns & Design Principles
• Modular client architecture (separate UI, business logic, transport)
• Single Responsibility: each TS file has one concern
• Lazy theme upload (cache first, incremental updates)
• Pluggable encryption strategy (on/off via settings)