> ## Documentation Index
> Fetch the complete documentation index at: https://os.inttegro.dev/simile/llms.txt
> Use this file to discover all available pages before exploring further.

# Simile Stack

> Deterministic local backends that make a service emulator behave like a system.

An API is rarely only HTTP. A request may write state, cache a value, publish an event, enqueue
work, send mail, schedule a retry, store a file, or call another service. Simile Stack provides
small deterministic implementations of those capabilities so a local Simile service can reproduce
the observable consequences of an operation without reproducing its production infrastructure.

```mermaid theme={null}
flowchart LR
  App[Application under test] --> Service[Simile service]
  Service --> Response[Immediate response]
  Service --> Stack[Simile Stack]
  Stack --> DB[(db)]
  Stack --> Queue[[queue]]
  Stack --> Mail[mail]
  Stack --> More[cache · objects · events · schedules · HTTP]
  Clock[One logical clock] --> Stack
  Stack --> Journal[One causal journal]
```

## The design rule

Stack emulates **capabilities**, not vendors. `db` means durable document-like state; it does not
claim to be PostgreSQL. `queue` means delayed, at-least-once delivery with visibility and
acknowledgement; it does not claim Kafka or SQS protocol compatibility. The service definition
describes the behavior an integration can observe while private topology and vendor choices stay
private.

This keeps service definitions:

* portable across provider infrastructure changes;
* small enough for providers to author and review;
* safe to publish without disclosing internal architecture; and
* precise enough to reproduce meaningful state and asynchronous behavior.

## Components

| Capability | Process | What it emulates |
| - | - | - |
| [Database](https://os.inttegro.dev/simile/stack-db.md) | `simile-db` | Versioned documents, queries, conditional writes, transactions |
| [Cache](https://os.inttegro.dev/simile/stack-cache.md) | `simile-cache` | TTLs, counters, compare-and-set |
| [Queue](https://os.inttegro.dev/simile/stack-queue.md) | `simile-queue` | Delay, visibility, acknowledgement, redelivery |
| [Mail](https://os.inttegro.dev/simile/stack-mail.md) | `simile-mail` | Accepted mail and deterministic delivery outcomes |
| [Object store](https://os.inttegro.dev/simile/stack-object-store.md) | `simile-object-store` | Bytes, metadata, ETags, conditional writes, listing |
| [Event bus](https://os.inttegro.dev/simile/stack-event-bus.md) | `simile-event-bus` | Ordered topics and independent subscriber checkpoints |
| [Scheduler](https://os.inttegro.dev/simile/stack-scheduler.md) | `simile-scheduler` | Named tasks fired by logical time |
| [Outbound HTTP](https://os.inttegro.dev/simile/stack-http.md) | `simile-http` | Expected calls, local responses, and request history |

One process hosts one capability kind and may contain several named backends. For example,
`queue.orders` and `queue.receipts` are isolated namespaces in one `simile-queue` process. This is
small enough to run locally while preserving the backend boundaries in the service definition.

## What every component shares

All components implement the same [versioned protocol](https://os.inttegro.dev/simile/stack-protocol.md), use the same
[logical-time model](https://os.inttegro.dev/simile/stack-time.md), and contribute payload-free entries to the same conceptual
[causal journal](https://os.inttegro.dev/simile/stack-journal.md). Their state is serializable, resettable, and restorable. The
supervisor owns command identity and time, so every backend observes the same operation timeline.

Every component process checkpoints each coherent transition into an embedded redb database under
the Simile home directory and restores it before accepting traffic after a restart. No state-file
configuration is required. The [persistence contract](https://os.inttegro.dev/simile/stack-persistence.md) defines path identity,
commit visibility, rollback, file ownership, compatibility checks, and the distinction between a
runtime checkpoint and a portable JSON snapshot.

## Execution boundary

HCL effects compile into typed Stack commands. Synchronous commands, inferred state transitions,
the Stack checkpoint, and deferred-work publication share one service commit. Named `async` units
and webhook occurrences enter a durable outbox, where background workers lease and execute them
after the public response has committed.

A backend declaration grants the service a capability; it never invents a provider-specific
command. Simile can infer conservative database CRUD when the contract proves a single entity and
identity. Queue messages, mail, schedules, events, objects, and ambiguous database transitions use
provider-authored effects. See [Dependencies and effects](https://os.inttegro.dev/simile/dependencies-and-effects.md) for the action
language and [Durable work](https://os.inttegro.dev/simile/durable-work.md) for dispatch semantics.

## Composition rules

Stack follows three rules that keep larger emulations understandable:

1. **State changes commit before asynchronous effects.** A response cannot claim success while its
   required state mutation remains ambiguous.
2. **Every command carries causality.** Operation, causation, correlation, and idempotency metadata
   make related activity inspectable without recording private payloads in the journal.
3. **Time is an input.** Tests advance one logical clock instead of sleeping and hoping background
   work has completed.

These rules let simple components compose into a believable service without turning Stack into a
copy of the provider's production deployment.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.