Skip to content
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 .md to the URL or sending Accept: 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.

1

Write Rust

Define entities using #[arete] macro

2

Build Stack

Compile with cargo build

3

Deploy via CLI

Push to cloud with a4 up

4

Connect from App

Use generated SDK to stream


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


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.

Terminal window
cargo build

After building, you’ll find the generated specification in .arete/:

my-stack/
├── src/lib.rs
├── Cargo.toml
└── .arete/
└── OreStack.stack.json # Generated stack specification

The .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.


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.

Terminal window
# Initialize project config (creates arete.toml)
a4 init
# Deploy your stack
a4 up

On success, you’ll receive a WebSocket URL:

✔ Stack pushed (v1)
✔ Build completed
🚀 Deployed to: wss://ore.stack.arete.run

CLI Reference — Full command documentation


Once deployed, generate a typed SDK for your stack:

Terminal window
a4 sdk create typescript ore

This 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 component
const stack = useArete(ORE_STREAM_STACK);
const { data: rounds } = stack.views.OreRound.list.use();

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


GoalPage
Understand the DSL in depthStack Definitions
Set up your development environmentInstallation
Build a complete exampleYour First Stack
Learn all available macrosMacro Reference
Master aggregation strategiesPopulation Strategies