# madhawapolkotuwa/drinkbar architecture

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

- Interactive diagram: https://gitdiagram.com/madhawapolkotuwa/drinkbar
- Repository: https://github.com/madhawapolkotuwa/drinkbar

## Overview

Drink Bar is a Qt Quick drink-machine selection demo. The intended user journey is to choose a drink category and drink, configure size and (for hot drinks) sugar, confirm, wait through preparation, and see the completion screen. The C++ entry point loads three catalog models from JSON and registers a controller that stores selections and emits a preparation-finished signal after a timer. Screen-to-screen wiring is inferred from screen names; those links are dashed because the QML source was not shown.

Main entry points: [`main.cpp`](https://github.com/madhawapolkotuwa/drinkbar/blob/main/main.cpp) (Qt entry point), [`Models/drinkmodel.cpp`](https://github.com/madhawapolkotuwa/drinkbar/blob/main/Models/drinkmodel.cpp) (Catalog model), [`Models/hotdrinkmodel.h`](https://github.com/madhawapolkotuwa/drinkbar/blob/main/Models/hotdrinkmodel.h) (Hot drinks), [`Models/cooldrinkmodel.h`](https://github.com/madhawapolkotuwa/drinkbar/blob/main/Models/cooldrinkmodel.h) (Cool drinks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_entry["Qt entry point<br/>[main.cpp]"]
  node_root["QML root<br/>[Main.qml]"]
end

subgraph group_catalog["Drink catalog"]
  node_catalog_data["Drink catalog data<br/>[AllDrinks.json]"]
  node_drink_model["Catalog model<br/>[drinkmodel.cpp]"]
  node_hot_model["Hot drinks<br/>[hotdrinkmodel.h]"]
  node_cool_model["Cool drinks<br/>[cooldrinkmodel.h]"]
  node_juice_model["Fresh juices<br/>[freshjuicemodel.h]"]
  node_drink["Drink record<br/>[drink.h]"]
end

subgraph group_flow["Ordering flow"]
  node_category["Temperature choice"]
  node_drink_select["Drink selection"]
  node_size_select["Size selection"]
  node_sugar_select["Sugar selection"]
  node_confirmation["Order confirmation"]
  node_preparing["Preparation screen"]
  node_enjoy["Completion screen<br/>[EnjoyMegScreen.qml]"]
  node_custom_item["Drink item view"]
end

subgraph group_state["Selection and preparation"]
  node_controller["System controller"]
end

node_user(("Customer"))

node_user -.->|"uses"| node_root
node_entry -->|"loads"| node_root
node_entry -->|"creates and loads"| node_hot_model
node_entry -->|"creates and loads"| node_cool_model
node_entry -->|"creates and loads"| node_juice_model
node_entry -->|"registers"| node_controller
node_hot_model -->|"loads"| node_catalog_data
node_cool_model -->|"loads"| node_catalog_data
node_juice_model -->|"loads"| node_catalog_data
node_hot_model -.->|"inherits"| node_drink_model
node_cool_model -.->|"inherits"| node_drink_model
node_juice_model -->|"inherits"| node_drink_model
node_drink_model -->|"uses records"| node_drink
node_controller -->|"creates and stores"| node_drink
node_root -.->|"shows"| node_category
node_category -.->|"continues to"| node_drink_select
node_drink_select -.->|"renders"| node_custom_item
node_drink_select -.->|"continues to"| node_size_select
node_size_select -.->|"continues to"| node_sugar_select
node_sugar_select -.->|"continues to"| node_confirmation
node_confirmation -.->|"continues to"| node_preparing
node_preparing -.->|"continues to"| node_enjoy
node_preparing -.->|"starts preparation"| node_controller

click node_entry "https://github.com/madhawapolkotuwa/drinkbar/blob/main/main.cpp"
click node_root "https://github.com/madhawapolkotuwa/drinkbar/blob/main/Main.qml"
click node_catalog_data "https://github.com/madhawapolkotuwa/drinkbar/blob/main/Ui/assets/AllDrinks.json"
click node_drink_model "https://github.com/madhawapolkotuwa/drinkbar/blob/main/Models/drinkmodel.cpp"
click node_hot_model "https://github.com/madhawapolkotuwa/drinkbar/blob/main/Models/hotdrinkmodel.h"
click node_cool_model "https://github.com/madhawapolkotuwa/drinkbar/blob/main/Models/cooldrinkmodel.h"
click node_juice_model "https://github.com/madhawapolkotuwa/drinkbar/blob/main/Models/freshjuicemodel.h"
click node_drink "https://github.com/madhawapolkotuwa/drinkbar/blob/main/Models/drink.h"
click node_category "https://github.com/madhawapolkotuwa/drinkbar/blob/main/Ui/HotCoolSelectScreen.qml"
click node_drink_select "https://github.com/madhawapolkotuwa/drinkbar/blob/main/Ui/DrinkSelectScreen.qml"
click node_size_select "https://github.com/madhawapolkotuwa/drinkbar/blob/main/Ui/SizeSelectScreen.qml"
click node_sugar_select "https://github.com/madhawapolkotuwa/drinkbar/blob/main/Ui/SugarLevelSelectScreen.qml"
click node_confirmation "https://github.com/madhawapolkotuwa/drinkbar/blob/main/Ui/ConfirmationScreen.qml"
click node_preparing "https://github.com/madhawapolkotuwa/drinkbar/blob/main/Ui/PreparingDrinkScreen.qml"
click node_enjoy "https://github.com/madhawapolkotuwa/drinkbar/blob/main/Ui/EnjoyMegScreen.qml"
click node_custom_item "https://github.com/madhawapolkotuwa/drinkbar/blob/main/Ui/Items/DrinkCustomItem.qml"
click node_controller "https://github.com/madhawapolkotuwa/drinkbar/blob/main/Controllers/systemcontroller.cpp"

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_entry,node_root toneBlue
class node_catalog_data,node_drink_model,node_hot_model,node_cool_model,node_juice_model,node_drink toneAmber
class node_category,node_drink_select,node_size_select,node_sugar_select,node_confirmation,node_preparing,node_enjoy,node_custom_item toneMint
class node_controller toneRose
class node_user toneIndigo
```

## Components

### Application

- [Qt entry point](https://github.com/madhawapolkotuwa/drinkbar/blob/main/main.cpp): `main.cpp`
- [QML root](https://github.com/madhawapolkotuwa/drinkbar/blob/main/Main.qml): `Main.qml`

### Drink catalog

- [Drink catalog data](https://github.com/madhawapolkotuwa/drinkbar/blob/main/Ui/assets/AllDrinks.json): `Ui/assets/AllDrinks.json`
- [Catalog model](https://github.com/madhawapolkotuwa/drinkbar/blob/main/Models/drinkmodel.cpp): `Models/drinkmodel.cpp`
- [Hot drinks](https://github.com/madhawapolkotuwa/drinkbar/blob/main/Models/hotdrinkmodel.h): `Models/hotdrinkmodel.h`
- [Cool drinks](https://github.com/madhawapolkotuwa/drinkbar/blob/main/Models/cooldrinkmodel.h): `Models/cooldrinkmodel.h`
- [Fresh juices](https://github.com/madhawapolkotuwa/drinkbar/blob/main/Models/freshjuicemodel.h): `Models/freshjuicemodel.h`
- [Drink record](https://github.com/madhawapolkotuwa/drinkbar/blob/main/Models/drink.h): `Models/drink.h`

### Ordering flow

- [Temperature choice](https://github.com/madhawapolkotuwa/drinkbar/blob/main/Ui/HotCoolSelectScreen.qml): `Ui/HotCoolSelectScreen.qml`
- [Drink selection](https://github.com/madhawapolkotuwa/drinkbar/blob/main/Ui/DrinkSelectScreen.qml): `Ui/DrinkSelectScreen.qml`
- [Size selection](https://github.com/madhawapolkotuwa/drinkbar/blob/main/Ui/SizeSelectScreen.qml): `Ui/SizeSelectScreen.qml`
- [Sugar selection](https://github.com/madhawapolkotuwa/drinkbar/blob/main/Ui/SugarLevelSelectScreen.qml): `Ui/SugarLevelSelectScreen.qml`
- [Order confirmation](https://github.com/madhawapolkotuwa/drinkbar/blob/main/Ui/ConfirmationScreen.qml): `Ui/ConfirmationScreen.qml`
- [Preparation screen](https://github.com/madhawapolkotuwa/drinkbar/blob/main/Ui/PreparingDrinkScreen.qml): `Ui/PreparingDrinkScreen.qml`
- [Completion screen](https://github.com/madhawapolkotuwa/drinkbar/blob/main/Ui/EnjoyMegScreen.qml): `Ui/EnjoyMegScreen.qml`
- [Drink item view](https://github.com/madhawapolkotuwa/drinkbar/blob/main/Ui/Items/DrinkCustomItem.qml): `Ui/Items/DrinkCustomItem.qml`

### Selection and preparation

- [System controller](https://github.com/madhawapolkotuwa/drinkbar/blob/main/Controllers/systemcontroller.cpp): `Controllers/systemcontroller.cpp`

### Other components

- **Customer**

## Connections

- Customer → QML root: uses
- Qt entry point → QML root: loads (evidence: `main.cpp`)
- Qt entry point → Hot drinks: creates and loads (evidence: `main.cpp`)
- Qt entry point → Cool drinks: creates and loads (evidence: `main.cpp`)
- Qt entry point → Fresh juices: creates and loads (evidence: `main.cpp`)
- Qt entry point → System controller: registers (evidence: `main.cpp`)
- Hot drinks → Drink catalog data: loads
- Cool drinks → Drink catalog data: loads
- Fresh juices → Drink catalog data: loads
- Hot drinks → Catalog model: inherits
- Cool drinks → Catalog model: inherits
- Fresh juices → Catalog model: inherits (evidence: `Models/freshjuicemodel.h`)
- Catalog model → Drink record: uses records
- System controller → Drink record: creates and stores (evidence: `Controllers/systemcontroller.cpp`)
- QML root → Temperature choice: shows
- Temperature choice → Drink selection: continues to
- Drink selection → Drink item view: renders
- Drink selection → Size selection: continues to
- Size selection → Sugar selection: continues to
- Sugar selection → Order confirmation: continues to
- Order confirmation → Preparation screen: continues to
- Preparation screen → Completion screen: continues to
- Preparation screen → System controller: starts preparation
