SmartTech Hosting Panel

Complete Knowledge Base & Setup Guide

Version 2.0 · Updated July 2026

Table of Contents

  1. System Requirements
  2. Installation on VPS (Ubuntu/Debian)
  3. Installation on cPanel
  4. Database Setup (PostgreSQL/MySQL)
  5. All Modules & Features
  6. Integration Setup
  7. Payment Gateway Setup
  8. License Management
  9. Server Monitoring
  10. Email Notifications
  11. Backup & Recovery
  12. Troubleshooting

1. System Requirements

Minimum Requirements (up to 500 clients)

ComponentMinimumRecommended
CPU2 vCPU4 vCPU
RAM2 GB4 GB
Storage20 GB SSD50 GB SSD
Bandwidth1 TB/monthUnlimited
OSUbuntu 22.04 LTSUbuntu 24.04 LTS

Production Requirements (1000+ clients)

ComponentSpecification
CPU4+ vCPU
RAM8 GB (16 GB recommended)
Storage100 GB NVMe SSD
DatabasePostgreSQL 15+ (NOT SQLite)
CacheRedis 7+ (recommended)
OSUbuntu 22.04/24.04 LTS or Debian 12

Supported Operating Systems

⚠️ Not recommended: Windows Server (Node.js performance issues), shared hosting without SSH (cannot run Node.js processes), or any OS without root/SSH access.

Software Stack

