How it works
The path of a sign-up, a sign-in and a query, from your app through the engine to your database, and where each decision is made.
Your app talks to one address per project, https://<ref>.data.sypnia.com (or your own domain when you self-host). Behind it there is one program, the engine, and your Postgres.
- Your app, with
@sypnia/dataor any ORM, sends a publishable key and, once signed in, the user’s access token. - Agents and services sign in with OAuth (key pairs, DPoP, the device flow) or a personal access token.
- Auth checks credentials, keeps sessions, signs tokens and sends e-mails through your provider.
- The Data API turns a URL into one SQL statement and runs it as the caller’s database role.
- Postgres holds everything: your tables, the
sypnia_authschema and the rules that decide who sees which row.
A sign-up, step by step
A query, step by step
sypnia.from('orders').select('id, total') becomes GET /rest/v1/orders?select=id,total. The engine:
- reads the key or token and decides the database role:
anon,authenticatedorservice_role; - opens a transaction in your database, runs
SET LOCAL ROLE authenticatedand stores the token’s claims inrequest.jwt.claims; - runs one SQL statement; your row-level security policies, which call
auth.uid(), keep only the rows this user may see; - commits and returns JSON.
The engine never filters rows itself: Postgres does. That is why the same rules hold whether a request comes from the Data API, from an ORM on your server or from an agent.
Where each decision is made
| Decision | Made by |
|---|---|
| Is this password right, is this link valid, may this client get a token | The engine (Rust) |
| How long a session lives | Your project’s session policy |
| Which rows a user sees or changes | Your database, through row-level security |
| What your app does for a person | Your code, with any ORM or none (Use any ORM) |