> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.adid.dev/llms.txt.
> For full documentation content, see https://docs.adid.dev/llms-full.txt.

# Database ER (core entities)

**Used in:** §9.x reference for backend devs, §14.5 Migrations
**Audience:** Backend Developer, DevOps
**IA ID:** extra (required by user inst.)

```mermaid
erDiagram
  USERS ||--o{ DIDS : owns
  USERS ||--o{ SESSIONS : has
  USERS ||--o{ AGENTS : operates
  USERS {
    uuid id PK
    text email UK
    text name
    text role
    timestamptz created_at
  }
  DIDS ||--o{ CREDENTIALS : "subjectOf"
  DIDS ||--o{ ZK_PROOFS : "proverOf"
  DIDS ||--o{ AGENTS : "agent_did"
  DIDS {
    text did PK
    uuid user_id FK
    text method
    text public_key
    text status
    timestamptz created_at
    timestamptz updated_at
    text tx_hash
  }
  SCHEMAS ||--o{ CREDENTIALS : "validates"
  SCHEMAS {
    uuid id PK
    text name
    text version
    jsonb json_schema
    text issuer_did
  }
  CREDENTIALS ||--o{ REVOCATIONS : "may_be"
  CREDENTIALS {
    uuid id PK
    text issuer_did FK
    text subject_did FK
    uuid schema_id FK
    jsonb claims
    text proof_jwt
    text status_list_id
    int status_list_idx
    timestamptz issued_at
  }
  REVOCATIONS {
    uuid id PK
    uuid credential_id FK
    text reason
    timestamptz revoked_at
  }
  AGENTS {
    text did PK
    uuid operator_id FK
    int autonomy_level
    int trust_score
    text status
  }
  ZK_PROOFS {
    uuid id PK
    text prover_did FK
    uuid credential_id FK
    text predicate
    bytea proof
    text proof_hash
    boolean revoked
    timestamptz created_at
  }
  SESSIONS {
    uuid id PK
    uuid user_id FK
    text refresh_jti
    timestamptz expires_at
  }
```

**Reading guide:** The schema is illustrative — column names match repository code conventions but exact migrations should be confirmed against `migrations/*.sql` (see open question 4).

***