# Client setup — fresh MySQL (Option A)

Install the CEYLEX Renewables site and CMS from this repository on a **new MySQL 8** database. This path creates an empty schema, then seeds baseline content and an admin user. It does **not** migrate from PostgreSQL or restore a SQL dump.

## Prerequisites

- Node.js 24+ (see `.nvmrc`)
- MySQL 8 with an empty database (for example `ceylex`)
- Permission to create a `.env` file (or set the same variables in your host)

## 1. Get the code

Clone or unpack the delivery, then enter the project directory.

## 2. Configure environment

```bash
cp .env.example .env
```

Edit `.env` and set at least:

| Variable | Required | Notes |
|----------|----------|--------|
| `DATABASE_URL` | Yes | `mysql://USER:PASSWORD@HOST:3306/ceylex` |
| `AUTH_SECRET` | Yes | Long random string used to sign sessions |
| `NEXTAUTH_URL` | Yes | Canonical app URL (`http://localhost:3000` locally, or your production URL) |

Optional:

- `SHADOW_DATABASE_URL` — only needed for interactive `prisma migrate dev`. This guide uses `migrate deploy`, so you can leave it unset.
- `SOURCE_DATABASE_URL` — not needed for this setup (PostgreSQL cutover only; see [README.md](README.md)).

Generate a secret (example):

```bash
openssl rand -base64 32
```

## 3. Install dependencies

```bash
npm install
```

`postinstall` runs `prisma generate` automatically.

## 4. Apply the database schema

```bash
npx prisma migrate deploy
```

This applies the MySQL migration under `prisma/migrations/` (including `20260823120000_init_mysql`). Prefer this over `npm run db:migrate` for client and production installs.

## 5. Seed baseline data

```bash
npm run db:seed
```

Default admin (change immediately after first login):

- **Email:** `admin@ceylexrenewables.com`
- **Password:** `ceylex-admin-2024`

Seed also creates baseline site settings, projects, news, and team members.

## 6. Run the app

### Local development

```bash
npm run dev
```

- Public site: [http://localhost:3000](http://localhost:3000)
- Admin: [http://localhost:3000/admin](http://localhost:3000/admin)

### Production

```bash
npm run build
npm run start
```

`npm run build` already runs `prisma generate`, `prisma migrate deploy`, and `next build`. Ensure `DATABASE_URL`, `AUTH_SECRET`, and `NEXTAUTH_URL` are set in the production environment.

## 7. Verify

- [ ] Home page loads
- [ ] Admin login works with the seed credentials
- [ ] Seeded projects / news appear on the public site
- [ ] Admin password changed after first login


See [README.md](README.md) for those paths and for architecture notes.
