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

# Adapter

> Complete field reference for adapter definition files.

Each file in `app/adapters/` defines one adapter — a named binding between Hyperterse and your database. Adapter files are YAML documents with a fixed schema.

## Full schema

```yaml app/adapters/primary-db.terse theme={null}
name: primary-db
connector: postgres
connection_string: 'postgresql://user:pass@host:5432/db'
options:
  sslmode: require
  max_connections: '10'
```

## Field reference

<ParamField body="name" type="string">
  Adapter identifier, referenced by tools via `use`. Must be unique across all adapters. Must match `^[a-zA-Z][a-zA-Z0-9_-]*$`.

  Default: filename without the `.terse` extension (e.g., `primary-db` from `primary-db.terse`).
</ParamField>

<ParamField body="connector" type="string" required>
  Connector type. Determines which database driver to use.

  Allowed values: `postgres`, `mysql`, `mongodb`, `redis`, `sqlite`
</ParamField>

<ParamField body="connection_string" type="string" required>
  Database connection URI. Supports `{{ env.VAR }}` placeholders for secrets.

  ```yaml theme={null}
  connection_string: 'postgresql://{{ env.DB_USER }}:{{ env.DB_PASS }}@{{ env.DB_HOST }}:5432/{{ env.DB_NAME }}'
  ```
</ParamField>

<ParamField body="options" type="object">
  Driver-specific key-value options. All values must be strings.

  ```yaml theme={null}
  options:
    sslmode: 'require'
    connect_timeout: '10'
  ```
</ParamField>

## Connection string formats

<Tabs>
  <Tab title="PostgreSQL">
    ```
    postgresql://user:password@host:port/database?param=value
    ```

    Standard PostgreSQL DSN. Supports all driver parameters in the query string or `options` map.

    Common options:

    | Key                | Example                             | Description             |
    | ------------------ | ----------------------------------- | ----------------------- |
    | `sslmode`          | `require`, `disable`, `verify-full` | SSL mode                |
    | `connect_timeout`  | `"10"`                              | Timeout in seconds      |
    | `application_name` | `"hyperterse"`                      | Name reported to server |
  </Tab>

  <Tab title="MySQL">
    ```
    user:password@tcp(host:port)/database?param=value
    ```

    Standard MySQL DSN. Options are typically passed as query parameters in the connection string.
  </Tab>

  <Tab title="MongoDB">
    ```
    mongodb://user:password@host:port/database
    mongodb+srv://user:password@cluster.example.com/database
    ```

    Standard MongoDB URI. Supports replica sets and SRV records. Options are embedded in the connection string.
  </Tab>

  <Tab title="Redis">
    ```
    redis://user:password@host:port/db_number
    ```

    Standard Redis URI. Database number as path component. TLS, password, and other options are embedded in the URI.
  </Tab>

  <Tab title="SQLite">
    ```
    # local
    :memory:
    file:./data/app.db
    /absolute/path/to/app.db

    # remote (libSQL / Turso)
    libsql://db-name-org.turso.io
    https://db-name-org.turso.io
    ```

    SQLite supports local files (or `:memory:`) and remote libSQL/Turso databases.
    Use `libsql://`, `https://`, or `http://` for remote; WebSocket URLs are not supported.

    `options` are appended as query parameters. Example:

    ```yaml theme={null}
    connector: sqlite
    connection_string: 'libsql://db-name-org.turso.io'
    options:
      authToken: '{{ env.TURSO_AUTH_TOKEN }}'
      sync_interval: '5s'
    ```
  </Tab>
</Tabs>

## Lifecycle

<Steps>
  <Step title="Discovery">
    Hyperterse loads adapter definitions from `app/adapters/*.terse`.
  </Step>

  <Step title="Validation">
    Connector type, connection string presence, and name uniqueness are verified
    at compile time.
  </Step>

  <Step title="Initialization">
    At startup, all referenced adapters initialize their connections in
    parallel.
  </Step>

  <Step title="Execution">
    Tools resolve adapters by name when executing statements.
  </Step>

  <Step title="Shutdown">
    All connectors close concurrently on termination.
  </Step>
</Steps>

<Warning>
  If any adapter fails to connect during initialization, the server does not
  start.
</Warning>

## JSON Schema

Editor validation: `schema/adapter.terse.schema.json`. Associate with `**/adapters/*.terse`. See [Configuration schemas](/reference/configuration-schemas).
