# cPanel Deployment — ravneetbrar.in

This project is **fully compatible with cPanel Node.js** (Phusion Passenger). Follow these exact steps:

## 1. Create Node.js App in cPanel

cPanel → **Setup Node.js App** → **Create Application**

- **Node.js version:** `20.x` (or 22)
- **Application mode:** `Production`
- **Application root:** `ravneetbrar` (or `public_html/ravneetbrar` — keep it outside `public_html` if possible, then map domain to it)
- **Application URL:** `https://ravneetbrar.in`
- **Application startup file:** `app.js` (we provide this — it starts Next.js on `process.env.PORT`)
- Click **Create**

## 2. Upload Files

- In cPanel → **File Manager** → open `ravneetbrar` → **Upload** the project ZIP **or** use **Git Version Control** → Clone `https://github.com/luxpablo/ravneetbrar.git` into `ravneetbrar`
- Ensure `package.json`, `prisma/`, `src/`, `public/`, `app.js` are in the app root.

## 3. Set Environment Variables

In **Setup Node.js App** → your app → **Environment Variables** → Add:

```
NODE_ENV=production
DATABASE_URL=file:./prisma/dev.db
# For SQLite (simple, no external DB needed on shared hosting)
# Use absolute path if file:./ fails: file:/home/USERNAME/ravneetbrar/prisma/dev.db
# For MySQL/Postgres on cPanel, use:
# DATABASE_URL=mysql://user:pass@localhost:3306/dbname
# DATABASE_URL=postgresql://user:pass@localhost:5432/dbname

AUTH_SECRET=your-random-32-chars
ADMIN_EMAIL=admin@ravneetbrar.in
```

> **Important:** On shared hosting, SQLite `file:./prisma/dev.db` is the easiest — no external DB needed. Ensure `prisma/` folder is **writable** (755 or 775). If you use MySQL, change `prisma/schema.prisma` provider to `mysql` and run migrate.

## 4. Install & Build (via Terminal in cPanel)

Open **Terminal** in cPanel (or SSH):

```bash
cd ~/ravneetbrar
npm ci --no-audit --no-fund
# This runs postinstall: prisma generate (generates client for Linux)

# Create DB tables + seed
npx prisma migrate deploy
npx prisma db seed

# Build Next.js
npm run build
```

If `prisma` not found, ensure Node 20 and `npm ci` completed.

## 5. Restart App

In **Setup Node.js App** → Click **Restart** (or **Stop** then **Start**).

Check **Logs** (Node.js Selector → your app → Logs) — you should see:
```
> Ready on http://localhost:XXXX (cPanel)
```

Visit `https://ravneetbrar.in` — it should load.

## Common cPanel Fixes

**“Not running” / 503 / 500:**
- Check **Logs** in Node.js Selector — copy the error here.
- Ensure **Application startup file** is `app.js` (not `server.js`).
- Ensure **Node version 20** and **Application root** is correct.
- Ensure `DATABASE_URL` is set and `prisma/dev.db` is writable: `chmod 775 prisma && chmod 664 prisma/dev.db`
- If using `file:./dev.db` fails, try absolute: `file:/home/YOURCPANELUSER/ravneetbrar/prisma/dev.db`
- Run `npm run build` after every `git pull` — `.next` must exist.
- Ensure `package.json` has `prisma` in `dependencies` (we moved it) — `npm ci` will install.

**“Cannot find module @prisma/client”:**
- Run `npx prisma generate` manually in terminal.

**“PrismaClientInitializationError”:**
- Means `DATABASE_URL` is wrong or DB file not writable. Check `DATABASE_URL` and file permissions.

**Domain shows cPanel default page, not Node app:**
- In **Setup Node.js App**, ensure **Application URL** is `ravneetbrar.in` (with correct domain) and **Open** shows Node, not Apache. No `.htaccess` needed when using Node Selector.

**For `public_html` setup:**
- If your host requires files in `public_html`, keep Node app in `~/ravneetbrar` and set **Application URL** to `ravneetbrar.in` — cPanel will proxy automatically. Do **not** put Node files directly in `public_html`.

Need your exact cPanel **Logs**? Copy them here and I'll fix.
