Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Elixir
  3. machinery

machinery

Apache-2.0Elixirv0.16.1

A lightweight Elixir state machine library with Phoenix integration, providing a simple DSL for managing state transitions.

GitHubGitHub
565 stars55 forks0 contributors

What is machinery?

Machinery is a lightweight state machine library for Elixir that provides a simple DSL for declaring states and transitions. It simplifies state management in applications by offering a clean, unobtrusive layer for modeling workflows and business logic, with built-in support for Phoenix projects.

Target Audience

Elixir developers, particularly those building Phoenix applications, who need to manage state transitions in models like user accounts, orders, or document workflows.

Value Proposition

Developers choose Machinery for its minimalistic design that integrates seamlessly with Elixir's functional paradigms, offering essential features like guard functions, callbacks, and persistence without imposing a heavy framework.

Overview

Elixir State machine thin layer for structs

Use Cases

Best For

  • Modeling business logic workflows in Elixir applications, such as order processing or user onboarding steps.
  • Adding state management to Phoenix schemas with automatic database persistence via a custom persist function.
  • Implementing audit trails by logging every state transition for debugging and compliance purposes.
  • Enforcing conditional transitions with guard functions that prevent invalid state changes based on business rules.
  • Handling side effects around transitions using before and after callbacks for actions like sending notifications.
  • Creating flexible state machines with wildcard transitions that apply from any state to a specific one.

Not Ideal For

  • Applications requiring complex state hierarchies like nested or parallel states, as Machinery only supports flat transitions.
  • Projects needing built-in graphical tools for designing or debugging state diagrams, since it's code-focused without visualization.
  • Teams that prefer convention-over-configuration frameworks with automated state machine generation from models or schemas.
  • Systems where state transitions must be distributed or handled asynchronously with built-in support, as Machinery is synchronous and requires manual async handling.

Pros & Cons

Pros

Simple DSL Configuration

Declaring states and transitions uses a clean keyword-based DSL, as shown in the example where states and transitions are defined concisely in a module.

Built-in Phoenix Integration

Seamlessly integrates with Phoenix and Ecto schemas, with specific instructions for adding state fields and using persist functions for database persistence.

Flexible Guard Functions

Guard functions with pattern matching allow conditional transitions, preventing invalid changes based on business logic, demonstrated in the guard_transition example.

Comprehensive Callback System

Supports before and after callbacks for side effects, enabling actions like notifications or data updates around transitions, with examples for each.

Cons

Manual Persistence Setup

Users must implement their own persist function to save state changes to the database, adding boilerplate code and potential for errors if not handled correctly.

Limited Advanced Features

Lacks support for complex state machine patterns like hierarchical states, history states, or event sourcing, which might be necessary for sophisticated workflows.

Callback Error Handling

The README does not specify how errors in callbacks are managed, risking silent failures if callbacks raise exceptions without proper error handling.

Frequently Asked Questions

Quick Stats

Stars565
Forks55
Contributors0
Open Issues8
Last commit2 years ago
CreatedSince 2016

Tags

#elixir-lang#elixir#statemachine#callbacks#workflow#phoenix#dsl#ecto#phoenix-framework#structs#dashboard#state-machine#state#finite-state-machine#machine#state-management#transitions

Built With

E
Elixir
P
Phoenix

Included in

Elixir13.1k
Auto-fetched 18 minutes ago

Related Projects

flowflow

Computational parallel flows on top of GenStage

Stars1,613
Forks88
Last commit1 year ago
witchcraftwitchcraft

Monads and other dark magic for Elixir

Stars1,232
Forks60
Last commit2 years ago
fusefuse

A Circuit Breaker for Erlang

Stars513
Forks51
Last commit4 years ago
matrexmatrex

A blazing fast matrix library for Elixir/Erlang with C implementation using CBLAS.

Stars489
Forks32
Last commit5 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub