Skip to main content

Render Cloud Deployment & Environment Guide

This guide provides a comprehensive, step-by-step walkthrough for deploying the Retail POS Backendto Render.com with PostgreSQL database integration, cloud backup sync, and full multi-tenant SaaS capability.

[!TIP] Deploying the Web UI? To test and host the Flutter Web interfacealongside the backend, see the Web Deployment Guide.


Prerequisites​

  1. A Render.com account.
  2. A PostgreSQL database on Render (or external provider like Neon, Supabase, AWS RDS).
  3. Git repository pushed to GitHub or GitLab.

Step 1: Deploy PostgreSQL Database on Render​

  1. Log into your Render Dashboard.
  2. Click New +→ PostgreSQL.
  3. Fill in the details:
    • Name:retail-pos-db
    • Database:retailpos
    • User:retailadmin
    • **Region:**Choose nearest region (e.g., Singapore / Frankfurt / Oregon)
  4. Click Create Database.
  5. Once created, copy the Internal Database URL (or External Database URLif connecting from outside Render).

Step 2: Deploy Web Service on Render​

  1. In Render Dashboard, click New +→ Web Service.
  2. Connect your GitHub repository (RetailSale).
  3. Fill in the deployment configuration:
SettingValue
Nameretail-sale-backend
LanguageNode
RegionSame region as your database
Branchmain
Root Directorybackend (or leave blank if using Docker)
Build Commandnpm install
Start Commandnpm start

Step 3: Comprehensive Environment Variables Reference​

In your Web Service, go to the Environmenttab and add the following key-value pairs:

1. Database & Core Server (Required)​

VariableExample ValueDescription
NODE_ENVproductionEnables production mode and triggers cloud safety protocols
PORT10000Port for Express API server (Render sets automatically)
DATABASE_URLpostgresql://user:pass@dpg-xyz.render.com/retailpos?ssl=truePostgreSQL Connection URI (Enables Cloud SaaS multi-tenant mode)
DB_SSLtrueEnables SSL encryption required by Cloud PostgreSQL instances
JWT_SECRETsuper-secret-jwt-key-2026-prodSecret key used to sign and verify user JWT authentication tokens
IS_CLOUDtrueExplicitly declares cloud deployment environment

VariableExample ValueDescription
REDIS_URLrediss://default:password@redis-cloud-host:6379Redis / Upstash / Redis Enterprise URI for distributed caching, session storage & rate limiting
REDIS_HOSTredis-cloud-hostRedis host name (fallback if REDIS_URL is omitted)

3. Cloud Object Storage / S3 / Cloudflare R2 (For Backups & Large Files >50MB)​

VariableExample ValueDescription
S3_BUCKET (or R2_BUCKET)retail-pos-backupsCloud object storage bucket name for direct database backup archives
S3_ENDPOINT (or R2_ENDPOINT)https://<account_id>.r2.cloudflarestorage.comCustom S3/R2/MinIO endpoint URL (bypasses Google Apps Script payload limits)
S3_REGION (or AWS_REGION)auto / us-east-1 / ap-south-1S3 or Cloudflare R2 bucket region
S3_ACCESS_KEY_IDAKIAIOSFODNN7EXAMPLES3 / Cloudflare R2 / MinIO Access Key ID
S3_SECRET_ACCESS_KEYwJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEYS3 / Cloudflare R2 / MinIO Secret Access Key

4. Security & Field-Level Token Encryption​

VariableExample ValueDescription
ENCRYPTION_SECRETaes-256-gcm-secret-key-32-chars!Custom AES-256-GCM secret key for field-level encryption (WhatsApp tokens, store credentials)
BACKUP_SECRETenterprise-backup-encryption-key-123Passphrase used to encrypt automated database backup zip archives

5. SMTP Email Service & OTP Delivery (Primary & Add-On)​

[!IMPORTANT] Render Web Services block outbound TCP port 587 (ETIMEDOUT). For Zoho Mail or custom SMTP on Render, set **EMAIL_PORT=465**and EMAIL_SECURITY=SSL (or use **RESEND_API_KEY**over HTTPS port 443).

VariableExample ValueDescription
EMAIL_PROVIDERRESENDExplicit mode: RESEND (Resend API), GMAIL (Gmail OAuth2), SMTP (SMTP only), or AUTO
RESEND_API_KEYre_123456789abcdefHTTPS Resend API key for 0.1s instant OTP emails over Port 443
EMAIL_FROM"Retail POS" <help@famalth.com>Custom verified sender header name & email address
GMAIL_CLIENT_ID123456-xyz.apps.googleusercontent.comGoogle Cloud OAuth2 Client ID (See Gmail OAuth2 Guide)
GMAIL_CLIENT_SECRETGOCSPX-your_client_secretGoogle Cloud OAuth2 Client Secret
GMAIL_REFRESH_TOKEN1//04_your_oauth_refresh_tokenGoogle OAuth2 Refresh Token (from OAuth Playground)
EMAIL_USERhelp@famalth.comPrimary Sender Email Address (used for SMTP and Gmail OAuth2)
EMAIL_PASSabcd1234efghApp Password generated in Zoho Mail or Gmail Security (for password auth)
EMAIL_HOSTsmtp.zoho.inSMTP Server Host (smtp.zoho.in / smtp.gmail.com)
EMAIL_PORT587SMTP Port (587 for STARTTLS, 465 for SSL)
EMAIL_SECURITYSTARTTLSSecurity Protocol: STARTTLS (587), SSL (465), or NONE (25)
EMAIL_SECUREfalseSet false for Port 587 STARTTLS, true for Port 465 SSL
EMAIL_TIMEOUT20000SMTP Connection timeout in milliseconds (Default: 20000)

6. Google Drive Cloud Backups & Sheet Sync (Add-On)​

VariableExample ValueDescription
ROOT_FOLDER_ID1A2B3C4D5E6F7G8H9IGoogle Drive Root Folder ID for storing automated .enc database backups
SCRIPT_URLhttps://script.google.com/macros/s/execGoogle Apps Script Sync Endpoint URL for cloud synchronization
SHEET_ID1XYZ2ABC3DEF4GHI5JKLGoogle Sheets Database Spreadsheet ID for real-time audit logging

Cloud Mode Features & Automatic Adaptations​

When DATABASE_URL or DB_HOST is set, the backend automatically adapts:

  1. **Automatic Cloud Sync (Cloud Sync: ON):**Database backups default to **ON**for cloud deployments to protect data against ephemeral container restarts.
  2. **Bypasses Disk .enc Files:**Local config.enc disk existence checks are automatically bypassed in cloud mode while preserving local offline mode for Windows desktop terminals.
  3. **Resilient Migrations:**Automatically runs database schema migrations and seed scripts on boot with automatic PostgreSQL transaction ROLLBACK error recovery.
  4. **IPv4 DNS Lookup:**Uses forced resolve4 lookup (family: 4) for Nodemailer to prevent container IPv6 ENETUNREACH socket errors.
  5. **Live OTP Console Logging:**Outputs generated OTP codes directly to Render Live Logs ( [OTP GENERATED] Target: email | Code: 123456).

Step 4: Connecting the Flutter Client​

  1. Launch your Flutter client app.
  2. On the Terminal Setup Screen:
    • Server URL:https://retail-sale-backend.onrender.com
    • **Outlet Code (Optional):**Enter your private outlet code (e.g. OUTLET202608301109), or leave blank to register a new store.
  3. Click Verify & Connect Outlet (or Save & Register New Store).