# Components

> The engine's modules, what each one owns, and the services and libraries around them.

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

For agents: Engine modules (Rust crates): core (configuration, project registry: host → project → database, per-project connection pools, the AuthContext that turns a key/token/PAT/DPoP proof into a principal and a database role, envelope encryption, rate limits, audit, error shape), auth (/auth/v1 users and /auth/v1/oauth machines), mail (SES, SMTP, Resend, Postmark; templates), rest (Data API, schema cache), sql (query, transactions, migrations, schema JSON), mcp (the MCP server: tools, resources, prompt, account and project tokens), install (SQL migrations of the engine's own schemas and roles), server (HTTP router by host, Lambda adapter, CLI). Around it: @sypnia/data (TypeScript; subpaths /client, /server), and in Sypnia Cloud the console and the Cloud API.

## The engine's modules

| Module    | Owns                                                                                                                                                                                                                                                                                                                                           |
| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `core`    | configuration; the **project registry** (which host is which project, and its database); a small connection pool per project; the **auth context**: turning an API key, an access token, a PAT or a DPoP proof into _who is calling_ and _which database role_; encryption of keys at rest; rate limits; the audit writer; the one error shape |
| `auth`    | everything at `/auth/v1`: users, sessions, tokens, e-mails, providers, admin; and `/auth/v1/oauth`: clients, the token endpoint, device flow, DPoP, dynamic registration, metadata                                                                                                                                                             |
| `mail`    | e-mail providers (Amazon SES, SMTP, Resend, Postmark) and templates                                                                                                                                                                                                                                                                            |
| `rest`    | the Data API: parsing the PostgREST syntax, building one SQL statement, the schema cache                                                                                                                                                                                                                                                       |
| `sql`     | the SQL endpoint, SQL transactions, migrations and the schema as JSON                                                                                                                                                                                                                                                                          |
| `mcp`     | the [MCP server](https://data.docs.sypnia.com/machines/mcp): its tools call the engine's own routes in-process, with the caller's rights                                                                                                                                                                                                       |
| `install` | the SQL that creates the engine's schemas, tables, functions and roles in a database, versioned                                                                                                                                                                                                                                                |
| `server`  | the binary: routing by host, the HTTP server, the AWS Lambda adapter, and the [`sypnia-data` commands](https://data.docs.sypnia.com/self-hosting/configuration#the-engines-commands)                                                                                                                                                           |

Built with `tokio` (async runtime), `axum` (HTTP), `sqlx` (Postgres), `ed25519-dalek` and `p256` (tokens, client assertions and DPoP proofs, without a JWT library), `argon2` (passwords), `lettre` (SMTP) and a small SigV4 client for AWS (SES, KMS, SSM) instead of the AWS SDK, so the binary stays small.

## Around the engine

| Piece                      | What                                                                                                                                                                                                                                     | Open source |
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
| `@sypnia/data`             | one npm package: `/client` (auth and data in apps), `/server` (direct Postgres, admin, machines) and the CLI `npx @sypnia/data` (login, init, pull, migrate). No ORM: use any ([Use any ORM](https://data.docs.sypnia.com/data/any-orm)) | yes         |
| Your Postgres              | all the state                                                                                                                                                                                                                            | it is yours |
| E-mail provider            | sends auth e-mails                                                                                                                                                                                                                       | your choice |
| Google, GitHub             | provider sign-in                                                                                                                                                                                                                         | —           |
| The console **\[Cloud]**   | the web app at `data.app.sypnia.com`                                                                                                                                                                                                     | no          |
| The Cloud API **\[Cloud]** | organizations, projects, managed databases, at `data.api.sypnia.com`                                                                                                                                                                     | no          |

The console and the Cloud API are clients of the engine, like your app: they use the same public endpoints and add no logic to it.
