# Deployment shapes

> How the same Sypnia binary runs as three AWS functions or as one long-running process, what the AWS template creates, what each shape costs with the arithmetic shown, and the pieces you can swap, seen from the code.

Applies to: the Sypnia engine (open source, self-hosted). Status: at launch.  
Source: https://docs.sypnia.com/architecture/deployment-shapes/

The engine is one program, `sypnia`. It can be started in two ways, and it does the same work in both:

- **as functions on AWS**, woken by requests, a queue and a schedule;
- **as one long-running process**, in Docker or on any server.

This page shows what differs between the two, what is the same, what each costs, and where the engine's edges are: the four pieces you can replace.

> **Note: About the code and the numbers**
>
> The Rust here is a design excerpt; the repository opens at launch. Costs are estimates built from published prices and from volumes measured on the system this engine comes from. Every line shows its arithmetic so you can redo it with your own numbers and today's prices.

## One engine, two ways to wake it

**Figure (diagram not drawn yet)**: The same engine in both shapes. On AWS a queue stands where the in-memory buffer is; nothing else differs.

It will show: DIAGRAM IN THREE COLUMNS. CENTRE COLUMN: one tall rounded box titled «Engine (the same code)», the lit element, containing five stacked inner tiles with exact labels: «Ingest», «Fast path», «Roll-up», «The agent · Alerts», «API · MCP server · Console». LEFT COLUMN titled «On AWS: three functions»: three boxes stacked, each with a small trigger icon on its left edge and exact labels: box «function: ingest» with trigger «HTTPS, through the address»; box «function: worker» with three triggers listed «queue (10 s window)», «schedule: every minute», «itself, for agent jobs»; box «function: api» with trigger «HTTPS, through the address». Between «function: ingest» and «function: worker» a small queue symbol labelled «intake queue». Arrows from each left box to the inner tiles it runs: ingest → «Ingest»; worker → «Fast path», «Roll-up», «The agent · Alerts»; api → «API · MCP server · Console». RIGHT COLUMN titled «On a server: one process»: one box «sypnia serve» containing four small task tiles: «HTTP server», «buffer, flushed every 2 s», «worker loop, every 30 s», «cache refresh, every 60 s»; arrows from the right box to the inner tiles: HTTP server → «Ingest» and «API · MCP server · Console»; buffer → «Ingest»; worker loop → «Fast path», «Roll-up», «The agent · Alerts». BOTTOM, spanning all three columns, two shared nodes: «Bucket» and «Postgres», with the caption line «the same bucket layout and the same tables in both shapes: you can move from one to the other». Numbered callouts: (1) on the intake queue, (2) on the buffer tile, (3) on the Engine box.

|                          | AWS functions                                        | One process                                    |
| ------------------------ | ---------------------------------------------------- | ---------------------------------------------- |
| Started by               | The template                                         | `sypnia serve`                                 |
| Ingest's buffer (1) (2)  | A queue: ingest sends, the worker writes the segment | Memory: flushed every 2 s                      |
| The fast path runs       | When the queue delivers, and every minute            | When a segment lands, and every 30 s           |
| The roll-up runs         | On the minute tick, when 5 minutes have passed       | In the worker loop, when 5 minutes have passed |
| Scales by                | More copies of a function, by itself                 | More processes with `--role`, by you           |
| Idle cost                | Almost nothing                                       | The server                                     |
| Bucket layout and tables | The same                                             | The same                                       |

Both start in the same `main`. Notice that there is one `Engine::connect` and that everything after it only decides what wakes the engine up.

`crates/sypnia/src/main.rs`

