The Stack You Can't
Build on Vercel
I spent this year building a SaaS product for medical clinics, which meant learning that most of my default stack was not legally available to me. Not because it is insecure, but because handling patient data requires a signature, and a lot of vendors will not give you one. This is what I moved to, what it cost, the mistakes I made, and the four places patient data still leaks out after the database is locked correctly.
The fast way: don't read this, feed it to your AI
The check file is written for Claude Code, not for you. Download it, open your project, paste it in. It maps where your regulated data actually goes, names the vendors receiving it, flags the ones that cannot sign, and ends with a short list of questions to send your lawyer. It is read only and changes nothing until you say so.
The day the normal stack stopped working
I build software for medical clinics. Staff log in, pull up a patient, read lab results, write notes, send a message, take a payment. Ordinary software, except every screen has someone's medical history on it.
I started the way I start everything: Next.js on Vercel, hosted Supabase, ship it. That worked right up until the first real conversation about going live, when the question changed from how fast can you deploy to who is signing for this.
Under HIPAA, anyone who stores or processes health data on your behalf has to sign a Business Associate Agreement. It is a contract where they accept legal responsibility for protecting it. No signature, no legal path to put a single real patient record on their servers. It does not matter how good their security is. It matters whether they signed.
A signature is a business decision, not a security one. Plenty of vendors have decided not to make it, and that invalidated most of my defaults in an afternoon.
Leaving Vercel, and the exception worth knowing
AWSVercel is the piece people are most surprised about, so let me be precise, because I nearly did a migration I did not need.
If your frontend is a static bundle and the browser talks straight to your database, the host is only serving JavaScript. It never sees a record. In that setup the host may not need to sign anything at all, and you can stay where you are.
My problem was that I did not want to be one refactor away from breaking that. The moment anything renders server side, or an API route touches a patient row, or a log line captures a request body, the host is holding health data and the whole argument collapses. I did not want my compliance posture to depend on nobody ever adding a server component.
So I moved the whole thing onto AWS, which does sign a BAA, and covers the machine, the object storage, and the email and SMS sending. One signature for the layer that actually holds the data.
What it cost~$75/moup from roughly nothing, plus the deploy button
Coolify gave me the deploy button back
Coolify"Self hosted" sounds like hand editing nginx configs at two in the morning. It was the part I dreaded and the part that turned out to be easiest.
Coolify is an open source platform you run on your own server. It gives you back most of what you gave up: a dashboard, one click services, containers, automatic TLS certificates, environment variables in a UI, a deploy that is still one command. It is the Heroku experience on hardware you control.
The same is true of the database. Supabase publishes an open source build, so I run Supabase OSS as a stack of containers on that same box. Same Postgres, same auth, same storage, same client library. My application code did not change. The connection string changed and nothing else did.
What I actually took on is smaller than the fear and larger than zero. I own the operating system, the security updates, the backups, and the pager. The work is not harder than what I was doing before. It is just mine now.
One database, many clinics, and the rule that is off by default
SupabaseThis is software several clinics use, and they all share one database. The only thing standing between one clinic and another clinic's patients is a row level security policy: a rule on each table that says who is allowed to see which rows.
Those rules are off by default on any table created with raw SQL, which is how AI assistants create tables. And a policy that exists is not the same as a policy that works. When data stops loading, the fastest fix an assistant reaches for is the one that allows everybody:
create policy "Enable read access" on patients for select using (true); -- everyone. every clinic. logged out.
Now a policy exists, so a checklist would say the table is protected. It just says yes to the entire internet. A policy that is doing real work names the person asking, and in multi tenant software it names their organization too:
using (clinic_id = current_clinic_id())
If the policy does not mention who is asking, it is decoration. Writing these, and then testing them by actually logging in as two different tenants, was the single largest block of work in the whole build.
Nobody warns you that the BAA is a chain
I assumed compliance meant one agreement. It is a chain, and working out who sits where in it took longer than any code I wrote that month.
The clinic is the covered entity, because it holds the relationship with the patient. I am their business associate, so there is an agreement between us. After that, every vendor sorts by one question: whose account does it run in?
That last row is the one that catches people. I cannot sign on a clinic's behalf for a tool running under their own login. My job is telling them which agreements they need before they onboard, not quietly absorbing the risk.
Two things I got wrong and would tell anyone starting: ask every vendor in writing, and get the answer in writing. Terms differ by plan tier and they change. And write the chain down early, because the day a clinic's lawyer asks who holds what, a clear one page answer is the difference between a short call and a stalled deal.
The four leaks that are not in your database
PostHogHere is the part I did not plan for. You can lock the database perfectly and still send patient data to vendors who never agreed to hold it, through code that is working exactly as written.
- Session replayIt records the screen, and on a logged in page the screen is the patient chart. Mask by default and build an allowlist. A blocklist only covers the fields you remembered.
- Error trackingThese tools capture request bodies and local variables, because that is what makes a stack trace worth reading. If nobody wrote a scrubbing config, it is sending all of it right now.
- AlertsA message reading "new patient: Jane Doe" has moved a real name into a chat vendor, and the free tier of most chat tools carries no agreement at all. Post an ID and a link instead.
- BackupsA nightly dump is still the data. It carries every obligation the live database has: where it may sit, who can reach it, how long you keep it, whether it is encrypted.
I run PostHog self hosted for exactly this reason. Watching how staff actually use the software is worth a lot, and none of those recordings leave infrastructure I control.
You do not have a backup until you have restored one
Nightly backups are the easiest box to tick and the easiest thing to be wrong about. The job runs, a file lands in storage, the size looks about right, everyone moves on.
Restoring is where you find out. When I actually did it, into a scratch database, I learned that parts of the dump needed a privileged role I never use day to day, and that a couple of internal schemas error out unless you restore into a fresh stack. Good news, but only because I found it on a calm Tuesday instead of during an outage.
Do the restore. Count the tables. Log in as a real user and click around. Write down the date, because that date is the actual evidence, and do it again after any material change.
My own documentation was the biggest risk
ObsidianThis is the one I did not see coming, and it is why the file at the top exists.
I went into my repository looking for something unrelated and found that every status document described a deployment that never happened. They named a different hosting provider, from a plan I had abandoned months earlier. One file stated flatly that nothing was running on the infrastructure that everything was, by then, running on.
Two of those files load automatically into my AI assistant at the start of every session. So every assistant I opened began work believing production did not exist. An agent reasoning correctly from that premise will do something destructive and be completely confident about it, and that is my fault, not the model's.
The compliance documents were worse, and this is the part that would have actually hurt. My incident response runbook, the page you open on the worst day of the year, gave instructions for a provider I do not use. My security policy told any clinic that read it that their patient data sat in a data center it does not sit in. That is not a typo. That is the wrong company named for the physical safeguards on protected health information.
So: re run the check after every infrastructure change. The expensive version of this is not a stack that was wrong on day one. It is a stack that was right on day one, changed in month four, and kept the day one documentation.
Find out where your data actually goes.
Grab the file and let Claude Code map it. It is engineering triage, not legal advice, but it gets you a real list instead of a guess, and the last section is written to be forwarded straight to a lawyer.