Skip to content
Yoni Amir edited this page Jun 3, 2025 · 4 revisions

Flow Framework

Flow Basics

Flow is a business logic framework that encourages the separation of business logic into Operations and Flows. Operations are responsible for performing individual tasks while Flows orchestrate operations together.

Table of Contents

Core Concepts

  • Getting Started - Installation and basic setup instructions
  • Flows - Orchestrate operations and manage business logic flow
  • Operations - Individual business logic components with accessors
  • States - Manage input, output, and derivative data with validations

Advanced Features

  • Errors - Exception handling, failures, and callback events
  • Transactions - Wrap flows and operations in database transactions
  • Statuses - Track and manage operation status codes
  • Inheritance - Extend and customize flows and operations

Development & Testing

  • Testing - Comprehensive testing setup for flows, operations, and states
  • Utilities - Callbacks, memoization, and logging utilities

Advanced Topics

  • Contributing - Development guidelines and contribution process

Key Benefits

🏗️ Structure - Separates business logic from controllers and models 🔄 Reusability - Operations can be shared across multiple flows 🧪 Testability - Each operation and flow can be tested in isolation 📊 Transparency - Clear visibility into business process execution ⚡ Performance - Built-in memoization and optimization features

Quick Reference

# Define an operation
class CreateUser < FlowBase
  state :name, :email

  def execute
    User.create!(name: name, email: email)
  end
end

# Use in a flow
class UserRegistrationFlow < FlowBase
  state :user_params

  def execute
    run CreateUser, user_params
    run SendWelcomeEmail, email: state.user.email
  end
end

Getting Started

  1. Install - Add to your Gemfile and configure
  2. Learn Flows - Understand how to orchestrate business logic
  3. Create Operations - Build reusable business logic components
  4. Manage State - Handle data flow and validation
  5. Add Testing - Set up comprehensive test coverage

Ready to build better business logic? Start with the Getting Started guide!

Clone this wiki locally