# Dugout — Deploy to your dedicated server

This is a **Node.js** app (React + TanStack Start + Postgres/PGLite), not a
static HTML site. FTP can upload the files, but the server must run **Node 20+**.

## What you need on the server

- Node.js 20 or 22
- npm
- A process manager is recommended (PM2, systemd, or your host’s Node app panel)
- Optional: Postgres (Neon, self-hosted). Without `DATABASE_URL`, the app uses
  an embedded database suitable for light demos.

## Upload via FTP

1. Unzip this archive on your computer.
2. Upload the **entire folder** to your server (e.g. `/var/www/dugout` or your
   home directory). Do **not** skip `package.json`, `package-lock.json`,
   `migrations/`, `src/`, `public/`, `server/`, or config files.
3. **Do not** expect the site to work by only opening `index.html` — there is no
   static-only index for the full social/auth/trade features.

## Install & run (SSH or hosting panel terminal)

```bash
cd /path/to/dugout
npm ci
npm run build
```

### Development-style (simplest)

```bash
npm run dev
# listens on 0.0.0.0:8080
```

### Production (recommended)

After `npm run build`, deploy the Vercel/Nitro output with a Node host, **or**
use a reverse proxy to a process that serves the built app.

If your host supports **Vercel-style** / **Nitro** Node deploys, the build
output under `.vercel/output` is what production targets.

For a simple always-on process after install:

```bash
# Example with PM2 (install once: npm i -g pm2)
npm run build
# Many hosts: set start command to `npm run dev` or your panel’s Node entry.
# Bind host 0.0.0.0 so the public IP can reach the app.
```

Point Nginx/Apache as a **reverse proxy** to `http://127.0.0.1:8080` (or your
chosen port). Example Nginx:

```nginx
server {
  listen 80;
  server_name your-domain.com;
  location / {
    proxy_pass http://127.0.0.1:8080;
    proxy_http_version 1.1;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
  }
}
```

## Environment variables (optional but recommended in production)

Set these in your host panel or systemd unit — **do not** commit secrets to FTP
as world-readable files if you can avoid it.

| Variable | Purpose |
|---|---|
| `DATABASE_URL` | Postgres connection string (persistent multi-user data) |
| `BETTER_AUTH_SECRET` | Random long secret for sessions |
| `BETTER_AUTH_URL` | Public site URL, e.g. `https://your-domain.com` |
| `GROK_AUTH_CLIENT_ID` / `GROK_AUTH_CLIENT_SECRET` | Only if using Grok broker Google/X sign-in on your own deploy |
| `VITE_AUTH_ENABLED` | Set to `false` only to force a shared dev user (not for real sites) |

Email/password sign-in works with the app’s own database once the app is running.

## After deploy — checklist

1. Open your domain; you should see the Dugout landing page.
2. Create an account (email/password).
3. Confirm starter cards appear under **Cards**.
4. Mint a card and check the **Feed**.

## Support note

Pure “FTP only, no Node, shared PHP hosting” cannot run this app. You need a
VPS / dedicated server / Node-capable host with shell or a Node app panel.
