Run tests Codacy Badge Gem Version


A collection of small classes allowing to implement CQRS API in ruby applications without too much of an effort.


Add this line to your application's Gemfile:

gem 'fast_cqrs'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install fast_cqrs



FastCqrs delivers transactions as the main piece of the request processing. A whole request processing is encapsulated within the transaction object, so it's easy to write unit tests for your endpoints without loading the whole framework while testing.

Also, it's super easy to inject dependencies when needed.

Basic transaction could look like this.

   # transactions/create_article.rb

  class CreateArticle < FastCqrs::Transaction
    def call(params, **)
      model = yield deserialize(params)
      yield authorize(model)
      yield create_article(model)


    def deserialize(params)

    def authorize(model)

    def create_article(model)
      Try { Article.create!(model) }

    def initialize
      @authorizer =
      @request =
  # articles_controller

  def create

  def create

Transaction blocks

Typical transaction consists of:

  • request - This parses the request body and modifies the input for an easy to use output.
  • authorizer - authorizes the parsed input against the given auth object
  • validator - validates the request
  • actions - methods making changes in the system.


After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to


Bug reports and pull requests are welcome on GitHub at This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

Publishing new version

  1. Push commit with updated version.rb file to the release branch. The new version will be automatically pushed to rubygems.
  2. Create release on github including change log.


The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the FastCqrs project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.