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

# Introduction

> Open-source job orchestration for background jobs, workflows, and AI agents. One binary, one database, zero message brokers.

## What is Strait?

Strait is an open-source platform that runs your background jobs, orchestrates multi-step workflows, and manages AI agent pipelines. You define what needs to happen. Strait handles the retries, scheduling, dependencies, and monitoring.

One Go binary. One PostgreSQL database. No Redis required. No RabbitMQ. No SQS. Just deploy and start running jobs.

## Why teams switch to Strait

Most teams start with a simple queue and a retry loop. Then they need scheduling. Then workflow dependencies. Then approval gates. Then cost tracking for AI agents. Before long, they're maintaining five different systems that don't talk to each other.

Strait replaces that patchwork with one system:

* **Jobs fail gracefully.** Every run follows a 13-state lifecycle. Retries use exponential backoff, fixed delays, or custom sequences. Exhausted runs go to a dead letter queue for review.
* **Workflows run as DAGs.** Define step dependencies, approval gates, sub-workflows, event waits, and sleep delays. Strait validates the graph and runs it.
* **Everything is observable.** See exactly where every run is, why it failed, how long it took, and what it cost. Real-time streaming, not polling.
* **Five SDKs, same architecture.** TypeScript, Python, Go, Ruby, and Rust. Pick your language, define your jobs, run them anywhere.
* **Self-host or use managed.** Deploy on your infrastructure with just PostgreSQL, or use the managed platform at [app.strait.dev](https://app.strait.dev).

## Key Capabilities

<CardGroup cols={2}>
  <Card title="13-State FSM" icon="engine">
    Robust lifecycle management—queued, executing, completed, failed, timed\_out, dead\_letter—ensures every job run is tracked correctly.
  </Card>

  <Card title="Workflow DAGs" icon="diagram-project">
    Directed Acyclic Graphs with fan-in/fan-out, step conditions, template variables, output transforms, human approval gates, and durable event waits.
  </Card>

  <Card title="Smart Retry" icon="rotate">
    Exponential, linear, fixed, or custom per-attempt delays with ±20% jitter. Prevents thundering herd and handles transient failures gracefully.
  </Card>

  <Card title="Cost Budgets" icon="money-bill">
    Track AI model usage with micro-USD precision. Enforce per-run and daily project limits to control costs.
  </Card>
</CardGroup>

<CardGroup cols={2}>
  <Card title="Event Triggers" icon="bell">
    Pause execution and wait for external events—approvals, webhooks, third-party callbacks—for days or weeks without holding goroutines. Durable, database-backed waits with timeout support.
  </Card>

  <Card title="Real-Time CDC" icon="zap">
    Postgres WAL change capture via Sequin. No polling required—your applications react instantly when jobs, workflows, or runs change.
  </Card>

  <Card title="SDK Endpoints" icon="code">
    Specialized endpoints for job executors—logging, heartbeats, progress updates, checkpoints, continuation, and child job spawning.
  </Card>

  <Card title="Webhooks" icon="send">
    HMAC-SHA256 signed webhooks with automatic retries and dead letter queue on delivery failure.
  </Card>

  <Card title="Health Scoring" icon="chart-line">
    Aggregate metrics over configurable time windows. Success rate, timeout rate, crash rate, and latency stability—at-a-glance job reliability.
  </Card>
</CardGroup>

## Architecture Overview

```text theme={null}
                    ┌──────────────────────────────────┐
                    │           API Server              │
                    │  (Chi router + middleware)         │
                    │                                    │
                    │  /v1/jobs/* ── Job CRUD + Health   │
                    │  /v1/workflows/* ── DAG CRUD       │
                    │  /v1/workflow-runs/* ── Run mgmt   │
                    │  /v1/jobs/{id}/trigger ── Enqueue  │
                    │  /v1/runs/* ── Run mgmt + DLQ     │
                    │  /v1/events/* ── Event triggers    │
                    │  /sdk/v1/* ── SDK (JWT auth)      │
                    │  /metrics ── Prometheus            │
                    └──────────┬───────────────────────┘
                               │ Enqueue (budget check)
                               v
                    ┌──────────────────────────────────┐
                    │         PostgreSQL                 │
                    │                                    │
                    │  jobs ── job definitions           │
                    │  job_runs ── run state + queue     │
                    │  workflows ── DAG definitions      │
                    │  workflow_runs ── workflow state   │
                    │  event_triggers ── durable waits   │
                    │  run_events ── log entries         │
                    │  run_usage ── AI cost tracking     │
                    │  environments ── endpoint config   │
                    │  project_quotas ── budget limits   │
                    │                                    │
                    │  Queue: SELECT FOR UPDATE          │
                    │         SKIP LOCKED                │
                    └──────────┬───────────────────────┘
                               │ Dequeue
                               v
                    ┌──────────────────────────────────┐
                    │         Worker Executor            │
                    │                                    │
                    │  Poll ─> DequeueN(available)       │
                    │  Workflow Engine:                  │
                    │  - DAG Validation (Kahn's)         │
                    │  - Atomic Fan-in (UPDATE...RET)    │
                    │  - Condition Evaluation            │
                    │  - Template Rendering              │
                    │  - Sub-workflow Nesting            │
                    │                                    │
                    │  Job Execution:                    │
                    │  - Resolve ─> Env override + SSRF  │
                    │  - Execute ─> HTTP POST to endpt   │
                    │  - Retry ─> Smart strategy select  │
                    │  - Trace ─> Execution timing       │
                    │  - DLQ ─> Dead letter on exhaust   │
                    └──────────┬───────────────────────┘
                               │ Webhook / PubSub
                               v
                    ┌──────────────────────────────────┐
                    │  Scheduler         │  Redis       │
                    │  - Cron ticker     │  - PubSub    │
                    │  - Delayed poller  │  - SSE       │
                    │  - Stale reaper    │  streaming   │
                    │  - Retention       │              │
                    └──────────────────────────────────┘
```

Strait runs in three modes:

<Info>
  **api**: Handles HTTP requests, job management, and triggering. Scale horizontally for API throughput.
</Info>

<Info>
  **worker**: Runs executor, scheduler, and background maintenance. Scale horizontally for job processing throughput.
</Info>

<Info>
  **all**: Combined mode for development or small deployments. Single binary, single process.
</Info>

## Why Strait?

<Steps>
  <Step title="Zero External Dependencies">
    No RabbitMQ. No SQS. No Kafka. PostgreSQL handles queuing with `SELECT FOR UPDATE SKIP LOCKED`—lock-free concurrent workers without operational overhead. Single binary includes everything—no runtime dependencies to install.
  </Step>

  <Step title="Production-Grade Concurrency">
    Go goroutines provide parallel job execution without external coordination. Worker pool with bounded backpressure prevents memory exhaustion during traffic spikes. Structured concurrency patterns (`sourcegraph/conc`) ensure panic recovery and graceful shutdown.
  </Step>

  <Step title="Built for AI Workloads">
    SDK endpoints designed for AI agents—logging, heartbeats, progress checkpoints, continuation for long-running workflows, and child job spawning. Cost budgets track token usage with micro-USD precision. Debug bundles aggregate execution data for troubleshooting.
  </Step>

  <Step title="Workflow Orchestration">
    Complex DAGs with step conditions, output transforms, template variables, and human approval gates. Atomic fan-in handles concurrent parent completions safely. Sub-workflows enable arbitrary nesting depth for multi-stage pipelines.
  </Step>

  <Step title="Observability First">
    OpenTelemetry tracing links job runs across API server, worker, and external endpoints. Prometheus metrics expose queue depth, throughput, and latency. Structured JSON logging enables log aggregation. Real-time SSE streaming via Redis.
  </Step>

  <Step title="Developer Experience">
    Unified CLI with code-first deployment workflows, operational command groups, and shell completion for Bash, Zsh, Fish, and PowerShell.
  </Step>
</Steps>

## Use Cases

Strait fits these patterns:

**Background Jobs**: Scheduled data imports, report generation, cache warming, cleanup tasks, and recurring maintenance operations.

**Webhook Consumers**: Process events from external services with retries, dead letter queue, and delivery guarantees.

**AI Agent Workflows**: Multi-step AI pipelines with human approval gates, conditional execution, and sub-workflow nesting. Cost tracking per run and per project.

**Batch Processing**: Bulk job triggering with configurable batch sizes, priority ordering, and idempotency deduplication.

**Data Pipelines**: ETL workflows with fan-out parallel steps, transform stages, and aggregation.

**Cron Jobs**: Standard 5-field cron expressions with timezone support and execution windows.

## Getting Started

<CardGroup cols={2}>
  <Card title="Quick Start" icon="bolt" href="/quickstart">
    Get Strait running in minutes. Clone repository, start infrastructure with Docker Compose, and trigger your first job.
  </Card>

  <Card title="Architecture" icon="sitemap" href="/architecture">
    Deep dive into internals. Learn about queue mechanics, FSM states, workflow engine, and technology choices.
  </Card>
</CardGroup>

<CardGroup cols={2}>
  <Card title="SDK Reference" icon="code" href="/sdks/overview">
    Official SDKs for TypeScript, Python, Go, Ruby, and Rust with full feature parity. Authoring DSL, composition helpers, and typed errors.
  </Card>

  <Card title="CLI Reference" icon="terminal" href="/cli/overview">
    Complete CLI documentation. 48+ commands organized by category with examples and shell completion.
  </Card>
</CardGroup>

<CardGroup cols={2}>
  <Card title="API Reference" icon="api" href="/api-reference/overview">
    REST API endpoints for job management, triggering, workflow orchestration, and SDK interactions.
  </Card>
</CardGroup>

## Concepts

Core domain concepts you'll encounter:

<Tabs>
  <Tab title="Jobs">
    Jobs define the template for recurring tasks—endpoint URL, timeout, retry strategy, cron schedule, and cost budgets. Runs are execution instances of jobs.
  </Tab>

  <Tab title="Runs">
    Runs represent a single execution of a job. Tracked through a 13-state FSM—queued, dequeued, executing, completed, failed, timed\_out, dead\_letter—with events, logs, and usage data.
  </Tab>

  <Tab title="Workflows">
    Workflows orchestrate multiple jobs into DAGs. Steps can depend on outputs from parent steps, have conditional execution based on step status, include human approval gates, and wait for external events.
  </Tab>

  <Tab title="Event Triggers">
    Event triggers pause workflow steps or job runs until an external event arrives via API. Waits are durable — stored as database rows, not goroutines — and can last days or weeks. Supports timeouts, webhook notifications, event chaining, and real-time SSE streaming.
  </Tab>

  <Tab title="Environments">
    Environments provide per-project, named configurations with key-value variables. Jobs can link to environments, enabling endpoint URL overrides for staging vs. production routing.
  </Tab>
</Tabs>

## Guides

Step-by-step guides for common tasks:

<CardGroup cols={2}>
  <Card title="Authentication" icon="lock" href="/guides/authentication">
    Internal secret auth for API endpoints and JWT run token auth for SDK. API key management with system keychain storage.
  </Card>

  <Card title="Deployment" icon="cloud" href="/guides/deployment">
    Docker deployment, Fly.io configuration, horizontal scaling strategies, and production readiness checklist.
  </Card>

  <Card title="Security" icon="shield" href="/guides/security">
    SSRF protection, rate limiting, encryption at rest, and secure webhook delivery.
  </Card>

  <Card title="Cost Budgets" icon="money-bill" href="/concepts/cost-budgets">
    Per-run and daily project limits. AI model usage tracking with micro-USD precision. Budget enforcement before execution.
  </Card>
</CardGroup>

## Development

Contributing to Strait or running it locally:

<CardGroup cols={2}>
  <Card title="Contributing" icon="users" href="/development/contributing">
    Setup development environment, code style, commit conventions, and PR guidelines.
  </Card>

  <Card title="Testing" icon="check-circle" href="/development/testing">
    Unit tests, integration tests with testcontainers, E2E tests, fuzz testing, and benchmarks.
  </Card>

  <Card title="Database Schema" icon="database" href="/development/database-schema">
    Complete table definitions, indexes, and relationships for PostgreSQL schema.
  </Card>
</CardGroup>

## What's Next?

Ready to dive deeper?

* Learn about the [queue mechanics](/architecture#queue-mechanics) and how `SKIP LOCKED` works
* Understand the [workflow engine](/architecture#workflow-engine) and DAG execution
* Explore [retry strategies](/concepts/retry-strategies) -- exponential, linear, fixed, and custom
* Set up [webhooks](/concepts/webhooks) with HMAC signing for event delivery
* Build durable workflows with [event triggers](/concepts/event-triggers) -- wait for external events without holding goroutines
* Configure [cost budgets](/concepts/cost-budgets) for AI workloads

Or jump straight into the [Quick Start Guide](/quickstart) and run your first job in 5 minutes.

## Explore the Docs

<CardGroup cols={2}>
  <Card title="Quick Start" icon="rocket" href="/quickstart">
    Run your first job in under 10 minutes.
  </Card>

  <Card title="Architecture" icon="sitemap" href="/architecture">
    Understand how Strait works under the hood.
  </Card>

  <Card title="SDKs" icon="code" href="/sdks/overview">
    Official client libraries for 5 languages.
  </Card>

  <Card title="API Reference" icon="square-terminal" href="/api-reference/overview">
    Complete REST API documentation.
  </Card>
</CardGroup>
