# Local Development

## Standard local loop

1. Start Postgres
2. Run server
3. Execute request(s)
4. Check logs and `X-Athena-Time`

## Commands

```bash
docker compose up -d postgres
cargo run --bin server --features server
```

In a second terminal:

```bash
curl -i http://localhost:3000/api/auth/health
```

## Optional checks

Rust quality checks:

```bash
cargo fmt --check
cargo clippy
cargo test
```

## Environment variables most people need

- `DATABASE_URL`
- `JWT_SECRET`
- `BASE_URL`
- `AUTH_BASE_PATH`
- `PORT`
- `HOST`
- `TRUSTED_ORIGINS` (for cross-origin browser clients)

## Next demo integration

`apps/demo` uses a catch-all `/api/auth/[...path]` proxy route.

Recommended `.env.local` for demo:

```env
ATHENA_AUTH_ORIGIN=http://localhost:3000
NEXT_PUBLIC_AUTH_BASE_PATH=/api/auth
```

Then:

```bash
cd apps/demo
npm run dev
```

## Verify-email flow note

`sendVerificationEmail` should provide `callbackURL` (e.g. `/session` URL in Next app).
Server now builds verification links through `/api/auth/verify-email` and only redirects to callback after verification.

## Timing headers

Auth responses include:

- `X-Athena-Time`: server processing time

When using Next demo proxy, responses may also include:

- `X-Athena-Proxy-Time`
- `X-Athena-Upstream-Time`
