Work

Side project · Apr – Jun 2026

Undobase, undo-first editing for live Supabase data

Undobase is a table editor for live Supabase data in which every write can be reversed. Each insert, update and delete is recorded with the row before and after and a note saying why, so a bad edit can be undone, or a whole table rewound to an earlier entry. The hard part is that undo runs against someone else's database, with their secret key, while other people and other systems keep writing to it. I built the Fastify API that holds all of that logic, and the product is live at undobase.io.

Role
Sole engineer on the API
Status
Live at undobase.io · early, in active development
Platforms
Web
Stack
Fastify, TypeScript, Node.js, Supabase, PostgreSQL, PostgREST, Zod, Next.js, Stripe, Sentry, Docker, Vercel
Undobase landing page with the tagline "Undo-first editing for live Supabase data"
HTTP routes in the Fastify API
55HTTP routes in the Fastify API
workspace roles, checked on every project route
4workspace roles, checked on every project route

The idea

Teams fix production rows in the Supabase dashboard, in SQL or with a script, and when a fix is wrong, recovery is manual. Undobase starts from the opposite rule: nothing may change a customer’s data unless it leaves enough behind to change it back.

Five design decisions

Decision Why What it costs
Install nothing in the customer’s database; write over PostgREST with the project’s secret key Connecting takes a minute, and there is nothing to migrate or remove The write and its log entry are two requests; if the log insert fails, that edit cannot be undone
Snapshot the full row before and after every write, with a required change note Undo needs no knowledge of the schema, and history explains itself History grows with every edit
Undo only the newest active change on a table; older ones get a 409 Reversing an older change under a newer one would leave a row nobody ever saw Fixing an old mistake means rewinding through the newer ones
Rewind is undo repeated, newest first, re-checking before each step A teammate’s edit mid-rewind stops it instead of being overwritten It is not a transaction: a rewind that fails halfway stays halfway, and says where
Keep workspaces apart in application code, answering 404 for both “missing” and “not yours” One access check, easy to follow, and ids cannot be probed Every project route has to go through it

The rewind loop, simplified:

const stack = await activeChanges(table); // not undone, newest first
const toUndo = stack.slice(0, indexOf(stack, target) + 1);
if (toUndo.length > 100) throw conflict("Undo in smaller batches");

for (const change of toUndo) {
  if ((await latestActiveChange(table))?.id !== change.id) break; // someone else changed the table
  try { await undoChange(change); } catch { break; }              // stop at the first failure
}

Undone entries are never deleted; they keep an undone_at timestamp and stay in the history. A preview lists every change a rewind would reverse, with diffs, and asks for stronger confirmation past 25.

Where undo stops

Each log entry holds one row, so undo knows nothing about relationships. Undoing an insert fails if other rows now point at it, restoring a deleted row fails if its parent is gone, and if a delete cascaded inside Postgres, the children were never logged, so undo brings back the parent alone.

Keeping the customer’s key safe

  • Only secret keys, tested against the project before they are stored, for project URLs on an allow-list of hosts.
  • Encrypted at rest with AES-256-GCM and a fresh IV each time. No response ever includes the key; it is decrypted only for the request in hand.
  • Webhooks must use HTTPS, private and metadata addresses are refused at registration and again before each delivery, and every body is signed with HMAC-SHA256.
  • Sign-in by email code, or GitHub and Google through PKCE, with the API kept stateless.

What I would change

  • Check the row before undoing. Undo writes the before snapshot back without checking the row still matches the after snapshot, so an edit made outside Undobase is overwritten.
  • Close the gap between write and log. A trigger in the customer’s database would make them one step, at the cost of installing something there.
  • Read primary keys instead of guessing them. Today the API uses an id column when there is one, and a heuristic otherwise.