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
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 HMVCMeet the wizards behind the magic ✨
Mr. Anh Nguyen
CTO, FounderI created HMVC with a vision to solve the inherent complexity issues in large-scale applications. By introducing a hierarchical structure to the traditional MVC pattern, we've established a framework-agnostic approach that brings clarity and maintainability to complex codebases. It's incredibly rewarding to see how this architecture has helped numerous teams reduce technical debt and build more sustainable applications.
Mr. Minh Tang
Lead Architect, MaintainerTaking the foundational principles, I evolved it into a powerful, modern architecture that addresses today's development challenges. My focus has been on enhancing developer experience through clear abstractions and maintainable patterns. The architecture's flexibility allows teams to gradually adopt it in existing projects, making it an ideal solution for both new developments and legacy system modernization.