## File-driven Owner Studio update

The compiled project now requires the `app-uis/` directory alongside `app/`, `public/`, and `blueprints/`. The Windows builder includes it. On upgrades, back up **`app-uis/`** as well as `.local-data/`, `blueprints/custom/`, and `.env.local`. Uploaded UI files are saved under `app-uis/<slug>/index.html` by the Node.js app, so this directory must be writable by that cPanel application. The website owner manages everything from **`/developer`**. `/admin` is an alias/redirect only.

No app is Available unless it has an assigned existing UI file and the owner explicitly releases it.

---

# Deploy Larpdevice on Namecheap cPanel (Node.js hosting)

This Next.js project **requires a running Node.js server** for real login, signup, editor saves, and share links. **Do not** upload the source to `public_html` as if it were plain HTML. For public accounts, replace the local JSON store with a production-grade database and auth solution first; see the README security section.

## Recommended: build on your Windows computer, then upload

1. Install Node.js 22 LTS and extract this ZIP somewhere on your computer. **Simplest option:** double-click `BUILD_FOR_NAMECHEAP_WINDOWS.bat` and let it create a compiled `Larpdevice-Namecheap-READY-TO-UPLOAD.zip` in the extracted `Larpdevice` folder. Then skip directly to step 4 using that generated ZIP. Alternatively, follow the manual steps below.
2. Inside the extracted `Larpdevice` folder, open a terminal and run:

   ```powershell
   npm install
   npm run build
   ```

   A successful build creates a hidden `.next` directory. **Keep `.next`** for the upload, but **do not upload `node_modules`, `.env.local`, or `.local-data`.**
3. Prepare a ZIP of the **contents of** the `Larpdevice` directory including `package.json`, `server.js`, `.next`, `public/`, `app/`, `components/`, `lib/`, and `next.config.ts`. Put files at the ZIP root, not inside an extra `Larpdevice` folder. If you skip the local build, you'll have to build on Namecheap with `npm run build` (which may use too many resources on shared hosting).
4. In Namecheap's Hosting List, open your plan's cPanel. Create/choose your domain or subdomain under cPanel Domains, making sure its DNS resolves to this hosting account and HTTPS is enabled.
5. Open **File Manager** and create `larpdevice` in your **home folder, outside `public_html`**. Upload and extract the prepared ZIP here. Ensure `larpdevice/server.js` and `larpdevice/package.json` exist directly within this directory.
6. In **Setup Node.js App**, choose **Create Application**:
   - Node.js: **22** (or compatible currently supported version)
   - Application mode: **Production**
   - Application root: **larpdevice**
   - Application URL: select your domain/subdomain (e.g. `https://demo.example.com`)
   - Application startup file: **server.js**
7. Add environment variables using the Node.js app environment-variable controls:
   - `NODE_ENV=production`
   - `APP_URL=https://your-actual-domain.com` (no trailing slash; match HTTPS and exact hostname)
   - `AUTH_SECRET=` a unique 48-byte random hex string; generate it locally using:

     ```bash
     node -e "console.log(require('node:crypto').randomBytes(48).toString('hex'))"
     ```

   Never paste your secret or `.env.local` into a support chat or publish them. Keep a secure backup of `AUTH_SECRET` so sessions don't break after re-deployment.
8. In the Node.js app interface run **NPM Install** (or use the suggested virtual environment + SSH and `npm install --omit=dev` if a valid `.next` production build was uploaded). Start/restart the application.
9. Check the homepage, light/dark toggle, login/signup (only with private test accounts), app library, and editor save. Use cPanel error logs and the Node.js App manager to diagnose startup failures.

**Build compatibility:** Build with the same Node.js major version on Windows and Namecheap. Upload a fresh `.next` after changes, then restart the app. Do not run `npm run dev` on public hosting.

**If you only purchased a Namecheap domain**, you still need hosting; a domain name alone does not run Next.js. If **Setup Node.js App** is not available on your plan, ask Namecheap about supported hosting or use a Node-capable service for the app while retaining Namecheap for the domain/DNS.

## Speed notes

- `npm run dev` is intentionally slower, particularly on the first page load. `npm run build` + `npm start` runs optimized production code.
- Larpdevice now fetches initial account data using one `/api/bootstrap` request rather than up to five requests.
- The marketing homepage is server-rendered, SVG catalog tiles load lazily, and offscreen cards defer rendering.
- Browsers cache brand icon SVGs. Reduced-motion preferences disable expensive effects.
- Namecheap shared hosting can still feel slow under load. Node.js CPU/memory, disk speed, and network latency limit real-world speed; use performance tests on the final host.

## Useful official guides

- [Namecheap: Next.js in cPanel](https://www.namecheap.com/support/knowledgebase/article.aspx/10686/29/how-to-deploy-reactjs-vitejs-react-native-and-nextjs-applications-in-cpanel/)
- [Namecheap: Set up Node.js app](https://www.namecheap.com/support/knowledgebase/article.aspx/10047/2182/how-to-work-with-nodejs-app/)
- [Next.js: Deploying](https://nextjs.org/docs/app/getting-started/deploying)


## Blueprint Studio upgrade (Larpdevice v1.1)

This package includes the `blueprints/` directory and the no-code `/admin`, `/developer`, and `/studio/<app-slug>` routes.

**Before an upgrade:** download backups of `.local-data/` and `blueprints/custom/`. They contain local users, project data, catalog changes, uploaded icons and custom blueprints. Do not delete these folders during updates.

The owner-only Admin Dashboard requires these additional environment variables on Namecheap Shared Hosting:

- `LARPDEVICE_ADMIN_EMAIL` — the email of the account you registered on this Larpdevice website.
- `LARPDEVICE_ADMIN_USER_ID` — the exact account ID returned as `user.id` by `/api/bootstrap` after owner login. Required in production, together with the matching email.

Restart the Node.js application after setting those variables. The owner can then open `https://your-domain/admin`. All other users are blocked from making global app/website changes.

See [BLUEPRINT_STUDIO_GUIDE.md](BLUEPRINT_STUDIO_GUIDE.md) for the block editor, LarpScript, icon upload and Coming Soon workflow.


## v1.2 Node Graph upgrade

See [NODE_GRAPH_SETUP.md](NODE_GRAPH_SETUP.md). Back up `.local-data/` and `blueprints/custom/` first. There are now distinct `/admin` and `/developer` routes; public visibility defaults to Chase and Cash App. Newly created screens are blank until you add Blueprint nodes.