```rust
#[tokio::main]
async fn main() -> ExitCode {
    let config = match Config::from_env_and_file() {
        Ok(config) => Arc::new(config),
        Err(error) => return fail(3, &error), // a missing required setting names itself
    };
    // Bucket, Postgres, the AI provider (or none), the alert sinks. Built once, shared by everything.
    let engine = match Engine::connect(config.clone()).await {
        Ok(engine) => Arc::new(engine),
        Err(error) => return fail(4, &error),
    };

    // Inside AWS Lambda the runtime sets this variable and there is no command line.
    if std::env::var_os("AWS_LAMBDA_RUNTIME_API").is_some() {
        return exit(lambda::run(engine, config.role).await);
    }

    match Cli::parse().command {
        Command::Serve(args) => exit(serve::run(engine, args).await),       // the long-running process
        Command::Aggregate(args) => exit(aggregate::run(engine, args).await), // one pass, then exit
        Command::Migrate(args) => exit(migrate::run(engine, args).await),
        Command::Doctor => exit(doctor::run(engine).await),
        other => exit(admin::run(engine, other).await), // project, key, token, sourcemaps, problems
    }
}
```

## As AWS functions

The template runs one function per role, the same three roles `sypnia serve --role` accepts.

**Figure (diagram not drawn yet)**: What the template creates: one address, three functions, one queue with its dead-letter queue, one schedule and a bucket. Postgres is yours to bring or to let the template create.

It will show: ARCHITECTURE DIAGRAM of what the AWS template creates, inside a large frame labelled «Your AWS account · one region». Left edge outside the frame: «Your app (SDK)» and, below it, «You · your coding agent». Inside the frame, left to right: a node «Address · https\://sypnia.example.com» that receives both and splits them («/v1/ingest/\*, /v1/otlp/\*» to ingest, «everything else» to api); a box «ingest» (tag «256 MB · 10 s · arm64»); a queue symbol «intake queue» with a smaller queue under it «dead-letter queue»; a box «worker» (tag «1,024 MB · 15 min · arm64»), the lit element; above the worker one clock symbol labelled «schedule: every minute» with an arrow down into the worker and a small note «also starts the daily job at 02:30 UTC and the weekly one on Monday 07:00 UTC»; a curved arrow from the worker back to itself labelled «agent jobs (async)». To the right of the worker, two storage nodes stacked: «Bucket» (tag «private · every key starts with a project id») and «Postgres» (tag «yours, or created by the template»). Bottom row inside the frame: a box «api» (tag «512 MB · 30 s · arm64») with the sub-label «API · MCP server · Console». ARROWS with labels: Your app (SDK) → ingest «events, replay chunks, OTLP»; ingest → intake queue «validated batches»; ingest → Bucket «replay chunks, snapshots, large batches»; intake queue → worker «up to 10 s of messages»; intake queue ⇢ dead-letter queue (dashed) «after 5 failed deliveries»; worker → Bucket «segments, session files, Parquet»; worker → Postgres «problems, numbers, ledger»; You → api; api → Postgres «reads»; api → Bucket «signed links». Outside the frame on the right, two dashed boxes: «AI provider (yours)» with an arrow from the worker labelled «the agent, if configured», and «Your webhook» with an arrow from the worker labelled «alerts». Small padlock tags on three arrows naming the permission: on ingest → Bucket «put only», on api → Bucket «read + sign», on worker → Bucket «read and write». Numbered callouts: (1) ingest, (2) intake queue, (3) worker, (4) api, (5) the schedule, (6) the address.

