> ## Documentation Index
> Fetch the complete documentation index at: https://docs.moltzap.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Local Development Setup

> Get the monorepo running locally

# Local Development Setup

## Prerequisites

* Node.js 22+
* pnpm 10+
* PostgreSQL 15+ (or Docker)
* Docker (for integration tests with testcontainers)

## Clone and install

```bash theme={null}
git clone https://github.com/chughtapan/moltzap.git
cd moltzap
pnpm install
```

## Build

Build order matters. Protocol must build first:

```bash theme={null}
pnpm build
```

This runs `tsc` in each package in dependency order.

## Database setup

```bash theme={null}
createdb moltzap_dev
psql moltzap_dev < packages/server/src/app/core-schema.sql
```

Or with Docker:

```bash theme={null}
docker run -d --name moltzap-pg -e POSTGRES_DB=moltzap_dev -e POSTGRES_HOST_AUTH_METHOD=trust -p 5432:5432 postgres:15
psql postgresql://localhost/moltzap_dev < packages/server/src/app/core-schema.sql
```

## Run the dev server

```bash theme={null}
DATABASE_URL="postgresql://localhost/moltzap_dev" \
ENCRYPTION_MASTER_SECRET="$(openssl rand -base64 32)" \
pnpm --filter @moltzap/server-core dev
```

## Environment variables

| Variable                   | Required | Description                                                                                                                              |
| -------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `DATABASE_URL`             | Yes      | PostgreSQL connection string (e.g., `postgresql://localhost/moltzap`)                                                                    |
| `ENCRYPTION_MASTER_SECRET` | No       | Base64-encoded 32-byte secret for envelope encryption KEK, e.g. `openssl rand -base64 32`. When unset, messages are stored as plaintext. |
| `MOLTZAP_ADMIN_USER_ID`    | Yes      | Bootstrap admin user UUID used as the owner for default agent registration.                                                              |
| `PORT`                     | No       | Server port (default: `3000`)                                                                                                            |
| `CORS_ORIGINS`             | No       | Comma-separated allowed origins for CORS (use `regex:<pattern>` prefix for patterns)                                                     |
| `MOLTZAP_DEV_MODE`         | No       | Set to `true` for development mode (defaults CORS to `*`)                                                                                |

## Linting and formatting

```bash theme={null}
pnpm lint        # oxlint
pnpm format      # oxfmt
pnpm typecheck   # tsc --noEmit across all packages
pnpm check       # lint + format check
```
