# Letter Studio

A browser studio for the clinic’s patient-letter email: edit the copy, the medication rows and the colours with a live right-to-left preview at desktop and phone widths, then copy the letter JSON into the visit or the design tokens back into the React Email source. It also lays out the four delivery rules the letter must pass — one HTML part, a hosted logo, RTL on every block, and SPF/DKIM/DMARC — with a walkthrough of the pipeline from the studio to the inbox.

**Status:** Live · Projects · 2026

- **Local checkout:** `/Users/simon/Developer/letter-studio` (branch `main`, last commit 607fdfd, 2026-10-24 — audit: fall back to GET when the branding route refuses HEAD)
- **Repository:** https://github.com/ShimonNavon/letter-studio
- **On another machine:** `git clone https://github.com/ShimonNavon/letter-studio` — the paths below are Simon's Mac
- **Live:** https://letter-studio.navonsimon.com/

## Stack

Single-file HTML + one shared ES module, Node (CLI, MCP, tests), nginx-unprivileged, Kubernetes

## Start here

- `site/index.html` — the studio UI: editor, live preview, exports, explainer
- `site/lib/letter.mjs` — shared core: design tokens, renderEmail(), patient_letter/token/curl exports, lint
- `bin/letter-studio.mjs` — CLI: render, json, tokens, curl, check
- `mcp/server.mjs` — MCP server over stdio: render_letter, letter_json, design_tokens, check_letter
- `tests/smoke.mjs` — core, CLI and a real MCP handshake
- `deploy/k8s.yaml` — namespace letter-studio, nginx deployment, ConfigMaps (site/lib/conf), NodePort 30102
- `deploy/deploy.sh` — ships index.html, letter.mjs and nginx.conf as ConfigMaps over ssh to ubuntu03

## Commands

- **Run locally:** `python3 -m http.server 8099 --directory site`
- **Render the letter:** `node bin/letter-studio.mjs render --out letter.html`
- **Check a letter:** `node bin/letter-studio.mjs check --letter letter.json`
- **Audit (sizes, subject, live logo):** `node bin/letter-studio.mjs audit --json`
- **Read a visit into a state file:** `node bin/letter-studio.mjs pull --out state.json`
- **Stage a review send:** `node bin/letter-studio.mjs apply --dry-run`
- **Send for review (allowlist):** `node bin/letter-studio.mjs send --to you@gmail.com --dry-run`
- **Run the MCP server:** `node mcp/server.mjs`
- **Tests:** `npm test`
- **Deploy:** `./deploy/deploy.sh`

## Deploy and where it runs

- Deployment web in namespace letter-studio, nginx-unprivileged:1.27-alpine, ConfigMaps letter-studio-site (index.html) and letter-studio-conf (default.conf, no-store), NodePort 30102; public at https://letter-studio.navonsimon.com/ via Cloudflare Tunnel -> edge nginx on ubuntu01 (/srv/edge/nginx/conf.d/letter-studio.conf) and a tunnel ingress rule for the hostname.

## Current state

Live at https://letter-studio.navonsimon.com/. Fifteen CLI commands (render, json, tokens, subject, plaintext, eml, diff, check, audit, pull, apply, send, curl, new, preview) and nine read-only MCP tools run on the same shared core as the browser studio. send/apply talk to the app's API; nothing in the studio holds SMTP credentials.

## Tags

Email design, React Email, RTL, Kubernetes

---

Brief generated 2026-11-08 from `~/Developer/my-projects/context/`. Canonical URL: https://projects.navonsimon.com/context/letter-studio.md
