| Category | Informational / Design Pattern |
| Status | Draft — distilled from production experience |
| Applies to | Rails + Doorkeeper OAuth providers (Ruby), serving MCP or other dynamically-registered clients |
| Author | Aotokitsuruya(蒼時弦也) |
| Date | 2026-06-21 |
| Audience | Engineers who must host OAuth for dynamically-registered, one-time, unbounded clients (typically MCP agents) on top of Doorkeeper |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # frozen_string_literal: true | |
| require 'bundler/inline' | |
| gemfile do | |
| source 'https://rubygems.org' | |
| gem 'dotenv' | |
| gem 'autoflux' | |
| gem 'autoflux-openai' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # frozen_string_literal: true | |
| require 'bundler/inline' | |
| gemfile do | |
| source 'https://rubygems.org' | |
| gem 'dotenv' | |
| gem 'ruby-openai' | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "$schema": "http://json-schema.org/draft-07/schema#", | |
| "title": "Generated schema for Root", | |
| "type": "object", | |
| "properties": { | |
| "name": { | |
| "type": "string" | |
| }, | |
| "id": { | |
| "type": "string" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| paginator = InfinitePaginator.new( | |
| 'https://jsonplaceholder.typicode.com/users/%<page>d' | |
| ) | |
| pp paginator.take(12) | |
| # => | |
| # [{"id"=>1, "name"=>"Leanne Graham"}, | |
| # {"id"=>2, "name"=>"Ervin Howell"}, | |
| # {"id"=>3, "name"=>"Clementine Bauch"}, | |
| # {"id"=>4, "name"=>"Patricia Lebsack"}, |
Under Domain-Driven Design, we are trying to "Model" the real world to the virtual world. However, it cannot clearly describe the context/interaction with the domain.
The raw data is a "number" or "string" and cannot explain the meaning in specifying the domain. Therefore we have to create a "value object" to assign the domain meaning and use "entity" to compose mapping a real-world object.
| Name | Layer | Type | Description |
|---|---|---|---|
| app/models/visitor_pass.rb | Domain | Aggregate | Pass-related domain |
| app/services/tracker_service.rb | Domain | Domain Service | Logic between door and visitor interaction |
| app/controllers/passes_controller.rb | Application | Use Case | The user flow of "pass" a door |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'dry-contaienr' | |
| require 'dry-auto_inject' | |
| # Singleton style container | |
| class Container | |
| extend Dry::Container::Mixin | |
| namespace :repositories do | |
| register(:games) { GameRepository.new } | |
| register(:players) { PlayerRepository.new } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # API | |
| class FakeResponse < Struct.new(:status, :code) | |
| def success? | |
| code == 200 | |
| end | |
| end | |
| class FakeAPI | |
| def call | |
| FakeResponse.new('Success', 200) |
NewerOlder