Business4s Blog

Space for the articles related to business4s.org community

Featured

Workflows4s Finally Released — You Might Hate Your Business Processes a Little Less

--

TL;DR: This article covers why Workflows4s was created, its current state, and planned future developments. For technical details, visit the docs.

What is Workflows4s?

Workflows4s is a Scala library for defining and executing workflows. Think of it as a business process automation engine — but designed with general-purpose modeling in mind. It’s ideal for long-running, event-driven, and stateful logic that needs to evolve alongside your domain.

Key features

  • Type-safe definitions: Leverages Scala’s type system to catch invalid compositions at compile time.
  • Event-sourced persistence: Every non-deterministic operation emits events, allowing for replay, inspection, and safe recovery.
  • Visualizations: Built-in support for generating clear, insightful diagrams of workflows and their runtime state.
  • Multiple runtimes: Includes in-memory, Pekko, and Postgres runtimes — with extensibility for others.
  • Serverless architecture: Runs without a dedicated external server, relying only on a database.
  • Rich operator set: Includes built-in support for signals, timers, error handling, interruptions, parallel execution, loops, and sub-workflows.
  • Simplicity: Fully transparent and IDE-friendly (no macros included). Compositional but without hardcore FP jargon and concepts.

Compared to existing solutions, Workflows4s brings these features together in a cohesive and consistent way — whereas most existing tools cover only a subset of them. A detailed comparison is available here.

How Does It Look?

Here is a short sneak peak into the API.

object Context extends WorkflowContext {
override type State = String
}
import Context.*

// define the workflow
val hello = WIO.pure("Hello").autoNamed
val world = WIO.pure.makeFrom[String].value(_ + " World!").autoNamed
val workflow = hello >>> world

// render workflow definition
println(MermaidRenderer.renderWorkflow(workflow.toProgress).toViewUrl)
// https://mermaid.live/edit#base64:eyJjb2RlIjoiZmxvd2NoYXJ0IFREXG5ub2RlMEB7IHNoYXBlOiBjaXJjbGUsIGxhYmVsOiBcIlN0YXJ0XCJ9XG5ub2RlMVtcIkhlbGxvXCJdXG5ub2RlMCAtLT4gbm9kZTFcbm5vZGUyW1wiV29ybGRcIl1cbm5vZGUxIC0tPiBub2RlMlxuIn0=

// run the workflow
val runtime = InMemorySyncRuntime.default[Context.Ctx](workflow, initialState = "")
val wfInstance = runtime.createInstance(())
wfInstance.wakeup()
println(wfInstance.queryState())
// Hello World!

// render instance progress
println(MermaidRenderer.renderWorkflow(wfInstance.getProgress).toViewUrl)
// https://mermaid.live/edit#base64:eyJjb2RlIjoiZmxvd2NoYXJ0IFREXG5ub2RlMDo6OmV4ZWN1dGVkQHsgc2hhcGU6IGNpcmNsZSwgbGFiZWw6IFwiU3RhcnRcIn1cbm5vZGUxW1wiSGVsbG9cIl06OjpleGVjdXRlZFxubm9kZTAgLS0-IG5vZGUxXG5ub2RlMltcIldvcmxkXCJdOjo6ZXhlY3V0ZWRcbm5vZGUxIC0tPiBub2RlMlxuY2xhc3NEZWYgZXhlY3V0ZWQgZmlsbDojMGUwXG4ifQ==

You can run it yourself in Scastie!

Why Now?

Workflows4s is the result of three years of exploration and one year of focused development. It draws lessons from real-world usage of tools like Camunda, Temporal, Netflix Conductor, and custom event-sourced platforms.

The goal: make workflows simpler and more maintainable by addressing the common pain points in today’s tooling — boilerplate, lack of type safety, unclear recovery mechanisms, overly complex architectures and, most of all, lack of help in workflow understandability.

Workflows4s is now tested, validated, and ready for broader adoption!

Is It Production-Ready?

Yes — with some caveats.

Although it’s currently versioned at 0.1.x, it adheres to the Business4s philosophy: only release software that’s production-ready. That means:

  • The library is stable, well-tested, and ready for longer-term maintenance.
  • It already covers the most common workflow scenarios.
  • It can be used in production environments by early adopters.

⚠️ However, the public API may still evolve. We recommend not building other libraries on top of it yet to avoid binary compatibility issues. See the Production Readiness docs section for detail and up-to-date status.

What’s Next?

Here’s what’s on the roadmap:

  • Web UI: A dashboard for managing and visualizing workflow instances.
  • Telemetry: Better observability for running workflows.
  • Instance tracking: Store and query active/past workflow executions.
  • Retries: Built-in handling of transient errors.
  • Linter: Guardrails for workflow correctness and best practices.

Part of a Bigger Whole

Workflows4s is the second library released under the Business4s initiative, after Decisions4s. While the two are independent, they share a common vision:

Domain-centric development for Scala — empowering developers to build systems that closely reflect real business needs.

If you missed the Business4s announcement, now’s a good time to catch up!

Summary

Workflows4s is a lightweight, type-safe alternative to traditional workflow engines. If you’ve been building custom orchestration logic — or wrestling with the complexity of existing platforms — give Workflows4s a try.

Read the Docs, join discussions on our Discord, follow development updates on YouTube, and explore the code on GitHub.

--

--

Business4s Blog
Business4s Blog
Voytek Pituła
Voytek Pituła

Written by Voytek Pituła

Generalist. An absolute expert in faking expertise. Claimant to the title of The Laziest Person in Existence. Staff Engineer @ SwissBorg.

Responses (3)