What this project actually is
A small Ruby‑on‑Rails web app that lets users calculate the ingredients needed for Neapolitan‑style pizza dough.
The user submits parameters (number of pizzas, weight per pizza, hydration, yeast/sourdough percentages, etc.) via a form rendered by StaticController#index. The controller builds a Dough object (Dough.from_params) and displays the calculated recipe on /dough.
Sources
README.md(project description)config/routes.rb(root and/doughroutes)app/controllers/static_controller.rb(usesDough.from_params)
Sources:
README.mdcalculator/app/controllers/static_controller.rbcalculator/app/javascript/controllers/index.jscalculator/config/routes.rb
Tech stack
| Layer | Libraries / Gems | Files |
|---|---|---|
| Backend | Ruby 3.x, Rails 8 (edge), Puma | Gemfile, config/application.rb, config/environments/*.rb |
| Web framework | ActionController, ActionView, ActionCable | app/controllers/*, app/views/*, app/channels/* |
| Front‑end | Turbo (turbo-rails), Stimulus (stimulus-rails, stimulus-loading) | app/javascript/application.js, app/javascript/controllers/index.js, config/importmap.rb |
| Styling | Sass via Dartsass (dartsass-rails) | app/assets/stylesheets/application.scss, app/assets/stylesheets/styles.scss |
| Components | ViewComponent (view_component) | app/components/input_component.rb, .html.erb |
| Deployment | Capistrano (capistrano, capistrano-rails, etc.) | Capfile, config/deploy.rb, config/deploy/production.rb |
| Testing | Minitest + Capybara + Selenium | test/* files |
Sources
Gemfileconfig/importmap.rbapp/javascript/application.jsapp/javascript/controllers/index.jsapp/components/input_component.rb
Sources:
calculator/app/assets/stylesheets/application.scsscalculator/app/assets/stylesheets/styles.scsscalculator/app/javascript/controllers/application.jscalculator/app/javascript/controllers/index.js
High‑level architecture
client ──► Turbo (SPA navigation) ──► Stimulus controllers (dynamic UI) ──►
Rails MVC
├─ StaticController
│ ├─ index → renders form (InputComponent)
│ └─ dough → shows calculated recipe
├─ Dough model (logic in app/models/dough.rb – not shown)
└─ Views (ERB + ViewComponent)
- Routes – defined in
config/routes.rb. The root path maps toStaticController#index;/doughrenders the result. - Controllers – only one real controller (
StaticController) handles all user interactions. - Models – the core calculation lives in a separate model (
Dough). It is instantiated from request parameters. - Views & Components – ERB templates use the reusable
<%= render InputComponent.new(...) %>component for numeric inputs. - Stimulus – all controllers are eagerly loaded via
eagerLoadControllersFrom("controllers", application)incalculator/app/javascript/controllers/index.js. They provide client‑side interactivity (e.g., live updates of calculated values). - Assets – SCSS compiled by Dartsass; images served from
/public/images.
Sources
config/routes.rbapp/controllers/static_controller.rbapp/components/input_component.rbcalculator/app/javascript/controllers/index.jscalculator/app/javascript/application.js
Sources:
calculator/app/javascript/controllers/index.jscalculator/app/javascript/application.jscalculator/app/javascript/controllers/application.jscalculator/app/assets/stylesheets/application.scss
Entry points
- Docker – run with
make up. This starts a container that executes:
./bin/dev
which launches the Rails server on port 3000. 2. Rails server – entry point is the standard Rails boot sequence:
/opt/app/config/environment.rbloads the application.- Puma starts listening on port 3000 (
config/puma.rb).
- HTTP request flow – e.g., GET
/
- Router dispatches to
StaticController#index. - Controller builds a default or pre‑filled
Dough. - View renders the form; Stimulus controllers are attached via importmap.
- User submits → POST to
/dough; controller recalculates and renders result page.
Sources
- Makefile (
calculator/Makefile) - Dockerfile (
calculator/Dockerfile) /opt/app/config/environment.rb(boot)/opt/app/config/puma.rb
Sources:
calculator/Dockerfilecalculator/Makefilecalculator/app/javascript/controllers/application.jscalculator/app/javascript/controllers/index.js
Key concepts
| Concept | What it is | Where it lives |
|---|---|---|
| Dough calculation | Encapsulated in the missing but referenced class Dough. It parses request params and produces ingredient amounts and descriptive text (build_title, build_description). | Expected at app/models/dough.rb. |
| InputComponent | A reusable ViewComponent that renders a labeled numeric input with min/max/step constraints. Used throughout the form. | app/components/input_component.rb / .html.erb. |
| Stimulus eager loading | All Stimulus controllers are automatically registered at boot via importmap and eager loading helper. This allows dynamic updates without page reloads. | calculator/app/javascript/controllers/index.js. |
| Routes mapping | Simple REST‑like mapping: root → index; /dough → show result; /result redirects to /dough. | config/routes.rb. |
| Asset pipeline | SCSS compiled by Dartsass; images referenced in README are generated by a separate Flowchart submodule. | .scss, Flowchart Dockerfile & Makefile. |
Sources
- Reference to missing model: comment in controller (
# @dough = Dough.from_params(...)). - Component files (
input_component.*). - Importmap config (
controllers/index.js). - Routes file (
config/routes.rb).
Sources:
calculator/app/javascript/controllers/index.jscalculator/app/components/input_component.rbcalculator/config/boot.rbcalculator/config/importmap.rb
Where to start reading
config/routes.rb– understand which URLs map to which actions.app/controllers/static_controller.rb– core request handling and how it builds the dough object.- Missing model stub (
app/models/dough.rb) – locate or create this file to see calculation logic (the rest of the app depends on it). app/components/input_component.*– see how form inputs are rendered and styled.calculator/app/javascript/controllers/index.js+ importmap – learn how Stimulus controllers are wired into the page.
These files give you the full request–response cycle from URL to rendered HTML and client‑side behavior.
Sources
config/routes.rbapp/controllers/static_controller.rb- (implied) missing model path
app/components/input_component.*calculator/app/javascript/controllers/index.js
Sources:
calculator/app/javascript/controllers/index.jscalculator/app/components/input_component.rbcalculator/app/controllers/static_controller.rbcalculator/config/importmap.rb
