data-hub

Deployment Guide (Production)

1) PostgreSQL Setup

  1. Create database:
CREATE DATABASE prosperous_data_hub;
  1. Apply schema:
psql -U postgres -d prosperous_data_hub -f database/schema.sql
  1. Ensure DB accepts SSL connections if deploying on managed host.

2) Backend Deployment (Node.js + PM2 + Nginx)

  1. Copy backend env and set values:
cd backend
cp .env.example .env
  1. Install and start:
npm install
pm2 start ecosystem.config.js
pm2 save
pm2 startup
  1. Nginx reverse proxy sample:
server {
    listen 80;
    server_name api.yourdomain.com;

    location / {
        proxy_pass http://127.0.0.1:4000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
  1. Enable HTTPS with Certbot:
sudo certbot --nginx -d api.yourdomain.com
  1. Create a new Web Service in Render and connect this repository.
  2. Set Root Directory to backend.
  3. Set commands:
    • Build Command: npm install
    • Start Command: npm start
  4. Set Health Check Path to /health.
  5. Add required environment variables:
    • DATABASE_URL
    • JWT_SECRET (16+ chars, recommended 32+)
    • PAYMENT_CALLBACK_TOKEN (8+ chars)
    • ADMIN_EMAIL
    • CORS_ORIGIN (your frontend domain, e.g. https://your-frontend.vercel.app)
    • APP_BASE_URL (your backend public URL, e.g. https://your-service.onrender.com)
  6. Optional: deploy using render.yaml at repository root to auto-configure service settings.

Common Render failure causes:

3) Frontend Deployment (Vercel)

  1. Push frontend directory to a Git repository.
  2. In Vercel:
    • Framework: Next.js
    • Root directory: frontend
    • Environment variable:
    • NEXT_PUBLIC_API_URL=https://data-hub-6kwj.onrender.com
  3. Deploy.

Note: the frontend is intentionally kept on the stable Next.js 16.2.x line. It passes build and Playwright validation, but npm audit still reports a moderate upstream PostCSS advisory through Next’s bundled dependency tree. This is an external package-chain issue rather than an application-code defect.

4) Environment Variables

Backend .env required keys:

Going Live for Real Data Delivery

For real customer purchases (not simulation):

  1. Set VTU_PROVIDER=REAL in backend environment.
  2. Set VTU_BASE_URL to your VTU aggregator API base URL.
  3. Set VTU_API_KEY to your live provider API key/token.
  4. Redeploy backend and run a live sandbox purchase test.
  5. Keep wallet refund checks enabled (already built-in) for failed provider responses.

Frontend .env.local:

5) Optional Docker Deployment

From project root:

docker compose up --build

Services:

6) Security Best Practices

Environment Variables

CORS Configuration

Database Security

API Security

Payment Security

Monitoring & Logging

7) Operations Checklist

8) Automated Tests

Backend:

cd backend
npm test

Frontend (Playwright):

cd frontend
npx playwright install
npm run test:e2e