Architecture: Rails Hotwire/Stimulus Patterns

arch-rails-hotwire Doc

architecture active

Architecture: Rails Hotwire/Stimulus Patterns

Conventions for Hotwire (Turbo + Stimulus) usage in the paldocs Rails app.

Stimulus Controllers

  • Controllers live in app/javascript/controllers/
  • Registered via importmap (no webpack/esbuild build step)
  • Example: kanban_controller.js for drag-and-drop board interactions

Turbo Frames

  • Turbo Frames used for partial page updates without full reloads
  • Each frame scoped to a resource section (e.g. notes list, board column)
  • Use data-turbo-permanent on elements that must persist state across Turbo navigation

Progressive Enhancement Pattern

  • HTML <details>/<summary> provides a no-JS baseline for collapsible sections
  • Stimulus controllers layer on enhancement (animation, async loading) when JS is available
  • Pattern ensures the app remains functional without JavaScript