# matheuswemmer/autoatendimento-fx architecture

> Architecture diagram of the GitHub repository matheuswemmer/autoatendimento-fx, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/matheuswemmer/autoatendimento-fx
- Repository: https://github.com/matheuswemmer/autoatendimento-fx

## Overview

1. **Overall shape**
   - This is a **desktop JavaFX application** for restaurant self-service, not a web app.
   - The architecture is a simple **UI + domain model** split: FXML views define screens, controllers handle user interaction, and model classes hold the business state.

2. **Application entry point**
   - `com.example.App` is the startup class and is responsible for launching JavaFX and loading the initial screen.
   - `module-info.java` indicates the app is built as a **Java module**, which matters for JavaFX packaging and resource access.

3. **Presentation layer**
   - All screens live under `src/main/resources/com/views` as **FXML files**:
     - `Cardapio.fxml`
     - `Carrinho.fxml`
     - `CarrinhoItem.fxml`
     - `Cozinha.fxml`
     - `PedidoCard.fxml`
     - `ProdutoCard.fxml`
   - `cozinha.css` is a view-specific stylesheet, so the UI has at least one styled area focused on kitchen workflow.

4. **Controller layer**
   - Controllers in `com.example.controller` bind the FXML UI to the domain logic:
     - `CardapioController` manages menu browsing and product selection.
     - `CarrinhoController` manages the cart screen and checkout.
     - `CarrinhoItemController` handles individual cart row/item behavior.
     - `CozinhaController` manages kitchen order progression and delivery.
     - `PedidoCardController` handles the rendering/interaction of an order card in the kitchen.
     - `ProdutoCardController` handles the rendering/interaction of a product card in the menu.
   - These controllers are the main orchestration layer between UI events and model mutations.

5. **Catalog / menu subsystem**
   - `Cardapio` is the menu aggregate: it stores the available products.
   - `Produto` is the base type for menu items, with `Comida` and `Bebida` as specializations.
   - This subsystem is responsible for presenting the available items and their type-specific data.

6. **Cart subsystem**
   - `Carrinho` tracks the current customer selection before checkout.
   - The README specifies that it uses a `Map<Produto, Integer>` to store item quantities, so the cart is quantity-aware rather than item-list-only.
   - This subsystem is the main boundary for “in-progress” customer choices.

7. **Order subsystem**
   - `Pedido` represents the finalized order, including items, total value, identifier, and status.
   - The cart copies its contents into a new order when checkout happens, which preserves the order snapshot even after the cart is cleared.
   - `Pedido.Status` controls the lifecycle: **em preparo**, **pronto**, and **entregue**.

8. **Kitchen subsystem**
   - `Cozinha` holds both active orders and delivered orders.
   - This is the operational backend of the app’s workflow: orders move from cart checkout into kitchen processing, then through status transitions until delivery.
   - Delivered orders remain visible, so the kitchen screen is both a work queue and a history area.

9. **Runtime data flow**
   - The main flow is:
     - menu display → add/remove items in cart → finalize cart → create order → send order to kitchen → advance status → mark delivered → keep delivered history visible.
   - The final step is a **new order/reset flow**, where the user starts over with an empty cart and returns to the menu.

10. **Model relationships**
   - `Produto` is the shared abstraction for all sellable items.
   - `Comida` and `Bebida` extend it, which keeps common attributes centralized and lets the UI/workflow distinguish product kinds when needed.
   - `Cardapio`, `Carrinho`, `Pedido`, and `Cozinha` are the key state-holding classes, each representing a distinct stage of the restaurant workflow.

11. **Technology and packaging boundaries**
   - The project uses **Java 21**, **JavaFX 21**, and **Maven**.
   - FXML separates layout from behavior, so the UI boundary is explicit: view files define structure, controllers define interaction, and models define business data.
   - There is no evidence of persistence, database, or external API integration; state appears to be **in-memory only**.

12. **What to emphasize in an architecture diagram**
   - A good diagram should show three layers:
     - **FXML screens** at the top,
     - **controllers** in the middle,
     - **domain models** at the bottom.
   - Highlight the two main workflows:
     - customer ordering through `Cardapio` and `Carrinho`,
     - kitchen processing through `Pedido` and `Cozinha`.
   - Also show the one-way transition from cart to order, since that is the key state boundary in the application.

