A Rust business workflow package inspired by viewflow/viewflow, designed for loose coupling and production usage.
Language index: docs/README.md
- English Usage
- 简体中文使用文档
- 繁體中文使用文件
- Deutsch Nutzung
- Español Uso
- Français Utilisation
- Italiano Utilizzo
- 日本語 使い方
- 한국어 사용 가이드
- Português Uso
- Русский Использование
- Српски Употреба
- Қазақша Қолдану
- Workflow core engine independent of web framework
- Optional web adapters for Axum and Actix-web
- Database abstraction trait (
WorkflowDatabase) with pluggable backends - Built-in SQLx backends: SQLite / MySQL / PostgreSQL
- In-memory backend for tests and lightweight deployments
- API abstraction layer (
WorkflowApi) separated from transport - Multi-language task labels in sample flow (
en,zh-CN,zh-TW)
src/core: workflow domain model + engine + workflow definitionssrc/db: database trait and backend implementationssrc/api: API contract + Axum/Actix adaptersexamples: runnable demo apps
The coupling direction is one-way:
- Web layer depends on API trait
- API depends on workflow engine trait
- Engine depends on workflow/database traits
- Custom implementations can replace any layer
cargo add rust-viewflowaxum(default): enables Axum router integrationactix: enables Actix-web scope integration
Examples:
cargo check --all-features --examplesuse std::sync::Arc;
use rust_viewflow::{
create_axum_router,
migrate_sqlite,
DefaultWorkflowApi,
DefaultWorkflowEngine,
LeaveRequestWorkflow,
SqliteDatabase,
};
use sqlx::SqlitePool;
# async fn run() -> Result<(), Box<dyn std::error::Error>> {
let pool = SqlitePool::connect("sqlite::memory:").await?;
migrate_sqlite(&pool).await?;
let db = Arc::new(SqliteDatabase::new(pool));
let engine = Arc::new(DefaultWorkflowEngine::new(db.clone()));
engine.register_workflow(Arc::new(LeaveRequestWorkflow::new(db)));
let api = Arc::new(DefaultWorkflowApi::new(engine));
let router = create_axum_router(api);
# let _ = router;
# Ok(()) }The sample leave_request flow includes:
- Manager approval task
- HR approval task (if manager approves)
- Workflow completion or cancellation
You can run:
cargo run --example leave_request
cargo run --example leave_request_actix --features actixThen test endpoints:
./test_api.shPOST /workflows- create a workflow instanceGET /workflows/{id}- get workflow detailsGET /workflows/{id}/tasks- list workflow tasksPOST /tasks/{id}/complete- complete a task with payload
Like Viewflow's i18n-friendly model, task naming can be locale-aware. In sample workflow:
locale=zh-CN: Chinese (Simplified)locale=zh-TW: Chinese (Traditional)- default: English
You can extend this by implementing your own WorkflowDefinition with custom localization strategy.
cargo fmt
cargo check --all-features --examples
cargo testOne-shot release helper:
./release.sh [repo-url] [version] [--publish] [--no-commit] [--no-push] [--skip-tests] [--skip-package] [--skip-dry-run]Common flows:
# Local preflight only (no commit/push/publish)
./release.sh 0.1.0 --no-push --no-commit
# Push to GitHub, run checks, create and push tag
./release.sh https://github.com/<owner>/rust-viewflow.git 0.1.0
# Full release to crates.io
./release.sh https://github.com/<owner>/rust-viewflow.git 0.1.0 --publishDual-licensed under either of:
- MIT License (LICENSE-MIT)
- Apache License, Version 2.0 (LICENSE-APACHE)
at your option.