#!/bin/bash
# Layerfive Calibration System - Quick Start Script

echo "=================================================="
echo "  Layerfive Calibration Certificate System"
echo "=================================================="

# Check Node.js
if ! command -v node &> /dev/null; then
    echo "ERROR: Node.js is not installed."
    echo "Download from: https://nodejs.org"
    exit 1
fi

NODE_VER=$(node -v | cut -c 2- | cut -d. -f1)
if [ "$NODE_VER" -lt 16 ]; then
    echo "ERROR: Node.js 16+ required. You have $(node -v)"
    exit 1
fi

# Install dependencies if needed
if [ ! -d "node_modules" ]; then
    echo "Installing dependencies..."
    npm install
fi

# Copy .env if not exists
if [ ! -f ".env" ]; then
    cp .env.example .env
    echo "Created .env from .env.example"
    echo "Edit .env to configure SMTP email settings."
fi

echo ""
echo "Starting server..."
echo "Access the app at: http://localhost:3000"
echo "Default admin: admin@layerfiveltd.com / Admin@123"
echo ""
npm start