SoftwareVersionPurpose
Node.js20 LTS or 22 LTSJavaScript runtime
Bun1.1+Package manager & runtime (faster than npm)
PostgreSQL15+ (or MySQL 8+)Database (production)
Redis7+ (optional)Caching & session store
Nginx1.18+Reverse proxy & SSL
PM25+Process manager (keeps app running)
Certbot2+SSL certificates (Let's Encrypt)

2. Installation on VPS (Ubuntu/Debian)

Step 1: Connect to your VPS

ssh root@YOUR_SERVER_IP

Step 2: Update system & install dependencies

# Update system packages
apt update && apt upgrade -y

# Install essential packages
apt install -y curl git nginx ufw

# Install Node.js 20 LTS
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
apt install -y nodejs

# Install Bun (package manager)
curl -fsSL https://bun.sh/install | bash
source ~/.bashrc

# Install PM2 (process manager)
npm install -g pm2

Step 3: Install PostgreSQL

# Install PostgreSQL
apt install -y postgresql postgresql-contrib

# Start and enable PostgreSQL
systemctl enable postgresql
systemctl start postgresql

# Create database and user
su - postgres
psql
CREATE DATABASE smarttech;
CREATE USER smarttech_user WITH ENCRYPTED PASSWORD 'YourStrongPassword123';
GRANT ALL PRIVILEGES ON DATABASE smarttech TO smarttech_user;
ALTER USER smarttech_user WITH SUPERUSER;
\q
exit

Step 4: Upload the application

# Create directory
mkdir -p /var/www/smarttech
cd /var/www/smarttech

# Option A: Upload the zip file from your computer
scp smarttech-hosting-panel.zip root@YOUR_SERVER_IP:/var/www/smarttech/
unzip smarttech-hosting-panel.zip
mv smarttech-package/* .
rm -rf smarttech-package smarttech-hosting-panel.zip

# Option B: Clone from Git (if you have a repo)
git clone https://github.com/yourusername/smarttech-hosting.git .

# Install dependencies
bun install

Step 5: Configure environment

# Copy example env file
cp .env.example .env

# Edit the .env file
nano .env

Update these values in .env:

# Database — PostgreSQL connection
DATABASE_URL="postgresql://smarttech_user:YourStrongPassword123@localhost:5432/smarttech?schema=public"

# Security secrets (generate with: openssl rand -hex 32)
SESSION_SECRET="your-generated-secret-here"
NEXTAUTH_SECRET="your-generated-secret-here"
NEXTAUTH_URL="https://yourdomain.com"

# Email (optional — for notifications)
SMTP_HOST="smtp.gmail.com"
SMTP_PORT="587"
SMTP_USER="your-email@gmail.com"
SMTP_PASS="your-app-password"
FROM_EMAIL="noreply@yourdomain.com"

# Monitoring cron secret
CRON_SECRET="your-cron-secret"

Step 6: Update Prisma schema for PostgreSQL

# Edit the schema
nano prisma/schema.prisma

Change the datasource provider from sqlite to postgresql:

datasource db {
  provider = "postgresql"   // Change from "sqlite"
  url      = env("DATABASE_URL")
}

Step 7: Initialize database

# Push schema to PostgreSQL
bun run db:push

# Run all seed scripts
bun run scripts/seed.ts
bun run scripts/seed-integrations.ts
bun run scripts/seed-settings-payments.ts
bun run scripts/seed-content-monitors.ts
bun run scripts/seed-admin.ts
bun run scripts/seed-licenses.ts
bun run scripts/seed-domain-tlds.ts

Step 8: Build & start the application

# Build for production
bun run build

# Start with PM2
pm2 start "bun run start" --name smarttech

# Save PM2 config (auto-restart on reboot)
pm2 save
pm2 startup
# Follow the instructions PM2 prints

Step 9: Configure Nginx reverse proxy

nano /etc/nginx/sites-available/smarttech

Paste this configuration:

server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com;

    location / {
        proxy_pass http://localhost:3000;
        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_set_header X-Forwarded-Proto $scheme;
        proxy_cache_bypass $http_upgrade;
    }

    location /_next/static/ {
        proxy_pass http://localhost:3000;
        expires 365d;
        add_header Cache-Control "public, immutable";
    }

    client_max_body_size 10M;
}
# Enable the site
ln -s /etc/nginx/sites-available/smarttech /etc/nginx/sites-enabled/
rm -f /etc/nginx/sites-enabled/default

# Test config
nginx -t

# Restart Nginx
systemctl restart nginx

Step 10: Set up SSL (free Let's Encrypt)

# Install Certbot
apt install -y certbot python3-certbot-nginx

# Generate SSL certificate
certbot --nginx -d yourdomain.com -d www.yourdomain.com

# Follow the prompts — it auto-configures Nginx for HTTPS

Step 11: Configure firewall

ufw allow OpenSSH
ufw allow 'Nginx Full'
ufw allow 5432/tcp  # PostgreSQL (only if remote access needed)
ufw enable

Step 12: Set up cron jobs

crontab -e

Add these lines:

# Server monitoring — check every minute
* * * * * curl -s "https://yourdomain.com/api/monitors/cron?key=your-cron-secret" > /dev/null

# Email notifications — daily at 9 AM
0 9 * * * curl -s -X POST "https://yourdomain.com/api/notifications" -H "Content-Type: application/json" -d '{"trigger":"domain-expiry"}' > /dev/null
0 9 * * * curl -s -X POST "https://yourdomain.com/api/notifications" -H "Content-Type: application/json" -d '{"trigger":"invoice-reminders"}' > /dev/null

# Database backup — daily at 2 AM
0 2 * * * pg_dump -U smarttech_user smarttech > /var/backups/smarttech_$(date +\%Y\%m\%d).sql
✅ Done! Your application is now live at https://yourdomain.com. Access the admin panel at https://yourdomain.com/?admin=true.

3. Installation on cPanel

⚠️ Important: cPanel shared hosting does NOT support Node.js applications properly. You need a cPanel VPS or Dedicated server with Root access and the Node.js Selector plugin installed.

Prerequisites

Step 1: Create a cPanel account

  1. Log into WHM as root
  2. Go to Account Functions → Create a New Account
  3. Enter the domain (e.g., smarttech.yourdomain.com)
  4. Set a strong password and note it
  5. Click Create

Step 2: Enable SSH & Terminal access

  1. In WHM, go to Account Functions → Manage Shell Access
  2. Select your account and enable SSH Access (or "Jailed Shell")
  3. Save changes

Step 3: Create a MySQL database

  1. Log into cPanel for your account
  2. Go to Databases → MySQL Database Wizard
  3. Create database: smarttech
  4. Create user: smarttech_user with a strong password
  5. Grant ALL PRIVILEGES to the user
  6. Note the full database name (usually username_smarttech) and user name (username_smarttech_user)

Step 4: Upload the application files

  1. Log into cPanel → Files → File Manager
  2. Navigate to your home directory (not public_html)
  3. Create a folder named smarttech
  4. Upload the smarttech-hosting-panel.zip file
  5. Extract the zip into the smarttech folder

Step 5: Install dependencies via Terminal

  1. In cPanel, go to Advanced → Terminal
  2. Run the following commands:
cd ~/smarttech

# Install Node.js dependencies
npm install

# If npm is not available, use the Node.js Selector:
# 1. Go to cPanel → Software → Setup Node.js App
# 2. Click "Create Application"
# 3. Set Node.js version to 20.x
# 4. Set Application Mode to "Production"
# 5. Set Application Root to /smarttech
# 6. Set Application URL to your domain
# 7. Click Create

Step 6: Configure environment

# Create .env file
cp .env.example .env
nano .env

Set these values:

# MySQL connection (cPanel format: username_dbname)
DATABASE_URL="mysql://username_smarttech_user:YourPassword@localhost:3306/username_smarttech"

# Update prisma/schema.prisma to use mysql:
# datasource db {
#   provider = "mysql"
#   url      = env("DATABASE_URL")
# }

SESSION_SECRET="generate-with-openssl-rand-hex-32"
NEXTAUTH_SECRET="generate-another-one"
NEXTAUTH_URL="https://yourdomain.com"

CRON_SECRET="your-cron-secret"

Step 7: Initialize database

# Update Prisma schema to MySQL
sed -i 's/provider = "sqlite"/provider = "mysql"/' prisma/schema.prisma

# Push schema
npx prisma db push

# Run seed scripts
node scripts/seed.js
node scripts/seed-integrations.js
node scripts/seed-settings-payments.js
node scripts/seed-content-monitors.js
node scripts/seed-admin.js
node scripts/seed-licenses.js
node scripts/seed-domain-tlds.js

Step 8: Build the application

# Build for production
npm run build

Step 9: Configure the Node.js app in cPanel

  1. Go to cPanel → Software → Setup Node.js App
  2. Edit your application (or create one if not done in Step 5)
  3. Set:
    • Application Mode: Production
    • Application URL: your domain
    • Application Root: smarttech
    • Application Startup File: server.js (or .next/standalone/server.js)
  4. In the Run the script field, add: npm run start
  5. Click Run to start the application

Step 10: Set up SSL

  1. In cPanel, go to Security → SSL/TLS Status
  2. Click Run AutoSSL to generate free SSL certificates
  3. Wait 5-10 minutes for certificates to be issued
📝 Note: cPanel's Node.js app runs behind Apache with Passenger. You don't need Nginx — cPanel handles the reverse proxy automatically.

4. Database Setup

Why not SQLite for production?

SQLite is a file-based database that only allows one write operation at a time. With 1000+ clients, you'll experience:

PostgreSQL (Recommended)

Install on Ubuntu/Debian

apt install -y postgresql postgresql-contrib
systemctl enable postgresql
systemctl start postgresql

Create database & user

su - postgres
psql

CREATE DATABASE smarttech;
CREATE USER smarttech_user WITH ENCRYPTED PASSWORD 'YourStrongPassword123';
GRANT ALL PRIVILEGES ON DATABASE smarttech TO smarttech_user;
ALTER USER smarttech_user WITH SUPERUSER;

\q
exit

Update Prisma schema

// prisma/schema.prisma
datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

Connection string format

DATABASE_URL="postgresql://username:password@localhost:5432/databasename?schema=public"

MySQL (Alternative)

Install on Ubuntu/Debian

apt install -y mysql-server
systemctl enable mysql
systemctl start mysql

# Secure installation
mysql_secure_installation

Create database & user

mysql -u root -p

CREATE DATABASE smarttech CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'smarttech_user'@'localhost' IDENTIFIED BY 'YourStrongPassword123';
GRANT ALL PRIVILEGES ON smarttech.* TO 'smarttech_user'@'localhost';
FLUSH PRIVILEGES;

EXIT;

Update Prisma schema

// prisma/schema.prisma
datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

Connection string format

DATABASE_URL="mysql://username:password@localhost:3306/databasename"
⚠️ Important: After changing the database provider, always run bun run db:push to create all tables in the new database, then re-run all seed scripts.

5. All Modules & Features

The SmartTech Hosting Panel includes 14 admin modules and a full client portal:

📊 Dashboard Overview

Real-time KPIs showing total revenue, active clients, domains, hosting services, open tickets, and outstanding amounts. Includes a 30-day revenue chart, server capacity bars, and recent activity feeds for clients, invoices, tickets, and domains.

  • 6 KPI cards with trends
  • Revenue area chart (7d / 30d / 12m)
  • Server capacity usage bars
  • Recent clients, invoices, tickets, domains
  • Domains expiring soon alerts

👥 Clients Management

Full client management with searchable, paginated table. Click any client to open a detail sheet showing profile, contact info, credit balance, and cross-module counts (hosting, domains, invoices, tickets).

  • Search by name, email, or company
  • Filter by status (Active, Suspended, Inactive)
  • Detail sheet with all account info
  • Service counts per client
  • Add new clients

🖥️ Hosting Services Management

All provisioned hosting accounts with plan, server, billing cycle, and next due date. Click any service to see full details and perform actions.

  • Search by domain, username, or client
  • Filter by status (Active, Pending, Suspended, Terminated)
  • Detail sheet with plan, server, client info
  • Actions: Suspend, Unsuspend, Provision, Reset Password, Login as User, Terminate

🌐 Domains Management

Domain registrations with expiry tracking, auto-renew toggles, and WHOIS privacy indicators. Click any domain for full details and management actions.

  • Expiry countdown with color coding
  • Auto-renew toggle (inline)
  • WHOIS privacy indicator
  • "Expiring soon" filter
  • Detail sheet: Renew, Transfer, Edit DNS, Get EPP Code

💰 Domain Pricing New

Set your own prices for every TLD. Configure registration, transfer, and renewal prices separately. Mark TLDs as "popular" to show them on the storefront.

  • Add/edit/delete any TLD (.com, .pk, .com.pk, etc.)
  • Separate register, transfer, renew prices
  • Min/max registration years
  • Popular flag (shown on storefront)
  • 22 pre-seeded TLDs including Pakistani TLDs

🛒 Orders Management

Order history with itemized products, billing cycles, and totals. Click any order to see full details and take action.

  • Search by client
  • Filter by status (Active, Pending, Cancelled, Fraud)
  • Detail sheet with all line items
  • Actions: Approve, Cancel, Generate Invoice, Print

📄 Invoices Billing

Billing summary with collected, outstanding, paid, and unpaid counts. Click any invoice for full details including line items and payment actions.

  • Summary cards (collected, outstanding, paid, unpaid)
  • Search by invoice number or client
  • Filter by status (Paid, Unpaid, Draft, Cancelled, Refunded)
  • Detail sheet with line items and totals
  • Actions: Download PDF, Mark as Paid, Send Reminder, Refund, Print

🎫 Support Tickets Support

Full ticket pipeline with conversation thread. Reply to customers and update ticket status from the detail sheet.

  • Status pipeline cards (Open, Answered, Customer-Reply, Closed)
  • Filter by department and status
  • Priority badges (Low, Medium, High, Critical)
  • Full conversation thread with chat bubbles
  • Reply box with status selector
  • Quick status change dropdown

📦 Products & Plans Catalog

Hosting plan catalog with full CRUD. Add, edit, or delete any product. Set prices, features, setup fees, and stock control.

  • Products grouped by type (Shared, VPS, Reseller, Dedicated, SSL)
  • Edit any product (name, price, features, description)
  • Add new products
  • Delete with confirmation
  • Hidden flag (hide from storefront)
  • Stock control with quantity limits

🖥️ Servers Infrastructure

Server infrastructure dashboard with capacity bars and full uptime monitoring.

  • Server cards with IP, type, location, capacity
  • Account usage progress bars
  • Uptime monitoring section
  • Add monitors (TCP, HTTP, Ping)
  • Monitor detail: uptime %, incidents, downtime log
  • Edit and delete monitors
  • "Check Now" button for instant check

🔌 Integrations System

Configure API credentials for all hosting providers, domain registrars, and payment gateways.

  • Hosting: cPanel/WHM, 20i Reseller
  • Domain Registrars: Namecheap, Spaceship
  • Payment Gateways: Easypaisa, JazzCash, Pakistani Bank Transfer, Stripe, PayPal
  • "Save & Test" verifies credentials
  • Active/Default toggles
  • Masked password fields with show/hide

🔑 Licenses System

Generate and manage license keys for reselling the app. Create admin and reseller keys with time durations.

  • Generate 1-50 keys at once
  • Duration: 30/90/180/365/730 days or Lifetime
  • Admin keys (full panel access)
  • Reseller keys (with max client limit)
  • Copy key to clipboard
  • Revoke/delete keys
  • License key login at /?admin=true

📝 Site Content System

Edit the storefront page content without touching code. All changes go live immediately.

  • Hero section: badge, title, subtitle, search placeholder, trust badges
  • Hosting section: title, subtitle, annually badge
  • Features section: add/edit/remove feature cards
  • Footer: company description
  • "View Storefront" button

⚙️ Settings System

Configure branding, currency, contact info, and system settings.

  • Branding: app name, tagline, company name
  • Currency: PKR, USD, EUR, GBP, AED, SAR, INR
  • Tax rate (Pakistan 13% default)
  • Contact: support email, phone, address
  • Payment gateways overview
  • Notification toggles
  • Security: 2FA, IP whitelist

Client Portal

🔐 Client Portal (separate from admin)

Clients log in via the "Client Login" button on the storefront. They can:

  • Overview: Stats for active services, domains, outstanding balance, open tickets
  • My Services: View all hosting services and domains
  • Invoices: View and pay invoices (Easypaisa, JazzCash, Bank Transfer)
  • Support: Open new tickets and view existing ones

6. Integration Setup

cPanel / WHM Integration

Required Credentials

  • WHM Hostname: e.g. shared01.yourcompany.com
  • WHM Port: 2087 (default)
  • WHM Username: root or reseller username
  • WHM API Token: Generate in WHM → Development → Manage API Tokens

Setup Steps

  1. Log into WHM as root
  2. Go to Development → Manage API Tokens
  3. Click Generate Token
  4. Name it "SmartTech Panel"
  5. Copy the token
  6. In SmartTech Admin → Integrations → cPanel/WHM → Configure
  7. Paste hostname, username, and API token
  8. Click "Save & Test"

20i Reseller Integration

Required Credentials

  • OAuth Client ID: Format: livesite_XXXXXXXX
  • OAuth Client Secret: Secret key
  • API Base URL: https://api.20i.com
  • Reseller Package ID: Your 20i reseller package reference

Setup Steps

  1. Log into 20i Reseller API
  2. Create new API credentials
  3. Copy the Client ID and Client Secret
  4. In SmartTech Admin → Integrations → 20i Reseller → Configure
  5. Paste credentials
  6. Click "Save & Test"

Namecheap Domain Registrar

Required Credentials

  • API Username: Your Namecheap username
  • API Key: Generate at Namecheap → Profile → Tools → API Access
  • Client IP: Your server's public IP (must be whitelisted)
⚠️ Important: Namecheap requires you to whitelist your server's IP address. Go to Namecheap API Whitelist and add your server IP.

Spaceship Domain Registrar

Required Credentials

Spaceship uses HMAC-signed requests. The integration code handles signing automatically.

7. Payment Gateway Setup

Easypaisa Payment Gateway

Required Credentials

  • Merchant ID: Numeric ID from Easypaisa
  • Store ID: Store identifier
  • Hash Key: For SHA-256 HMAC request signing
  • API Base URL: https://easypaisa.com.pk/easypaisa-service/api/v1
  • Callback URL: https://yourdomain.com/api/payments/easypaisa/callback

How it works

  1. Customer selects Easypaisa at checkout
  2. App creates a payment request with hash signing
  3. Customer redirected to Easypaisa checkout
  4. After payment, Easypaisa redirects to callback URL
  5. App verifies the response hash and marks invoice as Paid
📝 Note: Easypaisa requires a registered Pakistani merchant account and SBP approval. Contact Easypaisa Business to apply.

JazzCash Payment Gateway

Required Credentials

  • Merchant ID: Format: MC12345
  • API Password: Set in JazzCash merchant portal
  • Integrity Salt: For HMAC-SHA256 request signing (keep secret!)
  • API URL (Sandbox): https://sandbox.jazzcash.com.pk/CustomerApp/Api/Payment/Request
  • API URL (Production): https://api.jazzcash.com.pk/jazzcash/payment/Request
  • Return URL: https://yourdomain.com/api/payments/jazzcash/callback

How it works

  1. Customer selects JazzCash at checkout
  2. App creates an HMAC-SHA256 signed payment request
  3. Customer redirected to JazzCash payment page (POST form)
  4. After payment, JazzCash posts response to return URL
  5. App verifies the secure hash and marks invoice as Paid
📝 Note: JazzCash requires a registered Pakistani merchant account. Apply at JazzCash Business.

Pakistani Bank Transfer

Configuration

No API credentials needed — just enter your bank account details:

  • Bank Name: e.g. HBL, Meezan Bank, Bank Alfalah, UBL, MCB
  • Account Title: Must match CNIC/business registration
  • Account Number: Bank account number
  • IBAN: Format: PK36SCBL0000001123456702
  • Branch Code: Optional
  • SWIFT Code: For international transfers (optional)
  • Secondary Bank: Optional second bank account
  • Instructions: Shown to customer on checkout

How it works

  1. Customer selects Bank Transfer at checkout
  2. App shows bank account details and instructions
  3. Customer transfers funds and emails deposit slip
  4. Admin verifies deposit and marks payment as completed
  5. Invoice status changes to Paid

Supported banks: HBL, Meezan Bank, Bank Alfalah, UBL, MCB, Standard Chartered Pakistan, Faysal Bank, BankIslami, HabibMetro, Askari Bank.

Stripe (International)

Required Credentials

  • Publishable Key: pk_live_... or pk_test_...
  • Secret Key: sk_live_... or sk_test_...
  • Webhook Secret: whsec_... for payment verification

Set webhook URL to: https://yourdomain.com/api/webhooks/stripe

PayPal (International)

Required Credentials

  • Client ID: From PayPal Developer dashboard
  • Client Secret: From PayPal Developer dashboard
  • Webhook ID: For payment notifications

Set webhook URL to: https://yourdomain.com/api/webhooks/paypal

8. License Management

The licensing system lets you resell the SmartTech Hosting Panel to other hosting companies.

How Reselling Works

  1. You (SmartTech owner) generate license keys in Admin → Licenses
  2. Sell a key to another hosting company (e.g., 1-year reseller key for ₨50,000)
  3. They deploy the app on their own server
  4. They log in using the license key at theirdomain.com/?admin=true
  5. The key expires after the duration — they must renew to keep access
  6. You can revoke any key at any time if a customer doesn't pay

License Types

TypeAccessUse Case
AdminFull admin panel accessFor your own staff or single-customer deployments
ResellerFull admin panel + max client limitFor reselling to other hosting companies

Duration Options

DurationCodeUse Case
30 days30Trial / Demo
90 days90Quarterly
180 days180Semi-annual
365 days365Annual (most common)
730 days7302-year
LifetimenullNever expires (enterprise)

License Key Format

All keys follow the format: ST-XXXX-XXXX-XXXX-XXXX (ST = SmartTech)

Example: ST-ZFX8-AWWY-H0N0-7LO6

Default Admin Keys (pre-seeded)

⚠️ Change these immediately after installation! These are demo keys included with the seed data.
KeyDurationNote
ST-ZFX8-AWWY-H0N0-7LO6LifetimeMaster key
ST-4BKN-NSAM-VXDY-BA4T365 days1-year admin
ST-CAYH-9E7J-XJZS-DC6J365 days1-year admin
ST-843W-P4EK-VLZH-QC1F90 daysTrial
ST-9IRJ-AR6E-N9H3-ROB030 daysDemo

9. Server Monitoring

How Monitoring Works

The monitoring system checks your servers at regular intervals and logs uptime/downtime data.

Setting Up Monitors

  1. Go to Admin → Servers
  2. Scroll to the Server Monitoring section
  3. Click Add Monitor
  4. Enter:
    • Label: Friendly name (e.g., "Web Server 01")
    • Target: IP address or hostname
    • Port: Port to check (80, 443, 22, 2087, etc.)
    • Check Type: TCP, HTTP, or Ping
    • Interval: How often to check (60 seconds default)
  5. Click Add Monitor

Monitoring Data Displayed

Setting Up the Cron Job

The monitoring cron job runs the actual checks. Set it up on your server:

# Edit crontab
crontab -e

# Add this line (runs every minute):
* * * * * curl -s "https://yourdomain.com/api/monitors/cron?key=YOUR_CRON_SECRET" > /dev/null

Replace YOUR_CRON_SECRET with the value from your .env file's CRON_SECRET setting.

External Cron Services

If you don't have server access for cron, use an external service:

Set the URL to: https://yourdomain.com/api/monitors/cron?key=YOUR_CRON_SECRET

10. Email Notifications

Email Templates

The system sends these automated emails:

TemplateWhen SentRecipient
WelcomeNew client signupClient
Invoice CreatedNew invoice generatedClient
Invoice PaidPayment receivedClient
Ticket ReplyStaff replies to ticketClient
Domain Expiry60, 30, 7 days before expiryClient
Invoice Reminder7, 3, 1 days before dueClient

SMTP Configuration

Configure SMTP in your .env file:

SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your-email@gmail.com
SMTP_PASS=your-gmail-app-password
FROM_EMAIL=noreply@yourdomain.com

Gmail App Password Setup

  1. Enable 2-Factor Authentication on your Gmail account
  2. Go to Google App Passwords
  3. Generate a new app password for "Mail"
  4. Use that 16-character password as SMTP_PASS

Other SMTP Providers

ProviderSMTP HostPort
Gmailsmtp.gmail.com587
Outlook/Hotmailsmtp-mail.outlook.com587
Yahoosmtp.mail.yahoo.com587
SendGridsmtp.sendgrid.net587
Mailgunsmtp.mailgun.org587
Amazon SESemail-smtp.us-east-1.amazonaws.com587

Setting Up Notification Cron Jobs

# Daily at 9 AM — check domain expiry warnings
0 9 * * * curl -s -X POST "https://yourdomain.com/api/notifications" -H "Content-Type: application/json" -d '{"trigger":"domain-expiry"}' > /dev/null

# Daily at 9 AM — send invoice due reminders
0 9 * * * curl -s -X POST "https://yourdomain.com/api/notifications" -H "Content-Type: application/json" -d '{"trigger":"invoice-reminders"}' > /dev/null

11. Backup & Recovery

Database Backup (PostgreSQL)

# Manual backup
pg_dump -U smarttech_user smarttech > backup_$(date +%Y%m%d).sql

# Restore from backup
psql -U smarttech_user smarttech < backup_20260710.sql

Automated Daily Backups

# Create backup script
cat > /var/backups/pg-backup.sh << 'EOF'
#!/bin/bash
BACKUP_DIR="/var/backups/postgresql"
mkdir -p $BACKUP_DIR
DATE=$(date +%Y%m%d_%H%M%S)
pg_dump -U smarttech_user smarttech > $BACKUP_DIR/smarttech_$DATE.sql
# Keep only last 7 days
find $BACKUP_DIR -name "smarttech_*.sql" -mtime +7 -delete
EOF

chmod +x /var/backups/pg-backup.sh

# Schedule daily backup at 2 AM
crontab -e
# Add:
0 2 * * * /var/backups/pg-backup.sh

Database Backup (MySQL)

# Manual backup
mysqldump -u smarttech_user -p smarttech > backup_$(date +%Y%m%d).sql

# Restore from backup
mysql -u smarttech_user -p smarttech < backup_20260710.sql

File Backup

# Backup the entire application directory
tar -czf /var/backups/smarttech_files_$(date +%Y%m%d).tar.gz /var/www/smarttech

# Backup the .env file separately (contains secrets)
cp /var/www/smarttech/.env /var/backups/.env.backup

Full Backup Script

#!/bin/bash
# /var/backups/full-backup.sh

DATE=$(date +%Y%m%d_%H%M%S)
BACKUP_DIR="/var/backups/smarttech"
mkdir -p $BACKUP_DIR

# Database backup
pg_dump -U smarttech_user smarttech > $BACKUP_DIR/db_$DATE.sql

# Files backup
tar -czf $BACKUP_DIR/files_$DATE.tar.gz /var/www/smarttech --exclude=node_modules --exclude=.next

# Keep only last 7 days
find $BACKUP_DIR -name "*.sql" -mtime +7 -delete
find $BACKUP_DIR -name "*.tar.gz" -mtime +7 -delete

echo "Backup completed: $DATE"

12. Troubleshooting

Common Issues

Issue: "Cannot connect to database"

Cause: Wrong DATABASE_URL or database not running.

Fix:

  1. Check if PostgreSQL is running: systemctl status postgresql
  2. Test connection: psql -U smarttech_user -d smarttech -h localhost
  3. Verify .env file has correct DATABASE_URL
  4. Check PostgreSQL logs: tail -f /var/log/postgresql/postgresql-15-main.log

Issue: "Port 3000 already in use"

Cause: Another process is using port 3000.

Fix:

# Find the process
lsof -i :3000

# Kill it
kill -9 PID

# Or change the port in package.json:
# "dev": "next dev -p 3001"

Issue: "Prisma Client not generated"

Cause: Prisma client not built after schema change.

Fix:

bun run db:generate
# or
npx prisma generate

Issue: "SSL certificate not working"

Cause: DNS not pointing to server, or Certbot failed.

Fix:

  1. Check DNS: dig yourdomain.com — should show your server IP
  2. Re-run Certbot: certbot --nginx -d yourdomain.com
  3. Check Nginx config: nginx -t
  4. Check Certbot logs: cat /var/log/letsencrypt/letsencrypt.log

Issue: "App crashes on startup"

Cause: Missing environment variables or database not initialized.

Fix:

  1. Check .env file exists and has all required variables
  2. Run bun run db:push to create database tables
  3. Check PM2 logs: pm2 logs smarttech
  4. Rebuild: bun run build

Issue: "Emails not sending"

Cause: SMTP not configured or wrong credentials.

Fix:

  1. Check .env has SMTP_HOST, SMTP_PORT, SMTP_USER, SMTP_PASS set
  2. For Gmail, use an App Password, not your regular password
  3. Check email logs in Admin → (check EmailLog table)
  4. Test SMTP connection: node -e "require('nodemailer').createTransport({host:'smtp.gmail.com',port:587,auth:{user:'you@gmail.com',pass:'app-password'}}).verify().then(()=>console.log('OK')).catch(e=>console.error(e))"

Issue: "Payment callback not working"

Cause: Callback URL not set correctly in payment gateway dashboard.

Fix:

  1. Verify callback URL is accessible: curl https://yourdomain.com/api/payments/easypaisa/callback
  2. Check the URL is set correctly in the payment gateway dashboard
  3. Ensure SSL is working (payment gateways require HTTPS)
  4. Check Nginx logs: tail -f /var/log/nginx/error.log

Issue: "Monitoring not checking"

Cause: Cron job not set up or wrong secret key.

Fix:

  1. Verify cron is running: systemctl status cron
  2. Check crontab: crontab -l
  3. Test manually: curl "https://yourdomain.com/api/monitors/cron?key=YOUR_SECRET"
  4. Check the CRON_SECRET in .env matches the cron URL

Useful Commands

# Check app status
pm2 status
pm2 logs smarttech

# Restart app
pm2 restart smarttech

# Check Nginx status
systemctl status nginx
nginx -t

# Check PostgreSQL status
systemctl status postgresql

# Check disk space
df -h

# Check memory usage
free -h

# Check running processes
htop

# View app logs
pm2 logs smarttech --lines 100

# Clear Next.js cache
rm -rf .next
bun run build

# Reset database (DESTRUCTIVE!)
bun run db:push --force-reset

Getting Support

Need help? Check the following:
  • Application logs: pm2 logs smarttech
  • Nginx logs: /var/log/nginx/error.log
  • PostgreSQL logs: /var/log/postgresql/
  • System logs: journalctl -u smarttech