High Level MVC

Revolutionize Your Codebase with HMVC Rails

Wasting hours deciding where to put your code?
Pulling your hair out with validation spaghetti?
Drowning in bloated business logic?
logo
Why choose HMVC

Refactor for clarity
lessen debt

Missing abstractions

Web frameworks excel at routing and rendering but often fall short in structuring business logic. Without clear abstractions, code becomes tangled, complex, and difficult to maintain.

Our Solution

HMVC introduces the "operation" abstraction, breaking logic into well-defined steps. This improves flow control, enhances maintainability, and makes complex processes more manageable.

Rock-Solid Conventions

With the Railway pattern, HMVC streamlines error handling, minimizes excessive conditionals, and boosts code reusability through inheritance and composition—resulting in cleaner, more efficient development.

Architectural Mastery

MVC: The Next Generation
Evolution, not Revolution - Because we don't break things, we make them better!

MVC & HMVC ComplexityOverview LayerFlow Control

MVC & HMVC Complexity

Visualizing the relationship between codebase size and maintenance complexity. While traditional Rails shows exponential pain growth as projects scale, HMVC maintains linear complexity through structured organization and clear boundaries. This architectural approach ensures sustainable development for both small and large applications.

Overview Layer

Flow Control

Abstraction Layers

CORE MISSION: ENSURE SOFTWARE LONGEVITY
Achieve sustainable and maintainable software architecture
through strategic implementation of modern abstraction layers.

Slim Controller

Controllers are streamlined to focus on HTTP requests and routing, ensuring they remain clean and efficient.

By delegating all business logic to specialized Operations, we maintain clear boundaries and enhance code maintainability, making it easier to manage and scale.

# app/controllers/sessions_controller.rb
class SessionsController < ApplicationController
  def create
    operator = Auth::LoginOperation.new(params:)
    operator.call
    return redirect_to dashboard_path if operator.success?

    render :new
  end
end

Domain Model

Models are refined to excel at managing data relationships and database interactions, their core strengths.

# app/models/user.rb
class User < ApplicationRecord
  has_secure_password

  has_many :login_activities
  has_many :active_sessions
end

Smart Validation

Dedicated form objects handle all data validation, creating a clear separation between validation rules and business logic.

This proactive approach ensures data integrity early in the request cycle, preventing invalid data from compromising your core business operations and enhancing system reliability.

# app/forms/sessions/create_form.rb
class Sessions::CreateForm < ApplicationForm
  attribute :email
  attribute :password
  attribute :remember_me, :boolean, default: false

  validates :email, presence: true, email: true
  validates :password, presence: true
end

Business Logic

Operations act as orchestrators, breaking down complex business processes into clear, sequential steps.

Each operation encapsulates a specific workflow, making your code more testable, maintainable, and easier to understand as your application grows, promoting code reuse and scalability.

# app/operations/sessions/create_operation.rb
class Sessions::CreateOperation < ApplicationOperation
  attr_reader :user

  def call
    step_validate
    step_track_login
    step_create_session
  rescue Auth::LoginError => e
    fail!(message: e.message)
  end
end

Ready to level up your Rails architecture?

Get Started with HMVC

Meet the wizards behind the magic ✨