Main entry points: [`src/main/java/com/example/model/Produto.java`](https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/model/Produto.java) (Produto), [`src/main/java/com/example/model/Pedido.java`](https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/model/Pedido.java) (Pedido), [`src/main/java/com/example/controller/CardapioController.java`](https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/controller/CardapioController.java) (Menu Controller), [`src/main/java/com/example/controller/CarrinhoController.java`](https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/controller/CarrinhoController.java) (Cart Controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_cardapio_fxml["Menu View<br/>FXML view<br/>[Cardapio.fxml]"]
  node_carrinho_fxml["Cart View<br/>FXML view<br/>[Carrinho.fxml]"]
  node_cozinha_fxml["Kitchen View<br/>FXML view<br/>[Cozinha.fxml]"]
  node_carrinho_item_fxml["Cart Item<br/>FXML view<br/>[CarrinhoItem.fxml]"]
  node_pedido_card_fxml["Order Card<br/>FXML view<br/>[PedidoCard.fxml]"]
  node_produto_card_fxml["Product Card<br/>FXML view<br/>[ProdutoCard.fxml]"]
  node_cozinha_css["Kitchen CSS<br/>stylesheet<br/>[cozinha.css]"]
end

subgraph group_controllers["Controllers"]
  node_cardapio_controller["Menu Controller"]
  node_carrinho_controller["Cart Controller"]
  node_carrinho_item_controller["Item Controller"]
  node_cozinha_controller["Kitchen Controller"]
  node_pedido_card_controller["Order Card Ctrl<br/>controller"]
  node_produto_card_controller["Product Card Ctrl<br/>controller"]
end

subgraph group_domain["Domain"]
  node_cardapio_model[("Cardápio<br/>catalog<br/>[Cardapio.java]")]
  node_carrinho_model[("Carrinho<br/>cart state<br/>[Carrinho.java]")]
  node_pedido_model[("Pedido<br/>order state<br/>[Pedido.java]")]
  node_cozinha_model[("Cozinha<br/>order queue<br/>[Cozinha.java]")]
  node_produto_model["Produto<br/>item base<br/>[Produto.java]"]
  node_comida_model["Comida<br/>product subtype<br/>[Comida.java]"]
  node_bebida_model["Bebida<br/>product subtype<br/>[Bebida.java]"]
end

subgraph group_runtime["Runtime"]
  node_app(("App<br/>javafx entry<br/>[App.java]"))
  node_module_info["Module<br/>[module-info.java]"]
end

node_app -->|"launches"| node_cardapio_fxml
node_module_info -->|"exports"| node_app
node_cardapio_fxml -->|"uses"| node_cardapio_controller
node_carrinho_fxml -->|"uses"| node_carrinho_controller
node_cozinha_fxml -->|"uses"| node_cozinha_controller
node_carrinho_item_fxml -->|"uses"| node_carrinho_item_controller
node_pedido_card_fxml -->|"uses"| node_pedido_card_controller
node_produto_card_fxml -->|"uses"| node_produto_card_controller
node_cozinha_fxml -->|"styles"| node_cozinha_css
node_cardapio_controller -->|"reads"| node_cardapio_model
node_cardapio_controller -->|"adds to"| node_carrinho_model
node_cardapio_controller -->|"renders"| node_produto_card_controller
node_carrinho_controller -->|"updates"| node_carrinho_model
node_carrinho_controller -->|"creates"| node_pedido_model
node_carrinho_controller -->|"returns to"| node_cardapio_fxml
node_carrinho_item_controller -->|"mutates"| node_carrinho_model
node_cozinha_controller -->|"manages"| node_cozinha_model
node_cozinha_controller -->|"advances"| node_pedido_model
node_pedido_card_controller -->|"displays"| node_pedido_model
node_produto_card_controller -->|"displays"| node_produto_model
node_cardapio_model -->|"contains"| node_produto_model
node_produto_model -->|"specializes"| node_comida_model
node_produto_model -->|"specializes"| node_bebida_model
node_carrinho_model -->|"counts"| node_produto_model
node_pedido_model -->|"snapshots"| node_produto_model
node_cozinha_model -->|"tracks"| node_pedido_model

click node_app "https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/App.java"
click node_module_info "https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/module-info.java"
click node_cardapio_fxml "https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/resources/com/views/Cardapio.fxml"
click node_carrinho_fxml "https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/resources/com/views/Carrinho.fxml"
click node_cozinha_fxml "https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/resources/com/views/Cozinha.fxml"
click node_carrinho_item_fxml "https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/resources/com/views/CarrinhoItem.fxml"
click node_pedido_card_fxml "https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/resources/com/views/PedidoCard.fxml"
click node_produto_card_fxml "https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/resources/com/views/ProdutoCard.fxml"
click node_cozinha_css "https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/resources/com/views/cozinha.css"
click node_cardapio_controller "https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/controller/CardapioController.java"
click node_carrinho_controller "https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/controller/CarrinhoController.java"
click node_carrinho_item_controller "https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/controller/CarrinhoItemController.java"
click node_cozinha_controller "https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/controller/CozinhaController.java"
click node_pedido_card_controller "https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/controller/PedidoCardController.java"
click node_produto_card_controller "https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/controller/ProdutoCardController.java"
click node_cardapio_model "https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/model/Cardapio.java"
click node_carrinho_model "https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/model/Carrinho.java"
click node_pedido_model "https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/model/Pedido.java"
click node_cozinha_model "https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/model/Cozinha.java"
click node_produto_model "https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/model/Produto.java"
click node_comida_model "https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/model/Comida.java"
click node_bebida_model "https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/model/Bebida.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cardapio_fxml,node_carrinho_fxml,node_cozinha_fxml,node_carrinho_item_fxml,node_pedido_card_fxml,node_produto_card_fxml,node_cozinha_css toneBlue
class node_cardapio_controller,node_carrinho_controller,node_carrinho_item_controller,node_cozinha_controller,node_pedido_card_controller,node_produto_card_controller toneAmber
class node_cardapio_model,node_carrinho_model,node_pedido_model,node_cozinha_model,node_produto_model,node_comida_model,node_bebida_model toneMint
class node_app,node_module_info toneRose
```

## Components

### Presentation

FXML screens and styling for the JavaFX UI

- [Menu View](https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/resources/com/views/Cardapio.fxml): FXML view · Menu screen for browsing products and selecting items. · `src/main/resources/com/views/Cardapio.fxml`
- [Cart View](https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/resources/com/views/Carrinho.fxml): FXML view · Cart screen for reviewing selections and checking out. · `src/main/resources/com/views/Carrinho.fxml`
- [Kitchen View](https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/resources/com/views/Cozinha.fxml): FXML view · Kitchen screen for active and delivered orders. · `src/main/resources/com/views/Cozinha.fxml`
- [Cart Item](https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/resources/com/views/CarrinhoItem.fxml): FXML view · Reusable item row for the cart list. · `src/main/resources/com/views/CarrinhoItem.fxml`
- [Order Card](https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/resources/com/views/PedidoCard.fxml): FXML view · Reusable order card used in the kitchen workflow. · `src/main/resources/com/views/PedidoCard.fxml`
- [Product Card](https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/resources/com/views/ProdutoCard.fxml): FXML view · Reusable product card used in the menu. · `src/main/resources/com/views/ProdutoCard.fxml`
- [Kitchen CSS](https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/resources/com/views/cozinha.css): stylesheet · View-specific styling for the kitchen screen. · `src/main/resources/com/views/cozinha.css`

### Controllers

JavaFX controllers that bind views to domain state

- [Menu Controller](https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/controller/CardapioController.java): controller · Coordinates menu browsing and product selection. · `src/main/java/com/example/controller/CardapioController.java`
- [Cart Controller](https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/controller/CarrinhoController.java): controller · Manages cart contents and checkout. · `src/main/java/com/example/controller/CarrinhoController.java`
- [Item Controller](https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/controller/CarrinhoItemController.java): controller · Handles behavior for a single cart row. · `src/main/java/com/example/controller/CarrinhoItemController.java`
- [Kitchen Controller](https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/controller/CozinhaController.java): controller · Drives order progress and delivery actions. · `src/main/java/com/example/controller/CozinhaController.java`
- [Order Card Ctrl](https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/controller/PedidoCardController.java): controller · Binds order card UI to order state. · `src/main/java/com/example/controller/PedidoCardController.java`
- [Product Card Ctrl](https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/controller/ProdutoCardController.java): controller · Binds product card UI to product data. · `src/main/java/com/example/controller/ProdutoCardController.java`

### Domain

In-memory restaurant workflow model

- [Cardápio](https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/model/Cardapio.java): catalog · Menu aggregate that stores available products. · `src/main/java/com/example/model/Cardapio.java`
- [Carrinho](https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/model/Carrinho.java): cart state · Quantity-aware in-memory cart for the current customer selection. · `src/main/java/com/example/model/Carrinho.java`
- [Pedido](https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/model/Pedido.java): order state · Finalized order snapshot with items, total, id, and status lifecycle. · `src/main/java/com/example/model/Pedido.java`
- [Cozinha](https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/model/Cozinha.java): order queue · Tracks active and delivered orders for kitchen workflow and history. · `src/main/java/com/example/model/Cozinha.java`
- [Produto](https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/model/Produto.java): item base · Shared abstraction for sellable items. · `src/main/java/com/example/model/Produto.java`
- [Comida](https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/model/Comida.java): product subtype · Food-specific product specialization. · `src/main/java/com/example/model/Comida.java`
- [Bebida](https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/model/Bebida.java): product subtype · Drink-specific product specialization. · `src/main/java/com/example/model/Bebida.java`

### Runtime

Application bootstrap and module boundary

- [App](https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/com/example/App.java): javafx entry · JavaFX startup class that launches the app and loads the initial screen. · `src/main/java/com/example/App.java`
- [Module](https://github.com/matheuswemmer/autoatendimento-fx/blob/main/src/main/java/module-info.java): java module · Module descriptor for JavaFX packaging and access boundaries. · `src/main/java/module-info.java`

## Connections

- App → Menu View: launches · Bootstraps the initial menu screen.
- Module → App: exports · Defines the Java module boundary for the application.
- Menu View → Menu Controller: uses · Menu view is controlled by the menu controller.
- Cart View → Cart Controller: uses · Cart view is controlled by the cart controller.
- Kitchen View → Kitchen Controller: uses · Kitchen view is controlled by the kitchen controller.
- Cart Item → Item Controller: uses · Cart row view is controlled by the row controller.
- Order Card → Order Card Ctrl: uses · Order card view is controlled by the order card controller.
- Product Card → Product Card Ctrl: uses · Product card view is controlled by the product card controller.
- Kitchen View → Kitchen CSS: styles · Kitchen screen uses a dedicated stylesheet.
- Menu Controller → Cardápio: reads · Menu controller queries the product catalog.
- Menu Controller → Carrinho: adds to · Adds selected products into the cart.
- Menu Controller → Product Card Ctrl: renders · Uses product card instances to present items.
- Cart Controller → Carrinho: updates · Manages quantities and checkout actions.
- Cart Controller → Pedido: creates · Converts the cart snapshot into a finalized order.
- Cart Controller → Menu View: returns to · Resets flow back to menu after a new order.
- Item Controller → Carrinho: mutates · Updates per-item quantity and removal state.
- Kitchen Controller → Cozinha: manages · Coordinates active and delivered order lists.
- Kitchen Controller → Pedido: advances · Moves orders through preparation, ready, and delivered states.
- Order Card Ctrl → Pedido: displays · Binds an order card to one order instance.
- Product Card Ctrl → Produto: displays · Binds a product card to product data.
- Cardápio → Produto: contains · Catalog is a collection of products.
- Produto → Comida: specializes · Food is a product specialization.
- Produto → Bebida: specializes · Drink is a product specialization.
- Carrinho → Produto: counts · Stores product quantities in the current cart.
- Pedido → Produto: snapshots · Order captures the chosen products at checkout.
- Cozinha → Pedido: tracks · Kitchen holds active and delivered orders.
