# rivet-dev/rivet architecture

> Architecture diagram of the GitHub repository rivet-dev/rivet, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rivet-dev/rivet
- Repository: https://github.com/rivet-dev/rivet
- Video tour (about a minute): https://gitdiagram.com/rivet-dev/rivet/video

## Overview

Rivet is a control plane for durable Actors: clients address an Actor by name/key, the platform creates or locates it, routes requests to its worker, and preserves its state across sleep and rescheduling. The map includes the documented workflow, realtime, multi-region, and self-hosting capabilities, plus the depot persistence/compaction layer. Several runtime links are documented in the README rather than shown in the sampled implementation; those edges cite that documentation.

Main entry points: [`rivetkit-typescript/packages/rivetkit/src/common/engine.ts`](https://github.com/rivet-dev/rivet/blob/main/rivetkit-typescript/packages/rivetkit/src/common/engine.ts) (Actor worker), [`engine/packages/api-public/src/router.rs`](https://github.com/rivet-dev/rivet/blob/main/engine/packages/api-public/src/router.rs) (Engine API), [`rivetkit-swift/Sources/RivetKitClient/RemoteManager.swift`](https://github.com/rivet-dev/rivet/blob/main/rivetkit-swift/Sources/RivetKitClient/RemoteManager.swift) (Actor SDKs), [`engine/packages/depot/src/workflows/db_manager.rs`](https://github.com/rivet-dev/rivet/blob/main/engine/packages/depot/src/workflows/db_manager.rs) (Database management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Clients and console"]
  node_client_sdk["Actor SDKs"]
  node_console["Admin console"]
  node_console_data["Console data provider"]
end

subgraph group_control["Control plane"]
  node_engine_api["Engine API<br/>[router.rs]"]
  node_peer_api["Peer API<br/>[router.rs]"]
  node_auth["Token authorization<br/>[authorize.rs]"]
  node_gateway["Edge gateway<br/>[mod.rs]"]
  node_scheduler["Actor scheduling<br/>[get_or_create.rs]"]
  node_topology["Region topology<br/>[topology.rs]"]
  node_engine["Rivet engine<br/>[main.rs]"]
end

subgraph group_runtime["Actor runtime"]
  node_actor_worker["Actor worker<br/>[engine.ts]"]
  node_actor_state[("Actor state")]
  node_actor_network["HTTP and WebSocket<br/>[proxy_service.rs]"]
end

subgraph group_data["Durable data"]
  node_depot[("Database depot<br/>[storage.rs]")]
  node_db_manager["Database management<br/>[db_manager.rs]"]
  node_compaction["Database compaction<br/>[shared.rs]"]
end

subgraph group_operations["Workflows and operations"]
  node_workflow["Durable workflows<br/>[workflow.rs]"]
  node_workflow_engine[("Workflow storage<br/>[storage.ts]")]
  node_self_host["Self-host deployment<br/>[rivet-engine.ts]"]
end

node_actor_user(("Application client"))

node_actor_user -->|"calls"| node_client_sdk
node_client_sdk -->|"requests creation"| node_engine_api
node_client_sdk -->|"sends actor traffic"| node_gateway
node_engine_api -.->|"authorizes"| node_auth
node_engine_api -.->|"creates actors"| node_scheduler
node_scheduler -->|"selects region"| node_topology
node_gateway -->|"routes requests"| node_actor_worker
node_actor_worker -->|"persists state"| node_actor_state
node_actor_worker -->|"serves requests"| node_actor_network
node_actor_worker -->|"runs workflows"| node_workflow
node_workflow -.->|"persists history"| node_workflow_engine
node_db_manager -->|"manages storage"| node_depot
node_db_manager -->|"runs compaction"| node_compaction
node_console -->|"queries data"| node_console_data
node_console_data -->|"fetches engine data"| node_engine_api
node_self_host -->|"configures deployment"| node_engine
node_engine -.->|"serves peer API"| node_peer_api

click node_client_sdk "https://github.com/rivet-dev/rivet/blob/main/rivetkit-swift/Sources/RivetKitClient/RemoteManager.swift"
click node_engine_api "https://github.com/rivet-dev/rivet/blob/main/engine/packages/api-public/src/router.rs"
click node_peer_api "https://github.com/rivet-dev/rivet/blob/main/engine/packages/api-peer/src/router.rs"
click node_auth "https://github.com/rivet-dev/rivet/blob/main/engine/packages/auth-policy/src/authorize.rs"
click node_gateway "https://github.com/rivet-dev/rivet/blob/main/engine/packages/guard/src/routing/pegboard_gateway/mod.rs"
click node_scheduler "https://github.com/rivet-dev/rivet/blob/main/engine/packages/api-peer/src/actors/get_or_create.rs"
click node_topology "https://github.com/rivet-dev/rivet/blob/main/engine/packages/config/src/config/topology.rs"
click node_actor_worker "https://github.com/rivet-dev/rivet/blob/main/rivetkit-typescript/packages/rivetkit/src/common/engine.ts"
click node_actor_network "https://github.com/rivet-dev/rivet/blob/main/engine/packages/guard-core/src/proxy_service.rs"
click node_workflow "https://github.com/rivet-dev/rivet/blob/main/engine/packages/gasoline/src/workflow.rs"
click node_workflow_engine "https://github.com/rivet-dev/rivet/blob/main/rivetkit-typescript/packages/workflow-engine/src/storage.ts"
click node_depot "https://github.com/rivet-dev/rivet/blob/main/engine/packages/depot/src/conveyer/types/storage.rs"
click node_db_manager "https://github.com/rivet-dev/rivet/blob/main/engine/packages/depot/src/workflows/db_manager.rs"
click node_compaction "https://github.com/rivet-dev/rivet/blob/main/engine/packages/depot/src/compaction/shared.rs"
click node_console "https://github.com/rivet-dev/rivet/blob/main/frontend/src/app/engine-namespace-landing.tsx"
click node_console_data "https://github.com/rivet-dev/rivet/blob/main/frontend/src/app/data-providers/engine-data-provider.tsx"
click node_self_host "https://github.com/rivet-dev/rivet/blob/main/self-host/compose/template/src/services/edge/rivet-engine.ts"
click node_engine "https://github.com/rivet-dev/rivet/blob/main/engine/packages/engine/src/main.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client_sdk,node_console,node_console_data,node_actor_user toneBlue
class node_engine_api,node_peer_api,node_auth,node_gateway,node_scheduler,node_topology,node_engine toneAmber
class node_actor_worker,node_actor_state,node_actor_network toneMint
class node_depot,node_db_manager,node_compaction toneRose
class node_workflow,node_workflow_engine,node_self_host toneIndigo
```

## Components

### Clients and console

- [Actor SDKs](https://github.com/rivet-dev/rivet/blob/main/rivetkit-swift/Sources/RivetKitClient/RemoteManager.swift): `rivetkit-swift/Sources/RivetKitClient/RemoteManager.swift`
- [Admin console](https://github.com/rivet-dev/rivet/blob/main/frontend/src/app/engine-namespace-landing.tsx): `frontend/src/app/engine-namespace-landing.tsx`
- [Console data provider](https://github.com/rivet-dev/rivet/blob/main/frontend/src/app/data-providers/engine-data-provider.tsx): `frontend/src/app/data-providers/engine-data-provider.tsx`

### Control plane

- [Engine API](https://github.com/rivet-dev/rivet/blob/main/engine/packages/api-public/src/router.rs): `engine/packages/api-public/src/router.rs`
- [Peer API](https://github.com/rivet-dev/rivet/blob/main/engine/packages/api-peer/src/router.rs): `engine/packages/api-peer/src/router.rs`
- [Token authorization](https://github.com/rivet-dev/rivet/blob/main/engine/packages/auth-policy/src/authorize.rs): `engine/packages/auth-policy/src/authorize.rs`
- [Edge gateway](https://github.com/rivet-dev/rivet/blob/main/engine/packages/guard/src/routing/pegboard_gateway/mod.rs): `engine/packages/guard/src/routing/pegboard_gateway/mod.rs`
- [Actor scheduling](https://github.com/rivet-dev/rivet/blob/main/engine/packages/api-peer/src/actors/get_or_create.rs): `engine/packages/api-peer/src/actors/get_or_create.rs`
- [Region topology](https://github.com/rivet-dev/rivet/blob/main/engine/packages/config/src/config/topology.rs): `engine/packages/config/src/config/topology.rs`
- [Rivet engine](https://github.com/rivet-dev/rivet/blob/main/engine/packages/engine/src/main.rs): `engine/packages/engine/src/main.rs`

### Actor runtime

- [Actor worker](https://github.com/rivet-dev/rivet/blob/main/rivetkit-typescript/packages/rivetkit/src/common/engine.ts): `rivetkit-typescript/packages/rivetkit/src/common/engine.ts`
- **Actor state**
- [HTTP and WebSocket](https://github.com/rivet-dev/rivet/blob/main/engine/packages/guard-core/src/proxy_service.rs): `engine/packages/guard-core/src/proxy_service.rs`

### Durable data

- [Database depot](https://github.com/rivet-dev/rivet/blob/main/engine/packages/depot/src/conveyer/types/storage.rs): `engine/packages/depot/src/conveyer/types/storage.rs`
- [Database management](https://github.com/rivet-dev/rivet/blob/main/engine/packages/depot/src/workflows/db_manager.rs): `engine/packages/depot/src/workflows/db_manager.rs`
- [Database compaction](https://github.com/rivet-dev/rivet/blob/main/engine/packages/depot/src/compaction/shared.rs): `engine/packages/depot/src/compaction/shared.rs`

### Workflows and operations

- [Durable workflows](https://github.com/rivet-dev/rivet/blob/main/engine/packages/gasoline/src/workflow.rs): `engine/packages/gasoline/src/workflow.rs`
- [Workflow storage](https://github.com/rivet-dev/rivet/blob/main/rivetkit-typescript/packages/workflow-engine/src/storage.ts): `rivetkit-typescript/packages/workflow-engine/src/storage.ts`
- [Self-host deployment](https://github.com/rivet-dev/rivet/blob/main/self-host/compose/template/src/services/edge/rivet-engine.ts): `self-host/compose/template/src/services/edge/rivet-engine.ts`

### Other components

- **Application client**

## Connections

- Application client → Actor SDKs: calls
- Actor SDKs → Engine API: requests creation (evidence: `rivetkit-swift/Sources/RivetKitClient/RemoteManager.swift`)
- Actor SDKs → Edge gateway: sends actor traffic (evidence: `rivetkit-swift/Sources/RivetKitClient/RemoteManager.swift`)
- Engine API → Token authorization: authorizes
- Engine API → Actor scheduling: creates actors
- Actor scheduling → Region topology: selects region
- Edge gateway → Actor worker: routes requests
- Actor worker → Actor state: persists state
- Actor worker → HTTP and WebSocket: serves requests
- Actor worker → Durable workflows: runs workflows
- Durable workflows → Workflow storage: persists history
- Database management → Database depot: manages storage (evidence: `engine/packages/depot/src/workflows/db_manager.rs`)
- Database management → Database compaction: runs compaction (evidence: `engine/packages/depot/src/workflows/db_manager.rs`)
- Admin console → Console data provider: queries data (evidence: `frontend/src/app/engine-namespace-landing.tsx`)
- Console data provider → Engine API: fetches engine data (evidence: `frontend/src/app/data-providers/engine-data-provider.tsx`)
- Self-host deployment → Rivet engine: configures deployment (evidence: `self-host/compose/template/src/services/edge/rivet-engine.ts`)
- Rivet engine → Peer API: serves peer API
