# Requirements

What Charter needs before it will run: a Postgres database, a connection URL, and a database role with enough privileges.

Charter is a single binary (or container image) with no language runtime of its own. Almost everything it needs lives in Postgres. Before you [Install](/docs/install/) or deploy to production, you should confirm the checklist below.

## Server checklist

You may run Charter on a Linux or macOS host, or as a container. Confirm each of these on the host or platform where Charter will run:

- A supported Charter build for your platform (Linux or macOS binary, or the published container image). See [Install](/docs/install/).
- PostgreSQL 13 or newer. The test suite and Compose examples use Postgres 17.
- A network path from the Charter process to Postgres on the host and port in `DATABASE_URL`
- Enough file descriptors and memory for the HTTP workers and the connection pool (default pool size is 10)

Charter does not need Redis, a separate queue broker, or a language runtime such as Node or PHP. Background jobs use tables in the same Postgres database.

## Database connection

Every database-backed command except `charter dev` needs `DATABASE_URL`. The value must be a Postgres URL that starts with `postgres://` or `postgresql://`. There is no flag for it, so the URL stays out of shell history and process listings.

```sh
DATABASE_URL=postgres://charter:secret@db.example.com:5432/charter
```

You may add query parameters for managed providers:

- `sslmode=require` when the server expects TLS (common on managed Postgres)
- `sslmode=disable` only for local development when TLS is off

`charter setup` writes a Compose Postgres URL into `.env`. If `DATABASE_URL` is still unset, `charter dev` can derive a matching URL and start Compose Postgres. Production and every other command need an explicit URL. Pool size is `DATABASE_MAX_CONNECTIONS` (default `10`, `charter serve` only). Full list: [Environment variables](/docs/environment-variables/).

> [!WARNING]
> Point `DATABASE_URL` at a database Charter may own. Schema migrations and resource create/delete change tables in that database. Do not share an application database you are not willing to let Charter alter.

## Postgres features Charter uses

Charter relies on these Postgres features. That is why the floor is PostgreSQL 13 and why the app role needs schema `CREATE`:

- `gen_random_uuid()` for primary keys (built into Postgres 13+, no extension install)
- `jsonb` columns and operators for resource records and registry metadata
- GIN indexes on `jsonb`, plus btree expression indexes on individual keys
- `FOR UPDATE SKIP LOCKED` so several workers can share the job queue
- `CREATE TABLE` / `CREATE INDEX` / `DROP TABLE` for registry migrations and for each resource's data table

## Database role privileges

You should give Charter its own login role and database when you can. The role that opens `DATABASE_URL` must migrate the schema and, at runtime, create and drop the per-resource tables that back `/v1`. A superuser works, but you do not need one.

### Recommended setup

As a Postgres admin, you may create a dedicated role and database. Owning the database is the simplest limited setup:

```sql
CREATE ROLE charter LOGIN PASSWORD 'replace-me';
CREATE DATABASE charter OWNER charter;
```

Put that role's credentials in `DATABASE_URL`. The owner can connect, create objects in the default `public` schema, and manage every table it creates. That covers `charter migrate`, startup schema init, resource create/delete, and day-to-day reads and writes.

### Existing database, limited grants

When the database already exists and you cannot make Charter the owner, grant only what Charter uses. Replace `charter` and `public` with your role and schema names:

```sql
GRANT CONNECT ON DATABASE charter TO charter;
GRANT USAGE, CREATE ON SCHEMA public TO charter;
```

`CONNECT` lets the role open a session. `USAGE` on the schema lets it see objects there. `CREATE` on the schema lets it create tables and indexes. Objects the role creates are owned by that role, so it can `SELECT`, `INSERT`, `UPDATE`, `DELETE`, index, and `DROP` them without further grants.

If another role already created Charter's tables, also grant table privileges and prefer transferring ownership so drops and index changes keep working:

```sql
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO charter;
ALTER DEFAULT PRIVILEGES IN SCHEMA public
  GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO charter;
```

Ownership still matters for `DROP TABLE` and for changing indexes. Transfer ownership of Charter's tables to the Charter role, or run migrations and resource DDL as the same role that owns those tables.

### What Charter does not need

You can leave these off the Charter role:

- `SUPERUSER`
- `CREATEDB` and `CREATEROLE`, when the database and role already exist
- `CREATE EXTENSION`, on Postgres 13+ (`gen_random_uuid()` is built in)
- Privileges on other databases or schemas Charter does not use
- `TEMPORARY` / `TEMP` on the database (Charter does not create temporary tables)

> [!INFO]
> Turning on `CHARTER_DISABLE_SCHEMA_INIT` / `--no-schema-init` skips the startup migration pass. It does not remove the need for `CREATE` on the schema. Creating or deleting a resource still creates or drops that resource's data table unless you manage those tables yourself outside Charter.

## Signing key

Off loopback, or when `APP_ENV` is production, Charter also needs `COOKIE_SIGNING_KEY` (at least 64 bytes; `openssl rand -base64 64`). Without it the server will not start. Details and the development fallback: [Environment variables](/docs/environment-variables/).

## Next steps

- Install the binary or image: [Install](/docs/install/)
- Local project and first API: [Quickstart](/docs/quickstart/)
- Compose or a Virtual Private Server (VPS): [Deploy with Docker](/docs/docker/), [Install on Ubuntu](/docs/install-on-ubuntu/)
