The Advanced Business Logic Framework

Finally know where to put your code!

Trailblazer gives you a high-level architecture for web applications. It extends the basic MVC pattern with new abstractions. Rock-solid conventions that go far beyond database table naming or route paths let you focus on your application code, minimize bugs and improve the maintainability.

Trailblazer’s file structure organizes by CONCEPT, and then by technology.

  • THOUSANDS of users find this more intuitive and easier to navigate.
  • It embraces the COMPONENT STRUCTURE of your code.
  • Huge teams working on complex projects have it easier not to get into each others’ way.
  • Once a concept’s CODE IS TESTED it won’t break anywhere else.
  • The modular structure SIMPLIFIES REFACTORING in hundreds of legacy production apps.

The new abstractions in Trailblazer are optional. Only use what you need.

  • CONTRACT Form objects to validate incoming data.
  • POLICY to authorize code execution per user.
  • OPERATION A service object implementation with functional flow control.
  • VIEW MODEL Components for your view code.
  • REPRESENTER for serializing and parsing API documents.
  • DESERIALIZER Transformers to parse incoming data into structures you can work with.

Legacy app, refactoring or green-field?

Trailblazer helps improving your software in all kinds of systems and applications.


The Trailblazer gems work with any Ruby framework. We provide glue code for Rails and Hanami, but there are TRB-powered apps in Roda, Grape, Sinatra and many more out there.


You can start using Trailblazer in existing, massive applications today. Refactorings can be applied step-wise, legacy code can be minimized as you go. Remember: Rome wasn’t build in one day, either.


Our promise to the community: Trailblazer 2 will be supported until end of 2020 or longer. Our API design makes it easy to provide automatic upgrading and backward-compatibility so you won’t have to change code when we ship updates.

Build to Refactor

Our patterns are developed to be used in highly complex, existing, messy legacy applications. Trailblazer is designed to refactor old code - you do not have to rewrite the entire system to get a better architecture.

Test first

By restructuring business code, application behavior can be tested more efficiently with more unit and less integration tests. Trailblazer engineers do enjoy the simplicity of testing and the speedup of the test suites.

It's real!

Trailblazer is in use in thousands of production applications. Our patterns have evolved over a decade of engineering, our gems are mature and battle-tested. And: we will never stop innovating.

We walk the walk.

Trailblazer defines patterns for a better architecture, and gives you implementations to use those patterns in your applications. Your software will be better structured, more consistent and with stronger, faster, and way simpler tests.

Our high-level architecture and enterprise-ready™ gems will prevent you from reinventing the wheel again and again - you and your team are free to think about the next awesome feature.

We love legacy apps.

By standardizing the business logic, new developers can be onboarded faster with help of our free documentation. Trailblazer’s patterns cover 75% of daily business code’s structure - you will feel the power of strong conventions within the first hours.

If that’s not enough, we provide on-site training, premium support and consulting. Dozens of companies worldwide trust us already.

Want some code?


class SongsController < ApplicationController
  def create
    run Song::Create do |result|
      redirect_to songs_path(result["model"])

CONTROLLER They end up as lean HTTP endpoints. No business logic is to be found in the controller, they instantly delegate to their respective operation.

Oh, and did we say there won’t be controller tests anymore? That’s right. Only unit and integration tests.

MODEL Models contain associations, scopes and finders. Only persistence logic, no callbacks, no validations, no business logic here.

class Song < ActiveRecord::Base
  has_many   :albums
  belongs_to :composer

Any number of POLICYs can be used in an operation to grant or deny access to functionality.

class Application::Policy < Pundit::Policy
  def create?

Also, use your choice of authorization framework.

The OPERATION is the heart of the Trailblazer architecture. It orchestrates validations, policies, models, callback and business logic by leveraging a functional pipeline with built-in error handling.

class Song::Create < Trailblazer::Operation
  step Model( Song, :new )
  step Policy::Pundit( Application::Policy, :create? )
  step Contract::Build( constant: Song::Contract::Create )
  step Contract::Validate()
  step Contract::Persist()
  fail Notifier::DBError
  step :update_song_count!

  def update_song_count!(options, current_user:, **)

Designed to be a stateless object, the operation passes around one mutable options hash and makes heavy use of Ruby keyword arguments - if you want it.

class Song::Contract::Create < Reform::Form
  property :title
  property :length

  validates :title, presence: true

Validations are implemented with CONTRACT.

Trailblazer supports Reform and Dry::Schema validations in any number.

Any dependency, such as the current user, must be injected from the outside.

The concept of global state does not exist in Trailblazer, which leads to simplified, mock-free testability and concurrent-ready code.

And the best: there’s only one way to run an operation.

  { title: "Roxanne", length: 300 }, # params
  "current_user": current_user       # dependencies
describe Song::Create do
  it "prohibits empty params" do
    result = Song::Create.({})

    expect(result).to be_failure
    expect(result["model"]).to be_new

Clumsy, slow controller tests are history. Now that all your business logic is controlled by the operation, SIMPLE UNIT TESTS can test any edge-case scenario or avoid regressions.

Trailblazer’s encapsulation makes a programmer’s life better.



Your logo here? Send it to us →