# INSTALL — Mastermind MVP

## Prerequisites
- Docker + Docker Compose (recommended)
- A stable hostname/IP you can reach (LAN or Tailscale)

## Configure
```bash
cd /path/to/mastermind-mvp
cp .env.example .env
```

Edit `.env`:
- `SESSION_SECRET` — set to a long random value
- `BASE_URL` — the URL you use to reach the app (Tailscale IP recommended)
- `BOOTSTRAP_OWNER_EMAIL` / `BOOTSTRAP_OWNER_PASSWORD` — one-time local owner login created only when no local identities exist
  - Defaults in `.env.example` are set for local MVP use: `owner@local` / `owner`

OAuth is optional for now:
- `GOOGLE_CLIENT_ID/GOOGLE_CLIENT_SECRET`
- `MICROSOFT_CLIENT_ID/MICROSOFT_CLIENT_SECRET`

## Start (Docker Compose)
```bash
docker compose up -d --build
```

App:
- http://<BASE_URL_HOST>:3005/login
- With the default `.env.example`, that is `http://localhost:3005/login`

## First login (important)
On first run, if no local identities exist, the app creates the bootstrap local owner from:
- `BOOTSTRAP_OWNER_EMAIL`
- `BOOTSTRAP_OWNER_PASSWORD`

Immediately change that password:
- http://<host>:3005/account/password

## Create your first project
- http://<host>:3005/projects

## Import email (until OAuth is connected)
Export emails as `.eml` and upload:
- http://<host>:3005/inbox

## Enable connector placeholders
- http://<host>:3005/admin/email

Connectors will show **Configured: no** until OAuth client credentials are added.

## OAuth callbacks (when you’re ready)
These are the callback URLs the app expects:
- Google: `BASE_URL/auth/google/callback`
- Microsoft: `BASE_URL/auth/microsoft/callback`

Set `BASE_URL` correctly before authorizing.

## Test
```bash
npm test
```

## Direct Node.js run (no Docker, memory DB)
Install dependencies:
```bash
npm ci --prefix web
npm ci --prefix worker
```

Terminal 1:
```bash
cd /path/to/mastermind-mvp
export DATABASE_URL=memory://local
export SESSION_SECRET='replace-with-a-long-random-string'
export BASE_URL='http://localhost:3005'
export BOOTSTRAP_OWNER_EMAIL='owner@local'
export BOOTSTRAP_OWNER_PASSWORD='ChangeMe12345'
npm run start:web
```

Terminal 2:
```bash
cd /path/to/mastermind-mvp
export DATABASE_URL=memory://local
npm run start:worker
```
