Knowledge Base updated: 2026-11-03
React Webpack Rails Tutorial Knowledge Base
Orientation
This repository is a Rails tutorial application that compares several React delivery and comment-management approaches: JavaScript React, Hotwire, ReScript, server rendering, and React Server Components.
Rails owns routes, persistence, HTML/JSON endpoints, Action Cable, jobs, layouts, and page templates. Frontend code is built through Shakapacker/Rspack into browser, Node-renderer, and RSC-oriented bundles.
Comment state is persisted by Rails and exposed through server endpoints; browser clients render and mutate it through their respective implementations. Development orchestration coordinates Rails, asset watchers, ReScript, Node rendering, and Redis.
System architecture
flowchart LR
Browser[Browser]
Rails[Rails application]
Routes[Routes and page templates]
Comments[Comments controller and model]
Cable[Action Cable channel]
Jobs[Broadcast job]
Redis[Redis]
JS[JavaScript React UI]
Hotwire[Turbo and Stimulus UI]
ReScript[ReScript comment UI]
RSC[React Server Components]
RoR[React on Rails integration]
Node[Node renderer]
Build[Shakapacker and Rspack]
Assets[Generated client/server packs]
Browser --> Rails
Rails --> Routes
Rails --> Comments
Comments --> Jobs
Jobs --> Cable
Cable --> Redis
Redis --> Browser
Browser --> JS
Browser --> Hotwire
Browser --> ReScript
Browser --> RSC
Rails --> RoR
RoR --> Node
Build --> Assets
Assets --> Browser
Assets --> Node
Glossary
- React on Rails: the Rails integration layer that registers React components and renders them from Rails views.
- Shakapacker: the Rails-facing asset-pack integration used to serve built frontend bundles.
- Rspack: the JavaScript bundler configuration used for the tutorial's frontend targets.
- RSC: React Server Components, demonstrated through a dedicated server/client component and bundle path.
- ReScript bridge: generated JavaScript-facing component bindings that let Rails-delivered frontend code use ReScript UI components.
Codebase-wide invariants
- Rails remains the source of truth for comment persistence and HTTP response handling; evidence: app/…/comment.rb and app/…/comments_controller.rb.
- Every frontend delivery mode is exposed through Rails routes and page templates; evidence: config/routes.rb and
app/views/**. - Browser-facing packs must be produced by the configured asset pipeline before Rails can serve their current output; evidence: package.json and
config/**/shakapacker*. - ReScript test execution depends on its generated/build artifacts being current; evidence: package.json and spec/…/rescript_spec.rb.
- Realtime comment delivery passes through Rails jobs and Action Cable rather than direct client-to-client messaging; evidence:
app/jobs/**andapp/channels/**.
Routing table
- app/…/comment.rb, app/…/comments_controller.rb,
app/views/comments/**-> docs/comment-experience.md - app/…/comment.rb, app/…/comments_controller.rb,
app/views/comments/**-> docs/rails-comment-backend.md app/javascript/**/comments/**,app/javascript/**/Comment*.{js,jsx,ts,tsx}-> docs/react-comments-ui.mdapp/channels/**,app/jobs/**,app/javascript/**/realtime/**-> docs/realtime-comment-updates.mdapp/javascript/**/controllers/**,app/views/**/turbo/**,app/views/**/comments/**-> docs/turbo-stimulus-comments.mdapp/javascript/**/*.res,app/javascript/**/rescript/**, rescript.json, package.json -> docs/rescript-comment-demo.md- app/…/pages_controller.rb,
app/views/pages/**,app/javascript/**/{client,server,rsc}/**-> docs/react-rendering-modes.md - config/…/react_on_rails.rb,
app/javascript/**/registration/**,app/views/**-> docs/react-on-rails-integration.md server/**,app/javascript/**/server/**,config/**/server*-> docs/node-server-rendering.mdapp/javascript/**/rsc/**,app/javascript/**/*Server*.{js,jsx,ts,tsx},app/javascript/**/*Client*.{js,jsx,ts,tsx}-> docs/react-server-components.md- config/shakapacker.yml,
config/webpack/**,rspack.config.*, package.json -> docs/asset-build-pipeline.md app/javascript/**/*.{css,scss,sass},app/javascript/**/assets/**,tailwind.config.*,postcss.config.*-> docs/frontend-assets-and-styles.md- config/routes.rb, app/…/pages_controller.rb,
app/views/layouts/**,app/views/pages/**-> docs/application-pages-and-routing.md bin/dev,Procfile*, package.json, config/redis.yml -> docs/development-runtime.mdspec/**,test/**, package.json, .rubocop.yml,eslint.config.*-> docs/automated-validation.md