How arelius-d/lucid works
Purpose and entry points
LucID is a self-hosted encrypted Markdown notes application. The browser owns encryption, editing, rendering, search, import/export, and session state; the server only serves assets and persists an opaque vault blob. Primary runtime entry points are server.js for Node/Express and public/index.html → public/app.js for the browser application.
Browser application and vault boundary
public/app.js is the main client controller: it initializes the lock/onboarding flow, derives a non-extractable Web Crypto key from the passphrase, encrypts/decrypts vault fields, and coordinates UI state and API synchronization. The server must never receive the passphrase or plaintext note data. UI markup and styles are centralized in public/index.html and public/styles.css.
Note authoring pipeline
After unlock, decrypted notes, folders, tags, pin state, and trash state are managed in browser memory. Markdown editing feeds a rendered preview; rendered HTML is sanitized before DOM insertion. Search operates over decrypted titles, tags, and bodies locally. Imports parse supported document formats in-browser and convert them to Markdown before encryption. Locally hosted runtime dependencies are prepared by scripts/vendor.js and served from public/assets/vendored public content.
Persistence API and atomic storage
The Express service in server.js exposes the narrow application API, static-file delivery, health/version behavior, and CORS policy. Its persistence boundary is data/store.json (or DATA_DIR): the client sends an encrypted vault payload, and the backend performs guarded atomic replacement using temporary write, fsync, and rename. It preserves malformed/unparseable vault data rather than overwriting it.
Client/server control flow
1. Browser loads static UI and locally served assets from public/.
2. User passphrase is processed exclusively through browser Web Crypto; PBKDF2-derived AES-GCM keys encrypt vault fields.
3. Browser reads/writes ciphertext through the Express API in server.js.
4. Server atomically reads/writes the opaque store under data/.
5. On reload or another device, ciphertext is fetched and decrypted only after local unlock. Idle lock clears session/key material.
Deployment and network boundary
Dockerfile packages the Node application. docker-compose.yml runs it loopback-bound on port 58243, with Caddyfile configuring Caddy as the sole public ingress on HTTP/HTTPS and TLS certificate manager. The optional DDNS Updater sidecar integrates dynamic-DNS providers such as DuckDNS. This separation keeps the unauthenticated app API off the public interface and requires HTTPS for Web Crypto.
Operations and installation
install.sh is the host bootstrap and teardown entry point: it fetches deployment files, selects stable/dev branch image channels, configures firewall/DDNS inputs, and manages purge behavior. Persistent encrypted application data is bind-mounted through data/; Caddy certificate/config state is managed as Docker volumes. CI publication infrastructure is under .github/workflows/docker-publish.yml.
Main entry points: app.js Client controller · docker-compose.yml Service topology · server.js Express API and static server · Dockerfile Node application image
Components 16
Browser client
All note data handling occurs locally after unlock.
- App shell
public/index.html - UI styles
public/styles.css - Client controller · Coordinates unlock, UI state, and vault synchronization.
public/app.js - Vault cryptography · PBKDF2-derived non-extractable AES-GCM key remains in the browser.
- Authoring and local search · Edits, sanitizes previews, searches decrypted data, and imports to Markdown.
- Runtime dependency build · Prepares locally hosted browser dependencies.
scripts/vendor.js - Local public assets
public/assets
Application service
Persists only opaque encrypted vault data.
- Express API and static server · Serves public content and exposes the narrow vault API, health/version, and CORS policy.
server.js - Guarded atomic store · Uses temporary write, fsync, and rename without replacing malformed vault data.
server.js - Encrypted vault blob · Opaque ciphertext stored at the default data location or DATA_DIR.
Deployment and operations
Public ingress and host lifecycle.
- Node application image
Dockerfile - Service topology · Runs the app loopback-bound on port 58243 with persistent mounts.
docker-compose.yml - Public HTTPS ingress · Sole public ingress and TLS certificate manager.
Caddyfile - DDNS updater · Updates supported dynamic-DNS providers.
- Host installer · Fetches deployment files and configures branch, firewall, DDNS, and purge behavior.
install.sh - Image publishing CI
.github/workflows/docker-publish.yml
Connections 16
- App shell → Client controller: loads
- UI styles → App shell: styles
- Runtime dependency build → Local public assets: prepares
- Local public assets → Client controller: local dependencies
- Client controller → Vault cryptography: derives key and encrypts
- Client controller → Authoring and local search: manages decrypted notes
- Client controller → Express API and static server: reads/writes ciphertext
- Express API and static server → Guarded atomic store: vault API
- Guarded atomic store → Encrypted vault blob: atomic replacement
- Node application image → Express API and static server: packages
- Service topology → Node application image: runs
- Service topology → Encrypted vault blob: bind-mounts data
- Public HTTPS ingress → Service topology: proxies HTTPS to loopback app
- DDNS updater → Public HTTPS ingress: supports public address
- Host installer → Service topology: bootstraps
- Image publishing CI → Node application image: publishes image