| Function (role)  | Woken by                                             | Does                                                                                                                                                                                                                                        | Memory, time limit                 |
| ---------------- | ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- |
| **`ingest`** (1) | The address (6), for `/v1/ingest/*` and `/v1/otlp/*` | The seven gates, then sends the validated batch to the queue. Writes replay chunks, snapshots and batches over 192 KiB straight to the Bucket                                                                                               | 256 MB, 10 s, at most 40 copies    |
| **`worker`** (3) | The intake queue (2): up to 10 seconds of messages   | Writes the segments, adds the ledger rows, runs the fast path on them at once                                                                                                                                                               | 1,024 MB, 15 min, at most 2 copies |
|                  | The schedule, every minute (5)                       | One pass: the fast path's leftovers and held failures, alerts past their time, uptime checks, webhook retries, and the roll-up when 5 minutes have passed                                                                                   |                                    |
|                  | Itself, asynchronously                               | One agent job: symbolicate, analyse, release the alert. And the two long jobs the pass starts when they are due: the daily one at 02:30 UTC (Parquet, retention, next months' partitions) and the weekly suggestions on Monday at 07:00 UTC |                                    |
| **`api`** (4)    | The address (6), for everything else                 | The API, the MCP server at `/mcp`, the Console at `/console`                                                                                                                                                                                | 512 MB, 30 s, at most 20 copies    |

The worker tells its wake-ups apart by the shape of the event. Notice that the queue case and the one-process buffer end in the same two calls: write segments, scan them.

`crates/sypnia/src/lambda.rs`

```rust
/// Everything that can wake the worker function.
#[derive(Deserialize)]
#[serde(untagged)]
enum WorkerEvent {
    Queue(SqsEvent),       // { "Records": [...] }: batches from the ingest function
    Job { job: Job },      // { "job": "pass" }: a schedule, or the worker calling itself
}

#[derive(Deserialize)]
#[serde(rename_all = "snake_case")]
enum Job {
    Pass,
    Daily,
    Suggestions,
    Agent { problem: ProblemId },
}

async fn worker_event(engine: &Engine, event: WorkerEvent) -> Result<(), EngineError> {
    match event {
        WorkerEvent::Queue(batch) => {
            // The same two steps the in-memory buffer ends with.
            let segments = intake::write_segments(engine, batch.into_lines()?).await?;
            fast_path::scan(engine, &segments).await?;
        }
        WorkerEvent::Job { job: Job::Pass } => { engine.pass().await?; }
        WorkerEvent::Job { job: Job::Daily } => daily::run(engine).await?,
        WorkerEvent::Job { job: Job::Suggestions } => suggestions::run(engine).await?,
        WorkerEvent::Job { job: Job::Agent { problem } } => agent::run_job(engine, &problem).await?,
    }
    Ok(()) // an error makes the queue deliver again; every step is safe to repeat
}

pub async fn run(engine: Arc<Engine>, role: Role) -> Result<(), lambda_runtime::Error> {
    match role {
        Role::Ingest => lambda_http::run(ingest::router(engine)).await, // the same axum router as `serve`
        Role::Api => lambda_http::run(api::router(engine)).await,
        Role::Worker | Role::All => {
            lambda_runtime::run(service_fn(move |event: LambdaEvent<WorkerEvent>| {
                let engine = engine.clone();
                async move { worker_event(&engine, event.payload).await }
            }))
            .await
        }
    }
}
```

### Why a queue, and only one

The queue (2) exists for one reason: a function has no memory between requests, so it cannot group batches into segments. The queue is that memory. It also wakes the worker the moment there is something to scan, which is why the AWS shape creates a problem faster than its one-minute schedule would suggest.

There is one queue and not four. Agent jobs, alert releases and webhook retries are rows in Postgres with a time on them; the minute tick picks up whatever a direct call missed. The alternative, a queue per kind of work, would be three more things to create, watch and pay for, to move a few rows a minute.

A message that fails five deliveries goes to the dead-letter queue and raises an alarm. Nothing in the engine reads it by itself: a batch that cannot be written five times is a bug to look at, and `sypnia aggregate` can replay it.

### What the template creates

| Resource                                   | Notes                                                                                                                                                                                      |
| ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| A private bucket                           | No public access. One lifecycle rule, for unfinished uploads. Retention is the engine's daily job                                                                                          |
| The intake queue and its dead-letter queue | Messages kept 4 days; 5 deliveries before the dead-letter queue                                                                                                                            |
| Three functions, arm64, with their roles   | `ingest` may send to the queue and put objects; `api` may read objects and sign links; `worker` may read and write the bucket and call itself                                              |
| One address                                | A content-delivery distribution in front of the two HTTP functions, so the engine has one base URL. It caches nothing but the SDK file. CORS is answered by the engine, not by the address |
| One schedule                               | Every minute. The daily and weekly jobs are started by the pass when they are due, so there is one schedule to watch, not three                                                            |
| Log groups                                 | Kept 30 days                                                                                                                                                                               |
| Two alarms                                 | Messages in the dead-letter queue; the worker failing                                                                                                                                      |
| Postgres, optional                         | A small instance, or none if you pass `SYPNIA_DATABASE_URL`                                                                                                                                |

It does not create a load balancer, a container cluster, a cache, a stream or a search service. The step-by-step guide is [Deploy on AWS](https://docs.sypnia.com/self-hosting/deploy-aws).

### Cold starts, limits and connections

- **Cold starts.** The binary is native code with no runtime to boot and nothing to download. Budget: 300 ms for a cold function to answer its first request, most of it opening the connection to Postgres. For comparison, measured on the system this comes from: 0.4 s for its aggregator to start, and then a 50 MB extension download on every cold start, which this design does not have.
- **The 6 MB answer.** A function cannot answer more than 6 MB. The same rules as there: a replay is delivered as signed links to its chunks, never through the function; a session's detail has a budget of 4 MB with a fixed order of what to leave out.
- **Connections to Postgres.** Each copy of a function holds its own. `ingest` holds at most one and uses it only to fill its cache; `api` at most two; a `worker` one per project it is rolling plus one. Put a connection pooler in front of Postgres when many copies run: the system this comes from exhausted its pooler once, with every copy of a request-serving function opening its own pool.
- **The ingest cache.** A cold `ingest` function asks Postgres for a key the first time it sees it, then keeps it for 60 seconds. A warm one never asks.

> **Note: Sypnia Cloud**
>
> **\[Cloud]** Sypnia Cloud runs this shape in `us-east-1`, with the same template. Around it is the private part that the engine does not have: accounts and organizations, billing, the app, e-mail, the GitHub App and the managed model.

## What it costs on AWS

Two example projects. **Small** is the size measured on the system this engine comes from. **Medium** is ten times that.

| Per month                                             | Small                     | Medium     |
| ----------------------------------------------------- | ------------------------- | ---------- |
| Events                                                | 4 million (130,000 a day) | 40 million |
| Sessions                                              | 30,000 (1,000 a day)      | 300,000    |
| Batches sent to ingest (30 a session)                 | 0.9 million               | 9 million  |
| Replay chunks (15 % of sessions recorded × 22 chunks) | 0.1 million               | 1 million  |

Prices used, on demand, as published for `us-east-1` when this was written: functions on arm64 USD 0.0000133 per GB-second and USD 0.20 per million requests; queue USD 0.40 per million requests; object storage USD 0.023 per GB-month, USD 5 per million writes, USD 0.40 per million reads; logs USD 0.50 per GB. Check them before you rely on a total.

| Line                         | Arithmetic (small)                                                                                                     | Small        | Medium             |
| ---------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ------------ | ------------------ |
| The address                  | 1.0 M requests. Inside the provider's free allowance of 10 million requests a month; about USD 1 per million beyond it | 0.00         | 0.00               |
| `ingest` requests            | 1.0 M × 0.20                                                                                                           | 0.20         | 2.00               |
| `ingest` time                | 1.0 M × 0.05 s × 0.25 GB = 12,500 GB-s                                                                                 | 0.17         | 1.67               |
| Queue                        | 0.9 M sends + about 0.6 M receives and deletes = 1.5 M × 0.40                                                          | 0.60         | 4.00               |
| `worker`, queue wake-ups     | At most one every 10 s: 260,000 × 0.5 s × 1 GB = 130,000 GB-s (2 s each at medium)                                     | 1.78         | 6.98               |
| `worker`, minute tick        | 43,200 × 1 s × 1 GB (2 s at medium)                                                                                    | 0.58         | 1.15               |
| `worker`, roll-up            | 8,640 runs × 5 s × 1 GB (30 s at medium)                                                                               | 0.58         | 3.46               |
| Object writes                | 260,000 segments + 60,000 session files + 100,000 chunks = 0.42 M × 5                                                  | 2.10         | 10.50              |
| Object reads                 | The roll-up re-reads the open hour: at most 3.1 M × 0.40                                                               | 1.24         | 2.00               |
| Object storage               | 1.2 GB per million events; 90 days of events, 30 of replays: about 8 GB × 0.023                                        | 0.18         | 1.84               |
| Logs                         | Successes sampled at 1 %: about 1 GB                                                                                   | 0.50         | 2.00               |
| **Engine, without Postgres** |                                                                                                                        | **≈ USD 8**  | **≈ USD 36**       |
| Postgres                     | The smallest managed instance with 1 GB of memory and 20 GB of disk; 2 to 4 GB of memory at medium                     | ≈ 14         | 25 to 50           |
| **Total**                    |                                                                                                                        | **≈ USD 22** | **≈ USD 60 to 85** |

Three things to read from the table:

1. **The database is the largest single line** at small sizes. It is also the one you may already have: any Postgres 15 or later works.
2. **Object writes cost more than everything stored.** Measured there: of USD 3.81 of object storage in 12 days, USD 2.73 was writes. This is why batches are grouped into segments and why replay chunks are 200 KB and not smaller.
3. **Receiving is nearly free.** A million batches cost less than 40 cents to accept.

The AWS free allowance for functions, 400,000 GB-seconds and a million requests a month, covers almost all the function lines of the small project. The small total agrees with what the first deployment of this design costs, USD 15 to 25 a month.

Not in the table: the model. An analysis is a few thousand tokens in and at most two thousand out, at most 100 a day per project, at your provider's price. And data leaving AWS when you watch replays, which is the size of the replay.

## As one long-running process

`sypnia serve` is the whole engine in one process: the HTTP server for ingest, the API, the MCP server and the Console, and the worker.

| Task inside the process | Does                                                                | Every                                                             |
| ----------------------- | ------------------------------------------------------------------- | ----------------------------------------------------------------- |
| HTTP server             | Ingest, OTLP, API, MCP server, Console                              | Each request                                                      |
| Buffer flusher          | Closes open segments, writes them, queues their ledger rows         | 2 s, or 4 MiB                                                     |
| Worker loop             | `Engine::pass`: fast path, alerts, uptime, and the roll-up when due | `processing.interval_seconds`, 30 s; at once when a segment lands |
| Agent tasks             | One per job, at most 4 at a time                                    | When the fast path queues one                                     |
| Cache refresh           | Keys, origins, limits, `slow_down`                                  | 60 s                                                              |
| Daily task              | Parquet, retention, partitions                                      | 02:30 UTC                                                         |

Notice in the excerpt that the worker loop waits for whichever comes first, the timer or a segment landing, and that shutdown lets the current step finish.

`crates/sypnia/src/serve.rs`

```rust
pub async fn run(engine: Arc<Engine>, args: ServeArgs) -> Result<(), ServeError> {
    let stop = CancellationToken::new();
    let mut tasks = JoinSet::new();

    if args.role.serves_http() {
        let app = Router::new()
            .merge(ingest::router(engine.clone()))  // /v1/ingest/*, /v1/otlp/*
            .merge(api::router(engine.clone()));    // /v1/*, /mcp, /console, /healthz
        let listener = TcpListener::bind(engine.config.listen).await?;
        let stopping = stop.clone();
        tasks.spawn(async move {
            axum::serve(listener, app)
                .with_graceful_shutdown(async move { stopping.cancelled().await })
                .await
                .map_err(ServeError::from)
        });
    }

    if args.role.works() {
        let (engine, stopping) = (engine.clone(), stop.clone());
        tasks.spawn(async move {
            let every = engine.config.processing.interval;
            loop {
                if let Err(error) = engine.pass().await {
                    tracing::error!(%error, "pass failed; the next one repeats it");
                }
                tokio::select! {
                    _ = tokio::time::sleep(every) => {}
                    _ = engine.segment_landed.notified() => {} // do not make a failure wait 30 s
                    _ = stopping.cancelled() => return Ok(()),
                }
            }
        });
    }

    shutdown_signal().await; // SIGTERM or Ctrl-C
    stop.cancel();           // requests get 20 s; open segments are flushed; the pass finishes its step
    while let Some(done) = tasks.join_next().await {
        done??;
    }
    Ok(())
}
```

**Sizing.** The engine's process needs memory for two projects being rolled (2 × 256 MB), the ingest buffer (32 MiB) and the source-map cache (200 MB): 1 GB is comfortable, 2 GB leaves room. One CPU core is enough for the small project above; the work is waiting on the Bucket and on Postgres, not computing. With Postgres and the bucket on the same machine, plan for more: [Scaling and cost](https://docs.sypnia.com/self-hosting/scaling-and-cost) has the sizes.

**Scaling out.** Run several processes against the same Bucket and Postgres, each with one role:

```bash
sypnia serve --role ingest --listen 0.0.0.0:8081   # as many as you need, behind your load balancer
sypnia serve --role api    --listen 0.0.0.0:8082
sypnia serve --role worker                         # two workers are safe: the ledger decides who does what
```

With ingest and the worker apart, a segment landing cannot wake the worker directly. The worker finds it in the ledger on its next pass, at most 30 seconds later, which is the case the 2-minute budget in [Data flow](https://docs.sypnia.com/architecture/data-flow) is computed for.

**Cost.** The price of the server, plus Postgres and a bucket if they are not on the same machine. The Docker Compose file in [Deploy with Docker](https://docs.sypnia.com/self-hosting/deploy-docker) starts the engine, Postgres and an S3-compatible store together, for trying it on one machine.

## The pieces you can swap

The engine touches the outside world in four places. Each is a trait in the code and a choice in the documentation. The default deployment uses the smallest option for each.

**Figure (diagram not drawn yet)**: The engine's four edges. Everything on the outside of a port can be replaced without touching the inside.

It will show: PORTS-AND-ADAPTERS DIAGRAM. In the centre a hexagon labelled «Engine», the lit element, with the inner text «knows only four traits». On four of its sides, a small port tab with the trait's exact name: «ObjectStore» (left), «Database» (bottom left), «AiProvider» (right), «AlertSink» (bottom right). From each port, lines fan out to adapter boxes. From «ObjectStore»: «Amazon S3», «Cloudflare R2», «MinIO», and a dashed box «a folder (tests)». From «Database»: «Postgres on RDS», «Supabase», «Neon», «your own Postgres», and a dashed box «in-process Postgres (tests)». From «AiProvider»: «none (default)», «OpenRouter», «OpenAI API», «Anthropic API», «Google Gemini», «any OpenAI-compatible endpoint», and a dashed box «a recorded answer (tests)». From «AlertSink»: «the record in Postgres (always)», «your webhook», and outside a dotted boundary labelled «built by you, on the webhook» two boxes «e-mail with Amazon SES» and «any SMTP». On each fan, mark with a small filled dot the adapter of the default deployment: Amazon S3 or the bucket the template creates, your Postgres URL, none, the record. Mark with a small cloud symbol what Sypnia Cloud uses: Amazon S3, Postgres, OpenRouter, and next to AlertSink a cloud-only box «e-mail and in-app alerts (Sypnia Cloud)». Legend: filled dot «default deployment», cloud symbol «Sypnia Cloud», dashed box «only in tests». Numbered callouts (1) to (4) on the four ports in the order ObjectStore, Database, AiProvider, AlertSink.

The two traits not shown on other pages. Notice that every method of the store takes a key built by `Keys`, never a string, and that a sink receives a finished alert and cannot change it.

`crates/sypnia-core/src/ports.rs`

```rust
/// (1) Where objects live. Implemented over the `object_store` crate for S3-compatible stores,
/// and over a folder for tests and for `sypnia serve` on a laptop.
#[async_trait]
pub trait ObjectStore: Send + Sync {
    async fn put(&self, key: &ObjectKey, body: Bytes, options: PutOptions) -> Result<(), StoreError>;
    /// The object as lines, decompressed as they are read. A segment is never held twice in memory.
    async fn read_lines(&self, key: &ObjectKey) -> Result<LineStream, StoreError>;
    async fn get(&self, key: &ObjectKey) -> Result<Bytes, StoreError>;
    /// Keys under a prefix, in order. `after` continues a listing without re-reading it.
    async fn list(&self, prefix: &KeyPrefix, after: Option<&ObjectKey>) -> Result<Vec<ObjectMeta>, StoreError>;
    async fn delete_prefix(&self, prefix: &KeyPrefix) -> Result<u64, StoreError>;
    /// A link a browser can use directly: to play a replay chunk, or to upload a source map.
    async fn sign(&self, key: &ObjectKey, method: SignedMethod, ttl: Duration) -> Result<Url, StoreError>;
}

/// (4) Where a released alert goes. The engine ships two: the record and the webhook.
#[async_trait]
pub trait AlertSink: Send + Sync {
    fn name(&self) -> &str;
    /// Called once per released alert. An error is retried with growing waits and recorded as a delivery.
    async fn deliver(&self, alert: &ReleasedAlert) -> Result<Delivery, SinkError>;
}
```

`Database` (2) is the same idea with more methods: one per statement the engine runs, grouped by table, implemented once with `sqlx` for Postgres. It is a trait so that tests can count and fail queries, not because another database is planned. `AiProvider` (3) is on [The agent's pipeline](https://docs.sypnia.com/architecture/agent-pipeline).

**A piece you choose: Object storage.** Holds raw events, replay chunks, page snapshots and source maps.

- **Default deployment:** The bucket the template creates, or the one you name in SYPNIA_STORAGE_BUCKET.
- **Sypnia Cloud uses:** Amazon S3.

**A piece you choose: Database.** Holds the aggregates, the session index, problems and configuration.

- **Default deployment:** A Postgres URL you provide, or the instance the template creates.
- **Sypnia Cloud uses:** Postgres.

**A piece you choose: Alert delivery.** Gets an alert from the engine to a person.

- **Default deployment:** None. Alerts are recorded, shown in the Console and sent to a webhook if you set one.
- **Sypnia Cloud uses:** E-mail through Amazon SES, and alerts inside the app.

**A piece you choose: AI provider.** Runs the model behind the agent’s analysis and the ready prompt.

- **Default deployment:** Off until you set a key.
- **Sypnia Cloud uses:** OpenRouter.

There is no WhatsApp or Slack sink, in the engine or in Sypnia Cloud. An `AlertSink` for either is a few dozen lines on your side of the webhook, and the engine does not need to know.

## Which shape to choose

| If you                                                                    | Choose                                                              |
| ------------------------------------------------------------------------- | ------------------------------------------------------------------- |
| Already run things on AWS and want to pay for use, not for an idle server | AWS functions                                                       |
| Want everything on one machine, or are not on AWS                         | One process                                                         |
| Want to try the engine on a laptop                                        | One process, with Docker Compose                                    |
| Expect traffic in bursts                                                  | AWS functions: more copies appear by themselves                     |
| Need your data never to leave your network, including the model           | One process, with an OpenAI-compatible endpoint inside your network |

You can change your mind. The Bucket layout and the tables are the same, so moving is pointing the other shape at the same Bucket and the same Postgres.

## What changed from the system this comes from

| There                                                                                              | Here                                                             | Why                                                                             |
| -------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| Functions only, deployed with the app                                                              | Functions, or one process                                        | Brief §10.9: the same binary in both shapes                                     |
| An ingest function, an hourly function, a daily function, a weekly one, each with its own schedule | Three functions by role; the worker has a queue and one schedule | One function per role matches `--role`, and one binary has one configuration    |
| A managed delivery stream between ingest and the bucket                                            | A queue on AWS, memory elsewhere                                 | Freshness, and objects named by project                                         |
| x86_64 only, because of a native binding                                                           | arm64, or any target Rust builds for                             | No native dependency left                                                       |
| Five environment variables in the app to send server data                                          | One ingest key and one URL                                       | Its app once reached 3,924 of the 4,096 bytes a function's environment may hold |

## Next
