How loveholidays/excalidraw-decrypt works
Project Type and Purpose
• This is primarily a CLI application (cmd/excalidraw-decrypt) with a reusable Go library (pkg/excalidrawdecrypt) that:
• Decrypts it using a key supplied in the shareable link
File Structure
• Top‐level artifacts:
• cmd/excalidraw-decrypt – the CLI’s main() entrypoint
• pkg/excalidrawdecrypt – core library broken into subpackages:
– fetch: HTTP client for Excalidraw API
– crypto: decryption routines
– buffers: in-memory data buffering and I/O helpers
• Config & CI: Dockerfile, Makefile, GitHub workflows, goreleaser
• Tests and mocks under pkg/excalidrawdecrypt confirm clear separation of concerns.
README Insights
• Architecture is layered:
• Presentation: CLI
• Application logic: Library interfaces (CreateShareableExcalidrawDecrypter(), Decrypt())
• Infrastructure: HTTP fetch + crypto algorithms
• External dependency: public Excalidraw API (https://json.excalidraw.com/api/v2/documentID)
Main Components
a. User / CLI (cmd/excalidraw-decrypt)
b. Library API (pkg/excalidrawdecrypt)
– Fetch module (HTTP client)
– Crypto module (decryption)
– Buffers module (I/O helpers)
c. External Service: Excalidraw Public API
d. Output: stdout or file
Relationships and Data Flows
• User invokes CLI → CLI parses args → calls Library.Decrypt()
• Library.Fetch retrieves encrypted payload from Excalidraw API
• Library.Crypto decrypts payload using key from args
• Library.Buffers formats plaintext JSON
• CLI writes output to stdout or file
Highlighted Architectural Patterns
• Layered architecture (presentation → application → infrastructure)
• Separation of concerns: each pkg subdirectory focuses on one responsibility
• Dependency injection (in tests via mocks/fetch)
Relevant Technologies & Frameworks
• Go modules (go.mod)
• HTTP client (net/http)
• AES/GCM decryption (crypto/cipher)
• JSON unmarshalling (encoding/json)
• Cobra/flag (CLI parsing, if used)
• Testing/mocks (Go testing, autogenerated mocks)
• Clear, consistent component labels (e.g., “pkg/excalidrawdecrypt/crypto”)
• Annotations for protocols (HTTPS) and data formats (JSON)
• Optional: CI/CD pipeline overview (GitHub Actions → Docker/Goreleaser)