# Deploy Luminic Books on Rochen cPanel

Host: Rochen, CloudLinux, **Setup Node.js App** (Passenger). Node **22**. No Docker and no root access. The public address is a subdomain such as `https://books.luminic.studio`.

The app does not use Chromium. Invoice PDFs are built with PDFKit. The database is SQLite through Node’s built-in `node:sqlite` module, so nothing has to be compiled on the server. `better-sqlite3` is not used: CloudLinux accounts usually cannot compile native addons. MySQL is on the plan, but this app stays on one SQLite file because the books are small, the SQL is already SQLite, and a single file is easy to copy for a backup. Passenger should run **one** Node process for this app so two processes never write the file at once. Two people using it is fine on one process.

Secrets and the workbook never go in git. The database, receipts, and the Excel file live in a folder **outside** `public_html`.

## 1. Create the subdomain

1. cPanel → **Domains** → **Create a New Domain** (or Subdomains).
2. Domain: `books.luminic.studio`.
3. Document root: leave the default, usually `/home/USER/books.luminic.studio`. `USER` is the cPanel username.
4. Do not turn on a PHP site for this host. Node will answer it.

## 2. Create the private data folder

cPanel → **File Manager** → home directory (the folder that **contains** `public_html`, not inside it).

Create `luminic-data`.

That path is `/home/USER/luminic-data`. The app will create `luminic.db`, `receipts/`, and `imports/` there from `DATABASE_PATH`.

Upload the Excel workbook into this folder, for example `/home/USER/luminic-data/luminic_books_source.xlsx`. Do not put it in the app folder or in git.

## 3. Create the Node.js app

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

| Field | Value |
|---|---|
| Node.js version | `22` (22.x, not 24) |
| Application mode | `Production` |
| Application root | `books.luminic.studio` |
| Application URL | `books.luminic.studio` |
| Application startup file | `app.js` |

If the panel asks for a port, leave the one it assigns. Passenger sets `PORT`. Do not hard-code 3000.

Open **Environment variables** and add each of these. Generate the secret and password yourself. Do not reuse an example string.

| Name | Value |
|---|---|
| `NODE_ENV` | `production` |
| `NODE_OPTIONS` | `--experimental-sqlite` |
| `LUMINIC_SESSION_SECRET` | a long random string |
| `LUMINIC_OWNER_EMAIL` | Sahar’s email |
| `LUMINIC_OWNER_NAME` | `Sahar Rasooli` |
| `LUMINIC_OWNER_PASSWORD` | a long password |
| `DATABASE_PATH` | `/home/USER/luminic-data/luminic.db` |

`NODE_OPTIONS` has to be set here. The SQLite module is built into Node 22 and only loads when that flag is present **before** Node starts. `app.js` cannot turn it on later.

Optional, only if the assistant should exist on first boot:

| Name | Value |
|---|---|
| `LUMINIC_ASSISTANT_EMAIL` | her email |
| `LUMINIC_ASSISTANT_NAME` | her name |
| `LUMINIC_ASSISTANT_PASSWORD` | a long password |

Save the application. Do not start it until the files and `npm install` are done.

## 4. Upload the code

Use `luminic-books-cpanel.zip`. It is a Next.js **standalone** build: `app.js`, `server.js`, a traced `node_modules`, `.next/static`, `public`, and `assets/fonts`. It does not contain the Excel file, the database, or secrets. Building Next on this server needs more than 512 MB of RAM, so the zip is built elsewhere.

1. Upload the zip into `/home/USER/books.luminic.studio`.
2. Extract it so those files sit **in** that folder, not in an extra nested folder.
3. You should see `app.js`, `server.js`, and `node_modules` after extracting.

Git Version Control can pull source later, but a git pull does not include this standalone runtime. After a code change, build a new zip on a computer with enough RAM and upload it again.

## 5. Dependencies

The zip already contains the traced production `node_modules` from `next build` (`output: "standalone"`). On this machine that runtime is about 80MB. A full `npm install --omit=dev` of the same `package.json` is about **590MB**, which does not fit in the roughly **250MB** free on this account.

**Do not click Run NPM Install** after extracting this zip. It would try to download the full Next.js tree and fill the disk. The files it would install are already in the zip, and nothing in that install needs a compiler.

Use **Run NPM Install** only if you are deploying from a git checkout **without** the bundled `node_modules`, and only after freeing at least 700MB. The panel button runs `npm install` in production mode. From the terminal that is:

```bash
source /home/USER/nodevenv/books.luminic.studio/22/bin/activate
cd /home/USER/books.luminic.studio
npm install --omit=dev
```

The `nodevenv` path is the one printed on the Node.js App page. Use that path, not a guessed one. That install does not compile a database addon.

## 6. Start the app

**Setup Node.js App** → this application → **Restart**.

Open `https://books.luminic.studio`. You should see the sign-in page. Sign in with `LUMINIC_OWNER_EMAIL` and `LUMINIC_OWNER_PASSWORD`. The session cookie is `HttpOnly`, `SameSite=Lax`, and `Secure` whenever `NODE_ENV` is `production`, so the browser only sends it over HTTPS.

A wrong password eight times in 15 minutes locks that email for the rest of the window. The lock is stored in the SQLite file.

Change the owner password in **Settings** after the first sign-in if the value you typed in cPanel was temporary. Adding or removing the assistant is also in Settings. There is no public sign-up.

## 7. Import the workbook

Sign in, open **Settings**, and use **Import the workbook**. Choose the Excel file. The app saves it under `/home/USER/luminic-data/imports/` and loads it into the SQLite file. It does not commit the file anywhere.

Then open **Needs review**. Income should be $23,700.00, expenses $9,531.38, net $14,168.62, not paid $5,400.00, and invoices #1026–1035 pre-tax $7,450.00.

Importing again replaces the previous import and keeps records created in the app. The Excel file is not modified.

Importing again replaces the previous import and keeps records created in the app. The Excel file is not modified.

The invoice address in **Settings** stays **6075 Yonge St, 5th Floor, North York, Ontario, M2M 3W2** until you change it. The old Excel template prints a different street address. That difference is listed on Needs review. Edit Settings when you decide which one should appear on new PDFs.

## 8. Backups

The books are one file: `/home/USER/luminic-data/luminic.db`. Receipts are `/home/USER/luminic-data/receipts/`.

cPanel **Backup** of the home directory includes `luminic-data` because it is under the home folder and outside `public_html`. Download a copy of `luminic-data` as well before a big import or a code update. Stop or restart the app, copy the folder, then start the app again so the copy is not taken mid-write.

To restore, replace `luminic-data` with the copy and restart the Node app. Do not restore that folder into `public_html`.

## If it will not start

- The log in **Setup Node.js App** says `NODE_OPTIONS=--experimental-sqlite` is missing. Add that variable and restart.
- `Cannot find module 'next'`. Run NPM Install again from the application root.
- The site shows cPanel’s default page. The startup file must be `app.js`, and the application URL must be `books.luminic.studio`.
- Sign-in always fails. `LUMINIC_SESSION_SECRET`, the owner email, and the owner password in the environment must be set, then restart so the owner row can be created.
