Skip to content

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.

Applies to EngineCloud
View as Markdown
On this page
  1. A sign-up, step by step
  2. Your app calls sign-up
  3. The engine creates the user and sends the e-mail
  4. The person opens the link
  5. Your app holds a session
  6. A query, step by step
  7. 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.

Figure. The parts of Sypnia Data. Apps, agents and the console call the engine; the engine is one Rust binary with five modules; everything it keeps lives in your Postgres.
  1. Your app, with @sypnia/data or any ORM, sends a publishable key and, once signed in, the user’s access token.
  2. Agents and services sign in with OAuth (key pairs, DPoP, the device flow) or a personal access token.
  3. Auth checks credentials, keeps sessions, signs tokens and sends e-mails through your provider.
  4. The Data API turns a URL into one SQL statement and runs it as the caller’s database role.
  5. Postgres holds everything: your tables, the sypnia_auth schema and the rules that decide who sees which row.

A sign-up, step by step

  1. Your app calls sign-up

    sypnia.auth.signUp({ email }) sends POST /auth/v1/signup with the publishable key. The engine checks the rate limits and, if you turned it on, the CAPTCHA.

  2. The engine creates the user and sends the e-mail

    A row in sypnia_auth.users, unconfirmed. A one-time token, stored only as a hash, goes in an e-mail through the project’s e-mail provider: a link and a 6-digit code.

  3. GET /auth/v1/verify checks the token, confirms the e-mail and redirects to your app with a session in the address fragment. Without a password yet, your app shows «create your password».

  4. Your app holds a session

    An access token (a JWT signed with the project’s Ed25519 key, one hour by default) and a refresh token (rotated on every use). The SDK renews the access token a minute before it expires.

A query, step by step

sypnia.from('orders').select('id, total') becomes GET /rest/v1/orders?select=id,total. The engine:

  1. reads the key or token and decides the database role: anon, authenticated or service_role;
  2. opens a transaction in your database, runs SET LOCAL ROLE authenticated and stores the token’s claims in request.jwt.claims;
  3. runs one SQL statement; your row-level security policies, which call auth.uid(), keep only the rows this user may see;
  4. 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

DecisionMade by
Is this password right, is this link valid, may this client get a tokenThe engine (Rust)
How long a session livesYour project’s session policy
Which rows a user sees or changesYour database, through row-level security
What your app does for a personYour code, with any ORM or none (Use any ORM)
  1. A sign-up, step by step
  2. Your app calls sign-up
  3. The engine creates the user and sends the e-mail
  4. The person opens the link
  5. Your app holds a session
  6. A query, step by step
  7. Where each decision is made

    Search pages, sections and terms