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

# Deploy Self-Hosted

> Deploy the v2-agent-state edge function to your own Supabase project.

## Overview

The sovseal edge replication backend — `v2-agent-state` — is open-source, Deno + Hono, and self-hostable on **your own Supabase project**. There is no separate server process to run and no additional service to operate: the function *is* the backend.

<Note>
  **There is no Docker Compose stack, no local dashboard server, and no LLM API key requirement.** Embeddings run on-device inside the MCP server and the extension — the edge function only ever stores and serves ciphertext. If you've seen documentation describing a `server/` directory, a `make up` command, or an `OPENAI_API_KEY` secret for this deployment, that describes a different project's architecture and does not apply here.
</Note>

## Prerequisites

* **Supabase CLI** installed locally (`brew install supabase/tap/supabase` on Mac).
* A **Supabase project** created in the Supabase dashboard.
* **PostgreSQL 15+** (Standard Supabase Postgres instance — no vector extensions or extra plugins required).

## Step 1: Link your project

```bash theme={null}
supabase login
supabase link --project-ref your-project-ref
```

## Step 2: Apply database migrations

Migrations are plain SQL files under `supabase/migrations/`, applied in order:

```bash theme={null}
supabase db push
```

This creates `agent_state_snapshots`, the `sovseal-rom` storage bucket, and the Row-Level Security policies that scope every row to its owning account.

## Step 3: Deploy the edge function

```bash theme={null}
supabase functions deploy v2-agent-state --project-ref your-project-ref
```

Supabase automatically provisions `SUPABASE_URL` and `SUPABASE_SERVICE_ROLE_KEY` as function secrets — these are the only two environment values the function reads at startup. You do not need to set them yourself.

## Step 4: Point your SDK at it

```typescript theme={null}
import { AgentStateClient } from "@sovseal/sdk";

const client = new AgentStateClient({
  endpoint: "https://your-project-ref.supabase.co/functions/v1/v2-agent-state",
  apiKey: "your-api-key",
});

const lineageHistory = await client.lineage({ agentId: "my-agent-id-hash" });
console.log("Self-hosted connection status: OK", lineageHistory);
```

That's the entire deployment. See [Configuration](/self-hosted/configuration) for the SDK-level environment variables that are real, and [Bring Your Own Storage](/self-hosted/bring-your-own-storage) if you want to swap the storage bucket for something other than Supabase Storage.
