Vibe Coding Part 6: The Infrastructure Nobody Warns You About

The Infrastructure Gap
Most vibe coding tutorials end at "and then you deploy." They skip the part where your server crashes at 3 AM, the SSL certificate expires, or the database runs out of disk space.
Here's the infrastructure that keeps SAVAH running — the stuff nobody warns you about.
PM2: Your Process Manager
The Next.js app runs as a PM2 process. Not in a terminal window. Not with npm start in the background. As a proper managed process with:
- Auto-restart on crash — If the app crashes, PM2 restarts it automatically
- Log management — Logs are rotated and stored, not spamming your terminal
- Memory limits — If memory usage exceeds the limit, PM2 restarts the process
- Startup script — PM2 starts on system boot (when configured)
The Quoted Paths Gotcha
Our project lives on an external USB drive. The path contains spaces: /run/media/test2026/B23EB4C53EB483BF/copia portable/nootmarket/
PM2's ecosystem config doesn't handle spaces well. The solution: a wrapper shell script that quotes the paths internally.
The startup script at ~/start-SAVAH.sh handles this correctly. PM2's pm2 save preserves the process list. pm2 resurrect restores it on boot.
Cloudflare Tunnel: No Exposed Ports
We don't expose any ports to the internet. No port 80. No port 443. Cloudflare Tunnel creates an outbound-only connection from our server to Cloudflare's edge.
How it works:
- The cloudflared daemon runs on our server
- It connects outbound to Cloudflare's network
- Traffic to
SAVAH.usroutes through the tunnel - SSL termination happens at Cloudflare's edge
The gotcha: if the tunnel token gets invalidated, the entire site goes down. No error page. No fallback. Just gone. We documented the recovery process in our wiki because it happened to us.
PostgreSQL with Prisma
The database is PostgreSQL with Prisma ORM. The schema has 15+ models:
- User — Authentication, roles (admin, vendor, customer)
- Product — Name, description, price, images, stock, category
- BlogPost — Title, slug, content, featuredImage, SEO metadata
- Order — Items, total, status, shipping
- Review — Product ratings and comments
- AnalyticsEvent — Page views, referrers, device info
Prisma's db push syncs the schema. Migrations are type-safe. Every query is validated at build time. This catches errors before they reach production.
The USB Drive Reality
Yes, our production environment runs from an external USB drive. Not by choice — by necessity. The original project was 50GB (node_modules, build artifacts, images). We trimmed the source to 37MB and moved the full deployment to external storage.
This means:
- File operations are slower than SSD
- The drive must be mounted before PM2 starts
- NTFS permissions can be tricky on Linux
- Backup is critical — we mirror to internal storage
Is it ideal? No. Does it work? Yes. That's vibe coding infrastructure: it doesn't have to be pretty. It has to work.
The Deployment Pipeline
Deploying a change follows this flow:
npm run build— Creates the production build- Copy
.next/staticto.next/standalone/.next/static - Copy
public/to.next/standalone/public/ pm2 restart SAVAH
We're working on automating this. For now, it's manual. The key lesson: automate the boring parts early. We spent weeks doing manual deploys before building the wrapper script.
What We'd Do Differently
- Set up PM2 auto-start from day one. We lost process state twice before configuring
pm2 save. - Use a proper CI/CD pipeline. GitHub Actions for build + deploy would eliminate manual steps.
- Document infrastructure in a wiki. We re-discovered the same Cloudflare Tunnel fix three times before writing it down.
- Monitor disk space. The site filled up the USB drive once. No alerts. Just a crash.
Infrastructure isn't glamorous. It's the plumbing that keeps everything running. Get it right early, and you'll sleep better at night.

