# Data model

> The sypnia_design schema, and the files that live in your repository instead.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://design.docs.sypnia.com/architecture/data-model/

For agents: sypnia_design schema: projects (org, slug, repository, branch, guide_version, components_dir), guide_versions (project, version, commit_sha, approved_by, approved_at), proposals (id, project, kind, base_version, reason, changes jsonb, author, author_kind person|agent, status draft|rendering|ready|approved|rejected|merged, decided_by, pr_url), renders (target, state, theme, width, image_ref, expires_at), assets (kind logo|font|image, original_ref, sanitized_ref, licence, uploaded_by), exports (kind, ref), checks (ref, commit_sha, findings jsonb, errors, warnings), api_tokens (scopes, hash), audit (actor, action, at). Repository files are the source of truth for guide, tokens, icons, gallery, screens and components; the schema stores no copy of them beyond commit references.

## In your repository (the source of truth)

| File                                      | Holds                                                                                                             |
| ----------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| `sypnia.toml`, table `[design]`           | guide version, prefix, components folder, framework, waivers (the project's id is the file's top-level `project`) |
| `design/guide.md`, `design/guide.pdf`     | the guide in words, and its export                                                                                |
| `design/tokens.json`, `design/tokens.css` | the values, and the generated CSS                                                                                 |
| `design/icons/`                           | `rules.yaml` and the icons                                                                                        |
| `design/brand/`                           | logo versions, fonts and their licences, generated images                                                         |
| `design/gallery.yaml`                     | pieces, combinations, patterns                                                                                    |
| `design/screens/*.screen.yaml`            | the screens of each case                                                                                          |
| `src/design/`                             | your pieces                                                                                                       |

Every field is on [Design files](https://design.docs.sypnia.com/reference/files).

## In the engine (`sypnia_design`)

| Table            | Holds                     | Key columns                                                                                                    |
| ---------------- | ------------------------- | -------------------------------------------------------------------------------------------------------------- |
| `projects`       | the Design project        | `org_id`, `slug`, `repository`, `branch`, `guide_version`, `components_dir`                                    |
| `guide_versions` | each approved version     | `project_id`, `version`, `commit_sha`, `approved_by`, `approved_at`                                            |
| `proposals`      | each proposal             | `kind`, `base_version`, `reason`, `changes` (jsonb), `author`, `author_kind`, `status`, `decided_by`, `pr_url` |
| `renders`        | each picture              | `target`, `state`, `theme`, `width`, `image_ref`, `expires_at`                                                 |
| `assets`         | uploaded files            | `kind`, `original_ref`, `sanitized_ref`, `licence`, `uploaded_by`                                              |
| `exports`        | PDFs and zips             | `kind`, `ref`, `guide_version`                                                                                 |
| `checks`         | check results             | `ref`, `commit_sha`, `findings` (jsonb), `errors`, `warnings`                                                  |
| `api_tokens`     | API tokens                | `scopes[]`, `hash`, `last_used_at`                                                                             |
| `audit`          | every change and approval | `actor`, `action`, `target`, `at`                                                                              |

Proposal statuses: `draft → rendering → ready → approved → merged`, or `rejected`. Renders expire after 30 days and are made again on demand.
