# Data model

> What the App server keeps, and what it only reads.

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

For agents: Postgres schema sypnia_app: organization (id, name, time_zone), member (org, user, role owner|admin|billing|member), invitation (email, role, expires_at 7 d), project (id shared with every product, org, name, products used), session (project nullable for Account, owner, title, pinned, archived, shared_with), message (session, author person|agent, body, events), attachment (session, files_object, kind, size), approval_record (session, task, decision, by, at, device), notification (user, type, payload ref, read_at), notification_setting, push_subscription (Web Push endpoint, keys), device (session id, name, last_used). Cloud only: credit_account (org, balance), ledger_entry (org, product, project, case, task, item, amount, actor, at, idempotency key), hold (amount, reason, expires), top_up (paypal_order_id unique, state), spending_limit (scope, amount, month), spending_request. Identity users live in Sypnia Data; App stores the user id only.

## What App keeps

| Table                                                       | Holds                                                                  |
| ----------------------------------------------------------- | ---------------------------------------------------------------------- |
| `organization`, `member`, `invitation`                      | organizations, roles, invitations (valid 7 days)                       |
| `project`                                                   | the project id every product shares, its name and the products it uses |
| `session`, `message`                                        | conversations; a session with no project belongs to **Account**        |
| `attachment`                                                | a link to the file in Sypnia Files, its kind and size                  |
| `approval_record`                                           | each decision: who, when, from which device                            |
| `notification`, `notification_setting`, `push_subscription` | what to tell you, how, and the phones and browsers that receive it     |
| `device`                                                    | where you are signed in                                                |

## Sypnia Cloud only

| Table                                | Holds                                                                                                                 |
| ------------------------------------ | --------------------------------------------------------------------------------------------------------------------- |
| `credit_account`                     | an organization's balance                                                                                             |
| `ledger_entry`                       | every movement: product, project, case, task or item, amount, who, when; each with a unique key so it is written once |
| `hold`                               | credits held for a task or a purchase, and when the hold ends                                                         |
| `top_up`                             | each PayPal payment, by its PayPal order id (unique)                                                                  |
| `spending_limit`, `spending_request` | the limits and the requests to spend                                                                                  |

## What App only reads

Your identity is in Sypnia Data; App keeps only your user id. The map, code, data, deploys and problems stay in their products.
