# Data model

> The control plane's tables: projects, apps, environments, deploys, builds, releases, variables and domains.

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

For agents: Run control-plane data model in Postgres: apps, environments (current_deploy_id), builds, deploys (immutable, resources, env snapshot ref, use_case_diff), releases (from/to/actor/reason/gradual), env_vars (metadata only; values in SSM Parameter Store), domains (certificate ARN), jobs, queues, job_runs, tokens (hashed), approvals, audit_log; artifacts in S3; prefixed random ids; orgs/projects from the Sypnia account.

The control plane keeps its state in Postgres. Build artifacts live in S3, secrets in AWS Systems Manager Parameter Store, and none of them in the database.

| Table            | Holds                        | Key fields                                                                                                       |
| ---------------- | ---------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| `apps`           | one row per app              | `id`, `project_id`, `name`, `kind`, `framework`, `settings` (the resolved config)                                |
| `environments`   | production, preview, custom  | `app_id`, `name`, `current_deploy_id`, `auto_release`, `protection`                                              |
| `builds`         | each build                   | `id`, `app_id`, `source` (commit or upload), `status`, `started_at`, `finished_at`, `log_ref`                    |
| `deploys`        | each immutable deploy        | `id`, `app_id`, `build_id`, `env_snapshot_ref`, `resources` (ARNs, prefixes, digests), `status`, `use_case_diff` |
| `releases`       | every pointer change         | `environment_id`, `from_deploy_id`, `to_deploy_id`, `actor`, `reason`, `gradual`, `created_at`                   |
| `env_vars`       | names and metadata           | `environment_id`, `name`, `secret`, `build`, `parameter_arn` (the value is in Parameter Store)                   |
| `domains`        | custom domains               | `app_id`, `environment_id`, `domain`, `certificate_arn`, `status`                                                |
| `jobs`, `queues` | declared per app             | `app_id`, `name`, `schedule` or queue settings, AWS resource names                                               |
| `job_runs`       | each run                     | `job_id`, `deploy_id`, `status`, `started_at`, `finished_at`                                                     |
| `tokens`         | deploy tokens                | `app_id`, `environments`, `hash`, `last_used_at`                                                                 |
| `approvals`      | actions waiting for a person | `actor`, `action`, `payload`, `status`                                                                           |
| `audit_log`      | every change                 | `actor`, `action`, `target`, `at`                                                                                |

Identifiers are prefixed (`app_`, `dpl_`, `bld_`, `rel_`) and random. Organizations, members and projects come from the Sypnia account: Run keeps only `project_id` and checks membership on every call.
