#Quickstart: Build Your First Ranvier Service
Version: 0.51.0
Updated: 2026-09-29
Applies to: ranvier facade
Category: Getting Started
This is the canonical first-user path. It uses the public ranvier facade so
your application does not need to assemble Ranvier's internal crates.
#Prerequisites
- Rust 1.93.0 or newer
- Cargo
rustc --version#1. Install through the facade
Use this path for a new application:
cargo new ranvier-quickstart
cd ranvier-quickstart
cargo add ranvier@0.51.0
cargo add tokio@1 --features macros,rt-multi-threadDo not start by adding ranvier-core, ranvier-runtime, or ranvier-http
separately. Those crates remain available for advanced integration, but the
facade is the maintained onboarding contract.
#2. Add one public-facade transition and native HTTP ingress
Replace src/main.rs with:
use ranvier::prelude::*;
use ranvier::runtime::ClosureTransition;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let hello = Axon::<(), (), String>::new("hello").then(ClosureTransition::new(
"greet",
|_input: (), _bus: &mut Bus| Outcome::next("Hello, Ranvier!".to_string()),
));
Ranvier::http()
.bind("127.0.0.1:3000")
.route("/", hello)
.run(())
.await?;
Ok(())
}Run the service:
cargo run --lockedIn another terminal, request http://127.0.0.1:3000/:
curl http://127.0.0.1:3000/This example uses the public ranvier package facade and its
ClosureTransition adapter. Keep the generated Cargo.lock so the commands
below can use --locked and reproduce the dependency resolution you tested.
The runnable source is maintained at `fixtures/quickstart-public/src/main.rs`.
#3. Inspect the Schematic, branch, and recover from a pure failure
Create src/bin/onboarding-flow.rs with this second small program:
use ranvier::prelude::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let flow = Axon::<String, String, String>::new("helpdesk")
.then_fn("validate", |input: String, _bus: &mut Bus| {
if input == "invalid" {
Outcome::Fault("invalid request".to_string())
} else {
Outcome::Next(input)
}
})
.then_fn("route", |input: String, _bus: &mut Bus| {
if input == "billing" {
Outcome::Branch("billing-review".to_string(), None)
} else {
Outcome::Next(input)
}
});
for node in &flow.schematic().nodes {
println!("schematic_node={}", node.label);
}
let mut bus = Bus::new();
let failed = flow.execute_simple("invalid".to_string(), &mut bus).await;
println!("first_attempt={failed:?}");
let mut bus = Bus::new();
let retried = flow.execute_simple("billing".to_string(), &mut bus).await;
println!("corrected_attempt={retried:?}");
Ok(())
}Run it from the project directory:
cargo run --locked --bin onboarding-flowExpected output:
schematic_node=helpdesk
schematic_node=validate
schematic_node=route
first_attempt=Fault("invalid request")
corrected_attempt=Branch("billing-review", None)Branch returns a routing decision to the caller; it does not invoke a
destination automatically. Here the first run fails input validation and the
second run uses corrected input. This is safe as a teaching example because
both transitions are pure and perform no external side effect. Do not infer
that an arbitrary failed workflow can be retried safely. The source is kept at
`fixtures/quickstart-public/src/bin/onboarding-flow.rs`.
The state-persistence-demo is an in-memory example. It helps explain local
checkpoint/resume behavior but does not prove PostgreSQL durability, process
restart recovery, or a production persistence contract; those checks remain
open under M427-RQ1/RQ4.
#4. Continue with three maintained workflows
The next learning surface is deliberately bounded to three workflows:
| Workflow | What it proves | Support contract |
|---|---|---|
| Typed state progression | compile-time handoff between Axon steps | Canonical / Developer gate |
| Typed JSON native HTTP | typed request/response boundary through Ranvier ingress | Supported / Release gate |
| Bus capability policy | explicit resource presence and access policy | Supported / Release gate |
From a Ranvier source checkout, compile the exact workflow set with:
cargo check -p typed-state-tree -p typed-json-api -p bus-capability-demo --lockedThese packages are part of the recurring candidate compile contract. They do not require external runtime services.
#5. Choose native or hybrid at the HTTP boundary
| Starting point | Choose | Why |
|---|---|---|
| New service whose endpoints are decision workflows | Native Ranvier::http() |
One visible ingress/guard/Outcome model and Schematic-aware routing |
| Existing Axum service with selected complex endpoints | Axum + Ranvier hybrid | Keep Axum routing and Tower middleware; invoke Axon only for decision logic |
Native is the default onboarding path. Hybrid is a deliberate integration choice, not a second installation recipe. Tower/Axum middleware remains outside Ranvier's Schematic unless the application bridges that state into the Bus explicitly.
#6. Support boundary
- Stable Candidate APIs are governed by the API stability contract.
- Canonical examples run in the Developer gate; Supported examples run in the Release gate.
- Schema-described
Branch,Jump, andEmitpayloads and runtime Bus presence checks are not compile-time type guarantees. - macOS and the recurring platform/MSRV matrix are not claimed verified until M419 publishes that evidence.
#7. Experimental and Lab paths come last
After the quickstart and the three maintained workflows compile, use the Examples Explorer to find Lab or experimental integrations. Those examples are useful references but are not part of the routine Developer or Release support promise.