Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Ruby
  3. Hanami::Model

Hanami::Model

MITRuby

A Ruby persistence framework for Hanami 1.x applications, using entities and repositories to separate domain logic from storage details.

Visit WebsiteGitHubGitHub
447 stars146 forks0 contributors

What is Hanami::Model?

Hanami::Model is a Ruby persistence framework that provides entities and repositories to handle data storage in Hanami 1.x applications. It separates domain logic from persistence details, allowing developers to focus on business behaviors while abstracting database interactions. The framework supports SQL adapters and includes features like automapping and automatic timestamp management.

Target Audience

Ruby developers building applications with the Hanami 1.x framework who need a structured, clean architecture for data persistence. It's suited for projects emphasizing Domain-Driven Design and separation of concerns.

Value Proposition

Developers choose Hanami::Model for its strict separation between entities (domain logic) and repositories (persistence), which reduces coupling and improves testability. Its repository pattern provides a stable, storage-independent API, making it easier to switch databases or handle legacy schemas without affecting application code.

Overview

Ruby persistence framework with entities and repositories

Use Cases

Best For

  • Building Hanami 1.x applications with clean architecture
  • Implementing Domain-Driven Design patterns in Ruby
  • Abstracting database interactions with storage-independent repositories
  • Managing legacy database schemas with custom mapping
  • Separating business logic from persistence concerns
  • Creating testable data layers with intention-revealing APIs

Not Ideal For

  • Starting new projects with Hanami 2.x or planning framework upgrades
  • Applications requiring long-term maintenance, security patches, or active community support
  • Teams using Ruby 3.x or later versions due to compatibility restrictions
  • Projects preferring ActiveRecord's convention-over-configuration for rapid prototyping without explicit repository patterns

Pros & Cons

Pros

Clean Architecture Enforcement

Strictly separates domain logic (entities) from persistence (repositories), aligning with Domain-Driven Design principles as emphasized in the philosophy section, reducing coupling and improving testability.

Storage-Independent API

Repositories abstract database interactions, allowing easy adapter changes without affecting application code, which supports dependency inversion and postpones storage decisions, as described in the repository concepts.

Legacy Schema Support

Offers automapping for standard databases and manual mapping overrides for legacy schemas with mismatched column names, demonstrated in the mapping example for cases like :t_user_archive tables.

Automatic Timestamp Management

Automatically updates created_at and updated_at fields when entities are persisted, reducing boilerplate code, as shown in the timestamps feature example with UserRepository.

Cons

Deprecated and Unmaintained

Explicitly marked as deprecated with no future updates, making it unsuitable for new projects or those needing ongoing support, as stated in the important notice.

Limited Ruby Version Support

Only compatible with Ruby 2.6 and 2.7, excluding modern Ruby versions, which restricts adoption in current development environments.

Thread Safety Complexities

Requires mutex synchronization during loading to avoid issues in non-Hanami applications, adding setup overhead and potential for errors in multi-threaded contexts.

Boilerplate for Queries

Forces developers to define explicit repository methods for all queries instead of allowing chainable methods, which can increase initial development time compared to more flexible ORMs.

Frequently Asked Questions

Quick Stats

Stars447
Forks146
Contributors0
Open Issues13
Last commit1 year ago
CreatedSince 2014

Tags

#persistence-layer#hanami#orm#database#persistence-framework#domain-driven-design#database-abstraction#repository#entity#repository-pattern#ruby#persistence#entity-framework

Built With

R
Ruby
S
SQL

Links & Resources

Website

Included in

Ruby14.1k
Auto-fetched 1 day ago

Related Projects

MongoidMongoid

The Official Ruby Object Mapper for MongoDB

Stars3,915
Forks1,380
Last commit5 days ago
ROMROM

Data mapping and persistence toolkit for Ruby

Stars2,111
Forks167
Last commit5 months ago
Redis-ObjectsRedis-Objects

Map Redis types directly to Ruby objects

Stars2,095
Forks231
Last commit5 months ago
OhmOhm

Object-Hash Mapping for Redis

Stars1,385
Forks162
Last commit3 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub