#Ranvier Use Cases
Version: 0.43.0 Updated: 2026-04-03 Applies to: ranvier-core, ranvier-runtime, ranvier-std Category: Guide
Ranvier is a web backend framework. Because its architecture is robust, it works across many complex logic domains.
Each use case below shows the core Axon pipeline for a real-world domain, with links to the full working example and cookbook where available.
#1. Saga Compensation --- Payment Gateway
When a multi-step order process fails at step N, all previous steps must be rolled back in reverse. Ranvier's saga policy attaches a compensation function to each forward step, guaranteeing automatic LIFO rollback on failure.
let order = Axon::typed::<OrderRequest, String>("order-saga")
.with_saga_policy(SagaPolicy::Enabled)
.then_compensated(reserve_inventory, release_inventory)
.then_compensated(charge_payment, refund_payment)
.then(complete_order);Example: saga-compensation
Cookbook: cookbook_saga_compensation_patterns.md
#2. Cascade Screening --- AML/KYC
Sequential compliance checks where each screen can reject the application early. Place the cheapest and fastest checks first to minimize wasted computation. Each screen is independently testable and replaceable.
let screening = Axon::typed::<CustomerApplication, String>("kyc-screening")
.then(sanctions_check)
.then(pep_check)
.then(risk_scoring)
.then(document_verification);Example: cascade-screening
Cookbook: cookbook_cascade_screening.md
#3. Multi-Step Pipeline --- AI Agent
An LLM agent pipeline classifies user intent, selects the appropriate tool, executes it, and formats the response. Each step is a separate transition that can be tested, replaced, or wrapped with guards independently.
let pipeline = Axon::typed::<Query, String>("agent-pipeline")
.then(classify_intent)
.then(select_tool)
.then(execute_tool)
.then(format_response);Example: llm-agent-pipeline
Cookbook: cookbook_multi_step_pipeline.md
#4. Sensor Decision Loop --- Smart Farm IoT
Sensor readings arrive continuously and must be normalized, checked for anomalies, and acted upon. The pipeline transforms raw readings into decisions such as turning on irrigation or adjusting ventilation.
let iot = Axon::typed::<SensorReading, String>("iot-decision")
.then(normalize_reading)
.then(detect_anomalies)
.then(decide_action);Example: sensor-decision-loop
#5. Triage Branching --- Patient Triage
Patient intake data flows through vitals checking, severity classification, and department routing. The final transition returns Outcome::Branch to route patients to emergency, urgent care, or general ward pathways.
let triage = Axon::typed::<PatientIntake, String>("triage")
.then(check_vitals)
.then(classify_severity)
.then(route_department);
// Outcome::Branch routes to emergency/urgent_care/general_wardExample: triage-branching
#6. Rule Chain --- Benefits Eligibility
A chain of independent business rules evaluates an applicant's eligibility. Each rule can short-circuit with a rejection or pass the applicant forward. Rules are individually testable and can be reordered without code changes.
let eligibility = Axon::typed::<Applicant, String>("benefits-check")
.then(age_rule)
.then(income_rule)
.then(residency_rule)
.then(benefit_cap_rule);Example: eligibility-rule-chain
#When Ranvier Is Not the Right Choice
Ranvier is designed for domains where multi-step logic, auditability, and controlled branching matter. For simpler workloads, a lighter framework is a better fit.
| Workload | Better Alternative | Why |
|---|---|---|
| Simple CRUD REST API | Axum or actix-web | No multi-step orchestration needed; a standard handler function is sufficient. |
| High-throughput proxy/gateway | Axum + Tower | Proxy workloads need minimal per-request logic and maximum throughput; Tower middleware is purpose-built for this. |
| Pure static site / asset delivery | Any standard server (nginx, Caddy, object storage/CDN, tower-http::ServeDir) |
Asset delivery itself is the main workload; no business logic orchestration to justify Ranvier. |
Serving a built SPA next to API routes is still a valid Ranvier use case via
serve_dir() + spa_fallback(). The table above is about pure static hosting,
where asset delivery itself is the product.