# Data model

Live schema reference. Open the Supabase dashboard → Database for the authoritative view.

## Core tables

| Table          | Purpose                                                |
| -------------- | ------------------------------------------------------ |
| `profiles`     | Per-user profile, created by `handle_new_user` trigger |
| `user_roles`   | Role assignments (`requester` / `reviewer` / `admin`)  |
| `wallet_links` | Maps Solana wallet address → Supabase user id          |
| `siws_nonces`  | Short-lived SIWS nonces (service-role only)            |
| `projects`     | Review project + routing config                        |
| `items`        | Items pending or completed review                      |
| `decisions`    | Reviewer actions on items                              |
| `learnings`    | Captured corrections for training                      |
| `api_keys`     | Per-project public API keys                            |
| `webhooks`     | Outbound webhook configs + secrets                     |

## RLS

All public tables have RLS enabled. Access is gated through the `has_role(user_id, role)` security-definer function — never store roles on `profiles`.

## Triggers

* `handle_new_user` on `auth.users` — inserts a `profiles` row, assigns default `requester` role, sets wallet-derived display name when the email matches `*@wallet.loopdesk.local`.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hitl-01.gitbook.io/hitl-docs/architecture/schema.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
