# Deploying EazyByt to your cPanel (Node.js App)

Your EazyByt site is a **Node.js app** (not PHP/WordPress), so it runs through
cPanel's **Setup Node.js App** tool — which your plan has. This guide walks you
through it end to end.

> Your details (from your cPanel): username **`tagnetic`**, server IP
> **`217.217.250.172`**. The domain **eazybyt.com** is at another registrar, so
> we'll first test on a temporary address, then point eazybyt.com here.

You'll do everything inside cPanel — no coding needed. Just follow the steps.

---

## What I've prepared for you

- **`server.js`** — the startup file Passenger needs (already in the project).
- **`eazybyt-deploy.zip`** — a ready-to-upload package on your Desktop (excludes
  `node_modules`, the local database, and build files — those are created on the
  server).
- A generated **AUTH_SECRET** you can use (Step 4).

---

## Step 1 — (Recommended) Test on a temporary subdomain first

Before touching eazybyt.com, deploy under a subdomain of your existing domain so
you can confirm everything works.

1. cPanel → **Domains** → **Create A New Domain**.
2. Domain: `shop.tagneticai.com` (or any subdomain you like). Create it.

We'll deploy to this first, then switch to eazybyt.com in Step 7.

---

## Step 2 — Create the Node.js application

1. cPanel → search **"Node"** → open **Setup Node.js App**.
2. Click **Create Application** and set:
   - **Node.js version:** the highest available **20.x** (must be 18.18 or newer).
   - **Application mode:** **Production**.
   - **Application root:** `eazybyt`  (this creates `/home/tagnetic/eazybyt`).
   - **Application URL:** choose `shop.tagneticai.com` (from Step 1).
   - **Application startup file:** `server.js`
3. Click **Create**. Leave this page open — you'll come back to it.

---

## Step 3 — Upload the project files

1. cPanel → **File Manager** → go into the **`eazybyt`** folder (your app root).
2. Click **Upload** and upload **`eazybyt-deploy.zip`** from your Desktop.
3. Back in File Manager, right-click the zip → **Extract** (into the `eazybyt`
   folder). You should now see `src`, `public`, `prisma`, `package.json`,
   `server.js`, etc.
4. Delete the zip file to keep things tidy.

---

## Step 4 — Create the environment file

In File Manager, inside the `eazybyt` folder, create a new file named **`.env`**
(exactly that, with the leading dot) and paste this in — **change the admin email
and password to your own**:

```
DATABASE_URL="file:./dev.db"
AUTH_SECRET="0896c4d0715767d081cf1ecd312b66ae92258220b734b022ac5352a5d44d14c4"
ADMIN_EMAIL="you@youremail.com"
ADMIN_PASSWORD="ChooseAStrongPassword123!"
```

Save it. (This one file configures both the app and the database. The AUTH_SECRET
above is freshly generated for you — keep it private.)

---

## Step 5 — Install, build, and set up the database (Terminal)

Everything here runs in the **Terminal** (cPanel → **Terminal**). On the Node.js
App page, copy the **"Enter to the virtual environment"** command shown near the
top — it looks like `source /home/tagnetic/nodevenv/eazybyt/20/bin/activate`.
Then run these one at a time:

```bash
source /home/tagnetic/nodevenv/eazybyt/20/bin/activate   # paste YOUR exact line
cd ~/eazybyt
npm install --include=dev   # installs everything, incl. the build tools
npm run build               # builds the production site
npx prisma db push          # creates the database tables
npm run db:seed             # creates your admin login + sample catalog
```

> **Why `--include=dev`?** In Production mode the one-click "Run NPM Install"
> button can skip the tools needed to build (Tailwind, Prisma, TypeScript), which
> makes the build fail. Running the command above installs them correctly. You do
> **not** need to click the "Run NPM Install" button.

> If `npm run build` ever stops with an "out of memory" error on a small plan,
> tell me — I'll build it on my side and give you a pre-built version to upload.

---

## Step 6 — Start it and test

1. Back on **Setup Node.js App** → click **Restart**.
2. Open **https://shop.tagneticai.com** — your EazyByt store should load. 🎉
3. Log in at `/login` with the `ADMIN_EMAIL` / `ADMIN_PASSWORD` you set in `.env`.

If the page errors, open **Terminal** and check the log:
`cat ~/eazybyt/stderr.log` (or the log path shown on the Node.js App page), and
send me what it says.

---

## Step 7 — Point eazybyt.com to this server

Since eazybyt.com is registered elsewhere, do this once the test site works:

1. cPanel → **Domains** → **Create A New Domain** → enter `eazybyt.com`.
2. At your **domain registrar** (where you bought eazybyt.com), open its DNS
   settings and add these records:
   - **A record:** host `@` → **`217.217.250.172`**
   - **A record:** host `www` → **`217.217.250.172`**
   (Or, if your registrar prefers, change the **nameservers** to your host's —
   your host can tell you those.)
3. Wait for DNS to update (usually 15 min–2 hours, sometimes longer).
4. In **Setup Node.js App**, change your app's **Application URL** to
   `eazybyt.com` and **Restart** (or recreate the app pointing at eazybyt.com).
5. cPanel → **SSL/TLS Status** → select eazybyt.com → **Run AutoSSL** to enable
   HTTPS (the padlock).

Your live site: **https://eazybyt.com** 🚀

---

## Step 8 — After launch (important)

- **Admin password:** you set it in `.env`. To change it later, edit `.env`,
  then in Terminal run `npm run db:seed` (updates the password without deleting
  data).
- **Email / socials:** update in `src/lib/config.ts` if needed, then re-run
  `npm run build` and **Restart**.
- **Product photos** you upload from the admin are stored on the server and
  persist. Backups: periodically download `~/eazybyt/prisma/dev.db` (your data)
  and the `~/eazybyt/public/uploads` folder.

---

## Updating the site later

Whenever we change something:
1. Upload the changed files (or a new zip) into `~/eazybyt`.
2. Terminal: `cd ~/eazybyt && npm run build`
3. Setup Node.js App → **Restart**.

---

## Quick reference

| Setting | Value |
| --- | --- |
| App root | `/home/tagnetic/eazybyt` |
| Startup file | `server.js` |
| Node version | 20.x (≥18.18) |
| App mode | Production |
| Server IP (for DNS) | `217.217.250.172` |
| Admin login | the email/password from your `.env` |

Stuck on any step? Tell me which step number and what you see, and I'll get you
through it.
