# Pizza Dough

> This recipe is dedicated to helping you make the best possible pizza dough.

**Showcase URL:** https://shipdocs.sh/showcase/af9afef9-48e9-4a55-95aa-47eafe5bdb71
**Repository:** https://github.com/hendricius/pizza-dough
**Docs count:** 3

## Overview

## Project Overview

This project is a web application that functions as a calculator for pizza dough recipes. It allows users to input various parameters to determine the precise quantities of ingredients needed for their desired pizza dough, offering both yeast and sourdough options.

## Tech Stack

*   Ruby on Rails
*   StimulusJS
*   Hotwired Turbo
*   SCSS
*   ViewComponent
*   Docker

## High-Level Architecture

The application is built using Ruby on Rails.

*   **Controllers** (`calculator/app/controllers/`): Handle incoming requests and determine the response. `StaticController` is the primary controller, responsible for rendering the main calculator interface and results.
*   **Views** (`calculator/app/views/`): Render the HTML for the user interface. This includes layouts (`layouts/mailer.html.erb`, `layouts/mailer.text.erb`) and the main view for the calculator (`static/dough.html.erb`).
*   **Components** (`calculator/app/components/`): Reusable UI elements, such as `InputComponent`, which is used to render input fields for the calculator.
*   **JavaScript** (`calculator/app/javascript/`): Manages client-side interactivity, primarily using StimulusJS for controller-based JavaScript.
*   **Stylesheets** (`calculator/app/assets/stylesheets/`): Contains SCSS for styling the application.
*   **Configuration** (`calculator/config/`): Rails application configuration files, including routing (`routes.rb`), environment settings (`environment.rb`), and asset management (`importmap.rb`, `assets.rb`).
*   **Docker** (`calculator/docker-compose.yml`, `calculator/Dockerfile`): Defines the containerized environment for running the application.

## Entry Points

1.  **User Request:** A user navigates to the application's URL (e.g., `http://localhost:3000`).
2.  **Routing:** The request is matched against the routes defined in `calculator/config/routes.rb`. The root route (`/`) directs to the `index` action of the `static` controller.
3.  **Controller Action:** The `static#index` action is executed. This action likely sets up any necessary instance variables and renders the `static/index.html.erb` view.
4.  **View Rendering:** The `static/index.html.erb` view is rendered, which likely contains the form for the pizza dough calculator.
5.  **Form Submission:** When the user submits the form, a GET request is made to the `/dough` path with query parameters representing the input values.
6.  **Routing (again):** The `/dough` route is defined in `calculator/config/routes.rb` and maps to the `dough` action of the `static` controller.
7.  **Controller Action (calculation):** The `static#dough` action is executed. It retrieves the parameters from the request, performs the pizza dough calculations, and likely assigns the results to instance variables.
8.  **View Rendering (results):** The `static#dough.html.erb` view is rendered, using the calculated ingredient quantities to display the results to the user.

## Key Concepts

1.  **Pizza Dough Calculation Logic:** The core functionality of the application lies in calculating ingredient quantities based on user inputs. This logic is likely implemented within the `static#dough` controller action, utilizing "baker's math" as described in the `README.md`.
2.  **Input Component (`InputComponent`):** This reusable component (`calculator/app/components/input_component.rb` and `calculator/app/components/input_component.html.erb`) is used to render form input fields for the calculator. Understanding how this component is initialized and rendered is key to understanding the form structure.
3.  **Routing (`calculator/config/routes.rb`):** The `root` route and the `get "dough", to: "static#dough"` route define the main entry points and how user requests are mapped to controller actions. The `redirect` route for `/result` also shows how URLs are handled.
4.  **StimulusJS Controllers (`calculator/app/javascript/controllers/`):** While the provided code doesn't show specific controller implementations, the `importmap.rb` and `index.js` files indicate the use of StimulusJS for managing client-side interactivity. Understanding how Stimulus controllers are defined and attached to HTML elements is important for any dynamic behavior.
5.  **Dockerization (`calculator/Dockerfile`, `calculator/docker-compose.yml`):** The `Dockerfile` and `docker-compose.yml` files define how to build and run the application in a containerized environment. This is crucial for local development and deployment.

## All docs

- **Pizza Dough** (overview)
- **Flowchart Generator** (module)
- **Pizza Dough Calculator Backend** (module)

Browse the interactive showcase: https://shipdocs.sh/showcase/af9afef9-48e9-4a55-95aa-47eafe5bdb71
