ExcelRewind — Architecture Documentation

Monorepo C:\Users\TM\Documents\claude proj\fable pqrs · 12 modules, per-module deep dives plus a whole-system view

ExcelRewind is a spreadsheet decision-intelligence platform: it captures why numbers change in Excel or Google Sheets — not just what changed — and packages that reasoning into a shareable, replayable .rewind companion file that never modifies the original spreadsheet. The system has no application/API server: two Office/Sheets clients (an Office.js task pane and a Google Apps Script sidebar) record cell-change events and write .rewind files directly via the shared packages/format contract; two optional native desktop “Companion” helpers (Windows/Mac) give the Excel add-in COM/AppleScript access Office.js can't reach on its own; five static Cloudflare Pages sites (add-in, viewer, admin, team, website) talk straight to Supabase Postgres (RLS + SECURITY DEFINER RPCs) and 8 Deno Edge Functions for everything privileged (billing webhooks, the superadmin console, exam-file signing, domain verification, invite email); and encryption is zero-knowledge end to end — key material never leaves the browser/pane in usable form. Start with system.html for the cross-cutting diagrams (full architecture, .rewind lifecycle, auth/licensing, billing, deployment, trust boundaries), then drill into any module below for its own diagrams, key-function tables, and documented invariants/gotchas.

How these docs are built — read me before editing

Whole-system view

Module documentation

format.html — Format & Branding

packages/format · packages/branding · scripts/rewind_writer.py

The .rewind contract itself: types, the ZIP-of-deflated-MessagePack container codec, the zero-knowledge AES-256-GCM encryption envelope, and pure spreadsheet-replay/branch/spotlight utilities every app imports.

addin-excel.html — Excel Add-in

apps/addin-excel

The Office.js task pane: records cell changes, encrypts and saves .rewind files, replays sessions on disposable in-workbook temp sheets, and talks to Supabase, Stripe, and the desktop Companions.

viewer.html — Web Viewer

apps/viewer

Zero-backend, zero-install React SPA that opens and replays a .rewind file entirely client-side; also hosts the Excel add-in's Google/Apple OAuth system-browser handoff page.

admin.html — Superadmin Console

apps/admin

Owner-only console for tiers, feature entitlements, users, coupons, pricing, cohorts, the maintenance kill switch, and a guarded destructive data reset — the sole write path via the admin-ops Edge Function.

team.html — Team / Account Console

apps/team

Personal Account screen + org-manager Team console: members, invites, domain verification, cohort seat licensing, exam/kiosk proctoring, and client-side org encryption-key management.

website.html — Marketing Site

apps/website

Public marketing site; distributes the Windows installer download and reads public tier/promo config from Supabase with the anon key.

addon-sheets.html — Google Sheets Add-on

apps/addon-sheets

A read-only Apps Script server (no triggers) plus a React sidebar that poll-diffs the active sheet every ~2s to produce the same cross-platform .rewind the Excel add-in writes.

companion-win.html — Windows Companion

apps/companion-win

Optional native Python tray helper giving the Excel add-in COM access via a loopback-only HTTP API: cross-workbook recording, opening references, and driving Provenance Spotlight.

companion-mac.html — Mac Companion

apps/companion-mac

Wire-compatible Mac counterpart to the Windows Companion, driving Excel for Mac via AppleScript over a self-signed-TLS loopback HTTPS server (required by WKWebView's mixed-content policy).

backend-data.html — Database & Schema

supabase/schema.sql + migrations

The Postgres schema (RLS + SECURITY DEFINER RPCs) that is ExcelRewind's entire data layer — auth, tiers/feature cascade, orgs/cohorts/exams, zero-knowledge key storage, and the 21-file transactional test suite.

backend-services.html — Edge Functions & Auth

supabase/functions/* · auth.ts

The 8 Deno Edge Functions (admin-ops, billing webhooks, exam-storage, verify-domain, send-invite, metrics, uninstall-feedback) plus the OTP/OAuth-handoff auth story — everything privileged that Postgres alone can't do.

installer-deploy.html — Installers & Deploy Pipeline

apps/installer · scripts/make-manifest.mts · scripts/smoke.mts

The Windows NSIS installer (add-in sideload + Companion), the Mac .pkg, and the root npm run deploy pipeline that builds and ships every app to Cloudflare Pages and smoke-tests the live origins.

This index and system.html are generated documentation, not source code — they describe the repository as of the last documentation pass. Cross-check any specific claim against the linked source file paths before repeating it externally (e.g. to an auditor or a partner).