← Projects

Betolla CosmeticsHow I run it

Betolla Cosmetics is a cosmetics store with admin, staff and delivery dashboards. This page covers what runs where, how updates ship, and how the data is backed up.

Every detail on this page was checked against the live server on 14 Oct 2026.

The setup

Betolla Cosmetics production architecture Visitors reach Cloudflare over HTTPS. Cloudflare forwards to one VPS running Nginx, which splits traffic between two Next.js processes managed by systemd and PM2. The processes share a Redis cache and reach PostgreSQL 18 through PgBouncer. A nightly job backs up the database and the uploaded images. Visitors HTTPS Cloudflare TLS · CDN One VPS · Ubuntu 26.04 Nginx TLS · gzip · splits traffic across both processes systemd + PM2 Next.js #1 store + dashboards Next.js #2 store + dashboards Redis shared cache PgBouncer connection pool PostgreSQL 18 reachable from this server only Nightly backup database + uploads checked after each run Auto-restart systemd + PM2 starts on boot
How a request reaches the database. Dashed boxes are the jobs that keep it safe.
  • One VPS running Ubuntu 26.04 hosts the whole store.
  • Cloudflare sits in front and handles TLS for visitors.
  • Nginx compresses responses and splits traffic between two Next.js processes. If one process crashes, Nginx keeps sending visitors to the other while it restarts.
  • Next.js serves the store and the admin, staff and delivery dashboards. It runs as two PM2 processes inside a systemd service, so it restarts on a crash and starts again when the server boots.
  • Redis holds a shared cache, so both processes serve the same data.
  • PostgreSQL 18 sits behind PgBouncer, which pools database connections. Both listen on the server itself only, never on the public internet.
  • The firewall only allows SSH and web traffic, and fail2ban blocks repeated failed SSH logins.

How updates are deployed

Every deploy follows the same checklist:

  1. Back up first. A fresh copy of the database and the uploaded images is taken before anything changes.
  2. Package the code. The package deliberately leaves out the server's secrets and customers' uploaded images, so a deploy can never overwrite them.
  3. Install, migrate, build, restart. Exact dependency versions are installed, database migrations are applied with prisma migrate deploy, the app is built, and the service restarts.
  4. Verify. The service must be running, the number of users, orders and products must match what it was before, and the main pages (home, products, register, login and the health check) must load.

Database changes are kept additive (new tables, nullable columns, indexes), so accounts, passwords and orders are never touched by a schema change. Rolling back means restoring the previous code package and, if needed, the database copy taken in step 1.

How backups work

  • Every night a scheduled job dumps the database and archives all uploaded images.
  • Each database dump is read back right after it's written. If it can't be read, the job stops with an error.
  • Daily copies are kept for 30 days, and the first copy of each month is kept for a year.
  • On top of the nightly copy, a backup is taken right before every deploy.