For the complete documentation index optimized for AI agents, see llms.txt or llms-full.txt. A markdown version of this page is available by appending.mdto the URL or sendingAccept: text/markdown.
Workflow
For AI agents: the documentation index is at llms.txt (full corpus: llms-full.txt). A markdown source for this page is /building-stacks/workflow.md.
Building a stack follows a straightforward four-step workflow: define your data model in Rust, compile to build the stack, deploy to Arete Cloud, and connect from your application.
Write Rust
Define entities using #[arete] macro
Build Stack
Compile with cargo build
Deploy via CLI
Push to cloud with a4 up
Connect from App
Use generated SDK to stream
Step 1: Write Your Stack Definition
Section titled “Step 1: Write Your Stack Definition”A stack definition is a Rust module that maps structure from the IDL into a rich, queryable state ready to consume in your application layer. Using Arete’s expressive DSL, you define entities, field mappings, aggregations, computed fields, relationships, and more — all in declarative Rust syntax.
use arete::{arete, Stream};
#[arete(idl = "my_program.json")]pub mod ore_stack { #[entity] #[derive(Stream)] pub struct OreRound { #[map(RoundState::round_id, primary_key)] pub round_id: u64,
#[map(RoundState::motherlode)] pub motherlode: u64,
#[map(RoundState::difficulty)] pub difficulty: u64, }}The Rust code is purely declarative—you’re describing what data you want, not how to fetch it. Arete handles all the account parsing, event processing, and state management.
→ Stack Definitions — Learn the full DSL syntax
Step 2: Build the Stack
Section titled “Step 2: Build the Stack”When you compile your Rust project, Arete macros transform your definition into a portable JSON specification. This is the compiled representation of your data pipeline.
cargo buildAfter building, you’ll find the generated specification in .arete/:
my-stack/├── src/lib.rs├── Cargo.toml└── .arete/ └── OreStack.stack.json # Generated stack specificationThe .stack.json file contains everything Arete needs to execute your pipeline: all entities, field mappings, aggregation logic, key resolution rules, and more. A single stack file can contain multiple entities.
Step 3: Deploy with the CLI
Section titled “Step 3: Deploy with the CLI”The Arete CLI (a4) handles deployment to Arete Cloud. A single command pushes your stack specification, builds the execution environment, and deploys to a global edge network.
# Initialize project config (creates arete.toml)a4 init
# Deploy your stacka4 upOn success, you’ll receive a WebSocket URL:
✔ Stack pushed (v1)✔ Build completed🚀 Deployed to: wss://ore.stack.arete.run→ CLI Reference — Full command documentation
Step 4: Generate SDK and Connect
Section titled “Step 4: Generate SDK and Connect”Once deployed, generate a typed SDK for your stack:
a4 sdk create typescript orea4 sdk create rust oreThis creates a package containing the stack definition that tells the Arete client how to interact with your feed, including all entities and their views. Import it in your application:
import { AreteProvider, useArete } from "arete-react";import { ORE_STREAM_STACK } from "arete-stacks/ore"; // Generated in Step 4
// Wrap your app<AreteProvider> <App /></AreteProvider>;
// In your componentconst stack = useArete(ORE_STREAM_STACK);const { data: rounds } = stack.views.OreRound.list.use();import { Arete } from "arete-typescript";import { ORE_STREAM_STACK } from "arete-stacks/ore"; // Generated in Step 4
const a4 = await Arete.connect(ORE_STREAM_STACK);
for await (const round of a4.views.OreRound.list.use()) { console.log("Round updated:", round);}use a4_sdk::prelude::*;use ore_stack::{OreStack, OreRound}; // Generated in Step 4
#[tokio::main]async fn main() -> anyhow::Result<()> { // Connect to your deployed stack let a4 = Arete::<OreStack>::connect().await?;
// Stream updates via typed views let mut stream = a4.views.ore_round.latest().listen();
while let Some(round) = stream.next().await { println!("Round #{:?}: motherlode={:?}", round.id.round_id, round.state.motherlode); }
Ok(())}Share the generated SDK with your team or publish it — anyone with the SDK can connect to your stack’s feed (assuming they’re authorized).
→ Your First Stack — Complete tutorial with working code
Next Steps
Section titled “Next Steps”| Goal | Page |
|---|---|
| Understand the DSL in depth | Stack Definitions |
| Set up your development environment | Installation |
| Build a complete example | Your First Stack |
| Learn all available macros | Macro Reference |
| Master aggregation strategies | Population Strategies |