K
Zansify
Deployment

Production Deployment

Deploy the Kasify API and database to a VPS with Docker, and the dashboard and storefront to Vercel.

Architecture

The recommended production setup splits responsibilities across two hosting providers:

| Service | Where | Why | |---|---|---| | API + PostgreSQL | VPS (Docker) | Needs persistent storage and a long-running process | | Dashboard | Vercel | Free tier, zero-config Next.js deploys | | Storefront | Vercel | Same — fast global CDN, free SSL | | Marketing website | Vercel | Same |

A €4/month Hetzner VPS or $6/month DigitalOcean droplet is plenty for the API and database to start.


Part 1 — Deploy the API to a VPS

1. Get a server

Sign up for Hetzner, DigitalOcean, or any Linux VPS provider. Choose:

  • OS: Ubuntu 22.04
  • RAM: 2 GB minimum (4 GB recommended)
  • Disk: 20 GB SSD

2. Install Docker

SSH into your server and run:

curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER
newgrp docker

Verify:

docker --version
docker compose version

3. Clone the repo onto your server

git clone https://github.com/your-org/kasify.git
cd kasify

4. Set up environment variables

cp .env.production .env
nano .env

Fill in every value. The critical ones:

# Generate with: openssl rand -base64 48
JWT_SECRET=your_long_random_secret_here
JWT_REFRESH_SECRET=different_long_random_secret_here

# Your actual domain names
ALLOWED_ORIGINS=https://app.yourdomain.com,https://yourdomain.com
NEXT_PUBLIC_API_URL=https://api.yourdomain.com
NEXT_PUBLIC_DASHBOARD_URL=https://app.yourdomain.com
NEXT_PUBLIC_STOREFRONT_URL=https://yourdomain.com

# A strong Postgres password
POSTGRES_PASSWORD=very_strong_db_password
DATABASE_URL=postgresql://kasify:very_strong_db_password@postgres:5432/kasify

5. Start the stack

docker compose -f docker-compose.prod.yml --env-file .env up -d

This will:

  1. Start PostgreSQL
  2. Run database migrations automatically
  3. Build and start the API server

Check it's running:

docker compose -f docker-compose.prod.yml ps
curl http://localhost:3001/health
# → {"status":"ok","timestamp":"..."}

6. Set up Nginx + SSL

Install Nginx and Certbot:

sudo apt install nginx certbot python3-certbot-nginx -y

Create an Nginx config for the API:

sudo nano /etc/nginx/sites-available/kasify-api
server {
    server_name api.yourdomain.com;

    location / {
        proxy_pass http://localhost:3001;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_cache_bypass $http_upgrade;
    }
}

Enable it and get SSL:

sudo ln -s /etc/nginx/sites-available/kasify-api /etc/nginx/sites-enabled/
sudo certbot --nginx -d api.yourdomain.com
sudo systemctl reload nginx

Verify: curl https://api.yourdomain.com/health


Part 2 — Deploy Dashboard to Vercel

1. Push your repo to GitHub

git remote add origin https://github.com/your-org/kasify.git
git push -u origin main

2. Create a new Vercel project

  1. Go to vercel.comAdd New Project
  2. Import your GitHub repository
  3. Under Root Directory → set to apps/dashboard
  4. Vercel will detect the vercel.json automatically

3. Add environment variables

In the Vercel project settings → Environment Variables, add:

| Variable | Value | |---|---| | NEXT_PUBLIC_API_URL | https://api.yourdomain.com | | NEXT_PUBLIC_DASHBOARD_URL | https://app.yourdomain.com | | NEXT_PUBLIC_STOREFRONT_URL | https://yourdomain.com |

4. Add your custom domain

In Vercel → Domains → add app.yourdomain.com. Point your DNS CNAME to Vercel's address. SSL is automatic.

5. Deploy

Click Deploy. Every git push to main will auto-deploy from now on.


Part 3 — Deploy Storefront to Vercel

Repeat the same steps as the Dashboard, but:

  • Root Directoryapps/storefront
  • Domainyourdomain.com (your store root)
  • Environment Variables → only NEXT_PUBLIC_API_URL and NEXT_PUBLIC_STOREFRONT_URL needed

Part 4 — Deploy Marketing Website to Vercel

  • Root Directory → the main-website repo (separate repo)
  • Domainkasify.com (or your marketing domain)
  • Environment VariableNEXT_PUBLIC_DASHBOARD_URL=https://app.yourdomain.com

Updating Kasify

When you push new code:

API (on your VPS):

git pull origin main
docker compose -f docker-compose.prod.yml --env-file .env up -d --build

Dashboard + Storefront: automatic — Vercel redeploys on every push to main.


Monitoring & logs

# All services
docker compose -f docker-compose.prod.yml logs -f

# Just the API
docker compose -f docker-compose.prod.yml logs -f api

# Database
docker compose -f docker-compose.prod.yml logs -f postgres

Backups

Back up your Postgres database daily:

# Add to crontab: crontab -e
0 2 * * * docker exec kasify-postgres pg_dump -U kasify kasify | gzip > /backups/kasify-$(date +\%Y\%m\%d).sql.gz

Keep at least 7 days of backups.