Manual setup and deployment

Put Sufra on your own server with HTTPS, and keep it running.

On a Linux server (PM2 + Nginx)

  1. Install Node.js 22+ and copy the project to the server (for example /var/www/sufra).

  2. Create .env as in Installation, and set the public address:

    SITE_URL="https://order.your-restaurant.com"
    

    SITE_URL must be the exact HTTPS address customers use: Thawani sends paying customers back to it, and the session cookie is marked secure when it starts with https://.

  3. Build and create the database:

    npm ci
    npm run setup
    npm run build
    
  4. Keep it running with PM2:

    npm install -g pm2
    pm2 start npm --name sufra -- start
    pm2 save && pm2 startup
    

    The app listens on port 3301 (npm start). To use another port, change -p 3301 in the start script of package.json.

  5. Put Nginx in front for HTTPS:

    server {
      server_name order.your-restaurant.com;
      client_max_body_size 5m;               # dish photo uploads (4 MB max)
      location / {
        proxy_pass http://127.0.0.1:3301;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
      }
    }
    

    Then get a certificate (for example certbot --nginx). X-Forwarded-For matters: the request limits (orders, sign-in) count per visitor IP.

Updating

git pull            # or copy the new files
npm ci
npx prisma db push  # applies new tables or columns, keeps your data
npm run build
pm2 restart sufra

Backups

With SQLite, the whole restaurant is the file prisma/sufra.db plus your uploaded photos in public/uploads. Back up both, for example every night:

sqlite3 prisma/sufra.db ".backup /backups/sufra-$(date +%F).db"
tar czf /backups/uploads-$(date +%F).tgz public/uploads

Moving to PostgreSQL

SQLite is fine for one restaurant. For several server instances or a managed database:

  1. In prisma/schema.prisma change provider = "sqlite" to provider = "postgresql".
  2. Set DATABASE_URL="postgresql://user:password@host:5432/sufra".
  3. Run npm run setup.

Nothing else changes. With more than one instance, also move uploads to shared storage and replace the in-memory request limiter in src/lib/api.ts with a shared store (see Troubleshooting).

Hosting platforms

Any host that runs a Node.js server works. On platforms with a read-only or temporary disk (many serverless hosts), SQLite and public/uploads do not persist: use PostgreSQL and change the upload route src/app/api/dashboard/upload/route.ts to save to object storage (S3, R2, ...).