# How it works

> From a git push to a request served by your app, step by step.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://run.docs.sypnia.com/start/how-it-works/

For agents: How Sypnia Run works: build (isolated machine, framework detection, artifacts) → deploy (immutable version with its own address <app>--dpl-<id>.sypnia.app) → release (environment pointer switched at the edge; rollback = move back) → serve (CloudFront → S3 / Lambda / Fargate; logs; traces to Telemetry). Optional [run] table in the project's sypnia.toml. Open source: @sypnia/run CLI and engine; private: console.

Every app goes through the same four moves: **build**, **deploy**, **release**, **serve**. Knowing them explains everything else in these docs.

### 1. Build

Run takes your code (a Git commit, or a folder uploaded by the CLI) and builds it in a clean, isolated machine. It detects the framework, installs dependencies with your lockfile, runs your build command and produces **artifacts**: static files, function bundles or a container image. Nothing from another build or another customer is on that machine.

**You should see:**A build has an id like `bld_8k2…`, its logs, and the artifacts it produced, or the error that stopped it.

### 2. Deploy

The artifacts become a **deploy**: an immutable version of your app with its own address, its configuration snapshot and the AWS resources it needs (a Lambda version, a container image digest, a set of files under its own prefix). A deploy is never edited; a change makes a new deploy.

**You should see:**The deploy answers at its own address, `https://<app>--dpl-<id>.sypnia.app`, before anyone else sees it.

### 3. Release

An **environment** (production, a preview, or one you name, like staging) points to one deploy. Releasing moves that pointer, in one step, at the edge: the old deploy keeps serving until the switch, and requests already in flight finish where they started. A rollback is the same move backwards.

### 4. Serve

Requests reach Amazon CloudFront, which sends static files from S3 and dynamic requests to the deploy's function or container. Logs go to the log store, and, when you connect it, traces go to Sypnia Telemetry with the deploy id on them.

## What you write

Most apps need nothing: Run reads `package.json`, the framework's config or a `Dockerfile`. When you want to be explicit, you add a `[run]` table to `sypnia.toml`, the one configuration file every Sypnia product reads at the root of your repository:

`sypnia.toml`

```toml
format = 1
project = "la-espiga"

[run.apps.laespiga]
kind = "ssr"
framework = "nextjs"
build = { command = "pnpm build", node = "22" }

[run.apps.laespiga.functions.pay]
file = "functions/pay.ts"
path = "/api/pay"
memory = 512

[run.apps.laespiga.jobs.close-day]
schedule = "0 21 * * *"
timezone = "America/Bogota"
run = "jobs/close-day.ts"

[run.apps.laespiga.queues.kitchen]
consumer = "workers/kitchen.ts"
retries = 5
```

[The configuration file](https://run.docs.sypnia.com/config/run-file) lists every field.

## Who does what

| Part                                                  | Runs in                                                     | Open source |
| ----------------------------------------------------- | ----------------------------------------------------------- | ----------- |
| `@sypnia/run`: the CLI, the framework adapters        | your machine or CI                                          | yes         |
| The Run engine: the API, the builder and the deployer | your AWS account **\[Engine]** or Sypnia Cloud **\[Cloud]** | yes         |
| The console at `run.app.sypnia.com`                   | Sypnia Cloud                                                | no          |
| Your app                                              | AWS: S3, CloudFront, Lambda, Fargate, EventBridge, SQS      | it is yours |
