After about 5 laps around Clean architecture since I came across hanami/hanami: The web, with simplicity., I'm finally getting it down in my gut, so I'll summarize.
It is difficult to understand while using a frameworks like Ruby on Rails
When using a framework, the outer moat of the Usecase in the diagram is filled in: Controller, View, and Model in the case of MVC, and Repository in the case of other patterns. Personally, I feel that if all three layers from the inner layer are integrated, they are the center of the application.
So I tried to implement each responsibility of the application using different libraries.
Here it is. cc-kawakami/clean-architecture-minimal-app: A minimal Clean Architecture app
These are the libraries we used.
- Use Case: utils/interactor.rb at v1.3.8 - hanami/utils
- Controller: sinatra/sinatra: Classy web-development dressed in a DSL (official / canonical repo)
- Serializer: procore/blueprinter: Simple, Fast, and Declarative Serialization Library for Ruby
- Object Mapper: rom-rb/rom: Data mapping and persistence toolkit for Ruby
- DB: sparklemotion/sqlite3-ruby: Ruby bindings for the SQLite3 embedded database
"Let there be Entity."
We will attack from the heart of the architecture. First, Entity.
class User
attr_reader :id, :name, :email
def initialize(id:, name:, email:)
@id
