Yavin Songkham
← All workClinic infrastructure · security

Clinic Data Vault

A separate, encrypted site that keeps a versioned copy of everything in the clinic system — and brought it all back when the main database went down.

Designer & developerOct 2026Live (owner only)
Clinic Data Vault
AES-256encryption at rest
everyversion kept in history
2-stepowner login
1full restore done in production
The problem

Clinic data is sensitive and the main app runs on free-tier databases. I wanted a copy that lives on its own, can't be read by the main app, and keeps every past version.

What it does & how it works

Inside Clinic Data Vault

How it works

How it works

  • Database triggers in each branch write changes to an outbox table.
  • After every request (and on a schedule) the main app pushes the outbox to the vault with an HMAC-signed, write-only key.
  • The vault encrypts each record with AES-256 and keeps a history table with every version.
  • Only the owner can open it: password plus authenticator code.

It paid off

  • In late October the shared database hit its compute quota and the whole clinic app went down.
  • I restored every table from the vault into a new database per branch, checked counts table by table, and the app was back the same day.
  • Then I split the system into one database per branch so one branch can't take down the others.
How it is built

Stack

Node.js on Vercel FunctionsPostgres (Neon)HMAC-signed syncAES-256-GCMTOTP 2-step loginDB triggers + outbox
Next projectLocal AI →