# ambientrun/ambient architecture

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

- Interactive diagram: https://gitdiagram.com/ambientrun/ambient
- Repository: https://github.com/ambientrun/ambient

## Overview

Ambient is a cross-platform multiplayer game runtime and development platform. A developer creates or builds a Rust/WASM package, then launches it through the Ambient CLI; clients connect to a server where game state is maintained and synchronized, and the client renders the game. The README also identifies package interoperability, configurable asset pipelines, WASM isolation, and PBR rendering as major capabilities. The graph uses the README and indexed or excerpted source references; unsampled implementations and some runtime wiring are represented conservatively.

Main entry points: [`web/client/src/app.rs`](https://github.com/ambientrun/ambient/blob/main/web/client/src/app.rs) (Client application), [`app/src/main.rs`](https://github.com/ambientrun/ambient/blob/main/app/src/main.rs) (Ambient CLI), [`crates/network/src/server.rs`](https://github.com/ambientrun/ambient/blob/main/crates/network/src/server.rs) (Network server), [`guest/rust/packages`](https://github.com/ambientrun/ambient/tree/main/guest/rust/packages) (Game package)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_platform["Platform workflow"]
  node_ambient_cli["Ambient CLI<br/>[main.rs]"]
  node_campfire["Campfire tools<br/>[cli.rs]"]
  node_package_ops["Package operations<br/>[package.rs]"]
  node_package["Game package"]
end

subgraph group_runtime["Game runtime"]
  node_client_app["Client application<br/>[app.rs]"]
  node_server_runtime["Server runtime<br/>[mod.rs]"]
  node_network_client["Network client<br/>[client.rs]"]
  node_network_server["Network server<br/>[server.rs]"]
  node_network_protocol["Network protocol<br/>[server.rs]"]
end

subgraph group_engine["Engine services"]
  node_ecs[("Entity database<br/>[query.rs]")]
  node_terrain["Terrain systems<br/>[lib.rs]"]
  node_renderer["PBR renderer<br/>[renderer.rs]"]
  node_asset_pipeline["Asset pipeline<br/>[lib.rs]"]
end

subgraph group_guest["Package execution"]
  node_wasm_runtime["WASM runtime<br/>[engine.rs]"]
  node_guest_api["Guest Rust API<br/>[lib.rs]"]
end

node_developer(("Developer"))

node_developer -->|"launches"| node_ambient_cli
node_developer -->|"runs tools"| node_campfire
node_campfire -->|"dispatches"| node_package_ops
node_package_ops -->|"invokes"| node_ambient_cli
node_ambient_cli -.->|"starts client"| node_client_app
node_ambient_cli -.->|"starts server"| node_server_runtime
node_client_app -->|"connects through"| node_network_client
node_network_client -->|"exchanges game state"| node_network_server
node_network_server -->|"dispatches messages"| node_network_protocol
node_network_server -.->|"updates world"| node_ecs
node_client_app -->|"initializes"| node_wasm_runtime
node_wasm_runtime -.->|"hosts packages"| node_guest_api
node_guest_api -->|"implements"| node_package
node_ecs -->|"synchronizes state"| node_network_server
node_asset_pipeline -->|"loads assets"| node_package
node_client_app -.->|"renders game"| node_renderer
node_terrain -.->|"operates on world"| node_ecs
node_developer -->|"creates package"| node_package
node_package -->|"runs isolated"| node_wasm_runtime

click node_ambient_cli "https://github.com/ambientrun/ambient/blob/main/app/src/main.rs"
click node_campfire "https://github.com/ambientrun/ambient/blob/main/campfire/src/cli.rs"
click node_package_ops "https://github.com/ambientrun/ambient/blob/main/campfire/src/package.rs"
click node_package "https://github.com/ambientrun/ambient/tree/main/guest/rust/packages"
click node_client_app "https://github.com/ambientrun/ambient/blob/main/web/client/src/app.rs"
click node_server_runtime "https://github.com/ambientrun/ambient/blob/main/app/src/server/mod.rs"
click node_network_client "https://github.com/ambientrun/ambient/blob/main/crates/network/src/client.rs"
click node_network_server "https://github.com/ambientrun/ambient/blob/main/crates/network/src/server.rs"
click node_network_protocol "https://github.com/ambientrun/ambient/blob/main/crates/network/src/proto/server.rs"
click node_ecs "https://github.com/ambientrun/ambient/blob/main/crates/ecs/src/query.rs"
click node_terrain "https://github.com/ambientrun/ambient/blob/main/crates/terrain/src/lib.rs"
click node_renderer "https://github.com/ambientrun/ambient/blob/main/crates/renderer/src/renderer.rs"
click node_asset_pipeline "https://github.com/ambientrun/ambient/blob/main/crates/asset_cache/src/lib.rs"
click node_wasm_runtime "https://github.com/ambientrun/ambient/blob/main/crates/wasm/src/shared/engine.rs"
click node_guest_api "https://github.com/ambientrun/ambient/blob/main/guest/rust/api_core/src/lib.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_ambient_cli,node_campfire,node_package_ops,node_package toneBlue
class node_client_app,node_server_runtime,node_network_client,node_network_server,node_network_protocol toneAmber
class node_ecs,node_terrain,node_renderer,node_asset_pipeline toneMint
class node_wasm_runtime,node_guest_api toneRose
class node_developer toneIndigo
```

## Components

### Platform workflow

- [Ambient CLI](https://github.com/ambientrun/ambient/blob/main/app/src/main.rs): `app/src/main.rs`
- [Campfire tools](https://github.com/ambientrun/ambient/blob/main/campfire/src/cli.rs): `campfire/src/cli.rs`
- [Package operations](https://github.com/ambientrun/ambient/blob/main/campfire/src/package.rs): `campfire/src/package.rs`
- [Game package](https://github.com/ambientrun/ambient/tree/main/guest/rust/packages): `guest/rust/packages`

### Game runtime

- [Client application](https://github.com/ambientrun/ambient/blob/main/web/client/src/app.rs): `web/client/src/app.rs`
- [Server runtime](https://github.com/ambientrun/ambient/blob/main/app/src/server/mod.rs): `app/src/server/mod.rs`
- [Network client](https://github.com/ambientrun/ambient/blob/main/crates/network/src/client.rs): `crates/network/src/client.rs`
- [Network server](https://github.com/ambientrun/ambient/blob/main/crates/network/src/server.rs): `crates/network/src/server.rs`
- [Network protocol](https://github.com/ambientrun/ambient/blob/main/crates/network/src/proto/server.rs): `crates/network/src/proto/server.rs`

### Engine services

- [Entity database](https://github.com/ambientrun/ambient/blob/main/crates/ecs/src/query.rs): `crates/ecs/src/query.rs`
- [Terrain systems](https://github.com/ambientrun/ambient/blob/main/crates/terrain/src/lib.rs): `crates/terrain/src/lib.rs`
- [PBR renderer](https://github.com/ambientrun/ambient/blob/main/crates/renderer/src/renderer.rs): `crates/renderer/src/renderer.rs`
- [Asset pipeline](https://github.com/ambientrun/ambient/blob/main/crates/asset_cache/src/lib.rs): `crates/asset_cache/src/lib.rs`

### Package execution

- [WASM runtime](https://github.com/ambientrun/ambient/blob/main/crates/wasm/src/shared/engine.rs): `crates/wasm/src/shared/engine.rs`
- [Guest Rust API](https://github.com/ambientrun/ambient/blob/main/guest/rust/api_core/src/lib.rs): `guest/rust/api_core/src/lib.rs`

### Other components

- **Developer**

## Connections

- Developer → Ambient CLI: launches (evidence: `app/src/main.rs`)
- Developer → Campfire tools: runs tools (evidence: `campfire/src/cli.rs`)
- Campfire tools → Package operations: dispatches (evidence: `campfire/src/cli.rs`)
- Package operations → Ambient CLI: invokes (evidence: `campfire/src/package.rs`)
- Ambient CLI → Client application: starts client
- Ambient CLI → Server runtime: starts server (evidence: `app/src/main.rs`)
- Client application → Network client: connects through (evidence: `web/client/src/app.rs`)
- Network client → Network server: exchanges game state (evidence: `crates/network/src/client.rs`)
- Network server → Network protocol: dispatches messages (evidence: `crates/network/src/server.rs`)
- Network server → Entity database: updates world
- Client application → WASM runtime: initializes (evidence: `web/client/src/app.rs`)
- WASM runtime → Guest Rust API: hosts packages
- Guest Rust API → Game package: implements
- Entity database → Network server: synchronizes state
- Asset pipeline → Game package: loads assets
- Client application → PBR renderer: renders game
- Terrain systems → Entity database: operates on world
- Developer → Game package: creates package
- Game package → WASM runtime: runs isolated
