The Age of the 'Majestic Monolith'
To understand Hanami's impact, you first have to understand what it reacted against. For much of modern web development, particularly in the Ruby world, Ruby on Rails has been the undisputed king. Its 'convention over configuration' approach allows developers
to build functional applications with incredible speed. This led to the era of the 'majestic monolith'—a single, large codebase containing everything from the user interface to deep business logic. This approach is fantastic for getting a product to market quickly. But as these applications scale, that magic can start to feel like a curse. The tightly coupled nature of the code means a small change in one area can have unforeseen consequences elsewhere. Teams get bogged down, testing slows to a crawl, and the once-majestic monolith starts to feel more like a tangled mess that’s difficult to maintain.
Hanami's Bet on Clean Architecture
Launched in 2014, Hanami presented a fundamentally different philosophy. Instead of prioritizing convention and speed above all, its creator, Luca Guidi, focused on long-term maintainability, testability, and code clarity. Hanami is built on the principles of Clean Architecture, a design paradigm that enforces strict boundaries between different parts of an application. The core idea is simple but powerful: your business logic—the rules and processes that make your app unique—should not be dependent on the web framework itself. Where Rails mixes database concerns directly into its models (via ActiveRecord), Hanami explicitly separates the application's core logic from details like the database or the web server. This is less about writing code faster today and more about ensuring the code is still understandable and manageable years from now.
Building with 'Slices,' Not Just Layers
Perhaps the most transformative concept Hanami introduces is 'slices'. Think of a large application not as one giant entity, but as a collection of mini-applications, or slices, that work together. For example, the billing system can be one slice, user authentication another, and inventory management a third. Each slice is self-contained with its own logic and clear boundaries. This modular approach has profound implications. A developer can work on the billing slice with little risk of accidentally breaking the user authentication system. You can even, in theory, replace an entire slice without having to rewrite the whole application. It’s like organizing a messy garage into a system of clearly labeled tool chests. You know exactly where everything is, and you can work on one project without upending all the others.
The Practical Payoffs of a Disciplined Approach
This architectural discipline isn't just a theoretical exercise; it delivers tangible benefits. Hanami applications tend to be faster and use significantly less memory than their monolithic counterparts. Because components are small and decoupled, they are easier to test, leading to more reliable code. For development teams, the benefits are even greater. New engineers can be onboarded to a specific slice of the application without needing to understand the entire complex system at once. This modularity makes it easier to scale teams and infrastructure in parallel. While Hanami has a steeper learning curve than Rails, the upfront investment in structure pays dividends in long-term clarity and reduced maintenance costs.













