# rw-tafe/coffee architecture

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

- Interactive diagram: https://gitdiagram.com/rw-tafe/coffee
- Repository: https://github.com/rw-tafe/coffee

## Overview

Rossco’s Coffee is a PHP coffee-shop application. The main customer journey is browsing the coffee catalog, adding items to a cart, and checking out; account registration and login support that journey. Separate admin workflows manage coffees, while subscription pages and forms let visitors subscribe to category updates. The graph also includes the shared data-access and page-rendering layers. Relationships are limited to those shown in excerpts or SOURCE INDEX references; unsampled controller details are not inferred.

Main entry points: [`view/coffees.php`](https://github.com/rw-tafe/coffee/blob/main/view/coffees.php) (Coffee catalog), [`controller/checkout_process.php`](https://github.com/rw-tafe/coffee/blob/main/controller/checkout_process.php) (Checkout), [`model/functions_users.php`](https://github.com/rw-tafe/coffee/blob/main/model/functions_users.php) (User data), [`view/nav.php`](https://github.com/rw-tafe/coffee/blob/main/view/nav.php) (Shared navigation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shop["Coffee shop"]
  node_catalog["Coffee catalog<br/>[coffees.php]"]
  node_coffee_admin["Coffee management"]
  node_cart_view["Cart view<br/>[cart.php]"]
  node_cart_actions["Cart actions"]
  node_checkout["Checkout"]
  node_cart_model["Cart data<br/>[functions_cart.php]"]
  node_coffee_model["Coffee data"]
  node_orders["Order data"]
  node_checkout_model["Checkout logic"]
end

subgraph group_accounts["Accounts"]
  node_account["Account page<br/>[account.php]"]
  node_login["Login and registration<br/>[login_form.php]"]
  node_auth_actions["Authentication actions<br/>[authentication.php]"]
  node_registration["Registration action"]
  node_user_model["User data"]
end

subgraph group_subscriptions["Subscriptions"]
  node_subscription_page["Subscription settings<br/>[subscription.php]"]
  node_subscription_actions["Subscription actions"]
  node_subscription_model["Subscription data"]
end

subgraph group_shared["Shared runtime"]
  node_header["Shared header<br/>[header.php]"]
  node_navigation["Shared navigation<br/>[nav.php]"]
  node_footer["Shared footer<br/>[footer.php]"]
  node_messages["User messages"]
  node_database["Database connection<br/>[database.php]"]
end

node_visitor(("Shop visitor"))
node_mysql[("MySQL database")]

node_visitor -->|"browses"| node_catalog
node_catalog -->|"loads coffees"| node_coffee_model
node_catalog -->|"adds item"| node_cart_actions
node_cart_actions -->|"updates cart"| node_cart_model
node_cart_view -->|"loads cart"| node_cart_model
node_cart_view -.->|"submits checkout"| node_checkout
node_checkout -->|"processes checkout"| node_checkout_model
node_checkout -->|"loads user"| node_user_model
node_checkout -.->|"uses order data"| node_orders
node_coffee_admin -->|"manages coffees"| node_coffee_model
node_login -.->|"submits login"| node_auth_actions
node_auth_actions -->|"checks credentials"| node_user_model
node_registration -->|"creates user"| node_user_model
node_account -->|"loads orders"| node_orders
node_subscription_page -->|"loads subscription"| node_subscription_model
node_subscription_actions -->|"updates subscription"| node_subscription_model
node_header -->|"loads categories"| node_subscription_model
node_footer -->|"submits subscription"| node_subscription_actions
node_navigation -->|"loads user"| node_user_model
node_navigation -->|"counts cart"| node_cart_model
node_catalog -->|"renders"| node_header
node_catalog -->|"renders"| node_navigation
node_catalog -->|"renders"| node_footer
node_catalog -->|"displays messages"| node_messages
node_database -->|"connects"| node_mysql
node_database -->|"renders connection error"| node_database

click node_catalog "https://github.com/rw-tafe/coffee/blob/main/view/coffees.php"
click node_coffee_admin "https://github.com/rw-tafe/coffee/blob/main/controller/coffee_add_process.php"
click node_cart_view "https://github.com/rw-tafe/coffee/blob/main/view/cart.php"
click node_cart_actions "https://github.com/rw-tafe/coffee/blob/main/controller/cart_add_process.php"
click node_checkout "https://github.com/rw-tafe/coffee/blob/main/controller/checkout_process.php"
click node_cart_model "https://github.com/rw-tafe/coffee/blob/main/model/functions_cart.php"
click node_coffee_model "https://github.com/rw-tafe/coffee/blob/main/model/functions_coffees.php"
click node_orders "https://github.com/rw-tafe/coffee/blob/main/model/functions_order.php"
click node_checkout_model "https://github.com/rw-tafe/coffee/blob/main/model/functions_checkout.php"
click node_account "https://github.com/rw-tafe/coffee/blob/main/view/account.php"
click node_login "https://github.com/rw-tafe/coffee/blob/main/view/login_form.php"
click node_auth_actions "https://github.com/rw-tafe/coffee/blob/main/controller/authentication.php"
click node_registration "https://github.com/rw-tafe/coffee/blob/main/controller/registration_process.php"
click node_user_model "https://github.com/rw-tafe/coffee/blob/main/model/functions_users.php"
click node_subscription_page "https://github.com/rw-tafe/coffee/blob/main/view/subscription.php"
click node_subscription_actions "https://github.com/rw-tafe/coffee/blob/main/controller/subscription_add_process.php"
click node_subscription_model "https://github.com/rw-tafe/coffee/blob/main/model/functions_subscription.php"
click node_header "https://github.com/rw-tafe/coffee/blob/main/view/header.php"
click node_navigation "https://github.com/rw-tafe/coffee/blob/main/view/nav.php"
click node_footer "https://github.com/rw-tafe/coffee/blob/main/view/footer.php"
click node_messages "https://github.com/rw-tafe/coffee/blob/main/model/functions_messages.php"
click node_database "https://github.com/rw-tafe/coffee/blob/main/model/database.php"

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_catalog,node_coffee_admin,node_cart_view,node_cart_actions,node_checkout,node_cart_model,node_coffee_model,node_orders,node_checkout_model toneBlue
class node_account,node_login,node_auth_actions,node_registration,node_user_model,node_mysql toneAmber
class node_subscription_page,node_subscription_actions,node_subscription_model toneMint
class node_header,node_navigation,node_footer,node_messages,node_database toneRose
class node_visitor toneIndigo
```

## Components

### Coffee shop

- [Coffee catalog](https://github.com/rw-tafe/coffee/blob/main/view/coffees.php): `view/coffees.php`
- [Coffee management](https://github.com/rw-tafe/coffee/blob/main/controller/coffee_add_process.php): `controller/coffee_add_process.php`
- [Cart view](https://github.com/rw-tafe/coffee/blob/main/view/cart.php): `view/cart.php`
- [Cart actions](https://github.com/rw-tafe/coffee/blob/main/controller/cart_add_process.php): `controller/cart_add_process.php`
- [Checkout](https://github.com/rw-tafe/coffee/blob/main/controller/checkout_process.php): `controller/checkout_process.php`
- [Cart data](https://github.com/rw-tafe/coffee/blob/main/model/functions_cart.php): `model/functions_cart.php`
- [Coffee data](https://github.com/rw-tafe/coffee/blob/main/model/functions_coffees.php): `model/functions_coffees.php`
- [Order data](https://github.com/rw-tafe/coffee/blob/main/model/functions_order.php): `model/functions_order.php`
- [Checkout logic](https://github.com/rw-tafe/coffee/blob/main/model/functions_checkout.php): `model/functions_checkout.php`

### Accounts

- [Account page](https://github.com/rw-tafe/coffee/blob/main/view/account.php): `view/account.php`
- [Login and registration](https://github.com/rw-tafe/coffee/blob/main/view/login_form.php): `view/login_form.php`
- [Authentication actions](https://github.com/rw-tafe/coffee/blob/main/controller/authentication.php): `controller/authentication.php`
- [Registration action](https://github.com/rw-tafe/coffee/blob/main/controller/registration_process.php): `controller/registration_process.php`
- [User data](https://github.com/rw-tafe/coffee/blob/main/model/functions_users.php): `model/functions_users.php`

### Subscriptions

- [Subscription settings](https://github.com/rw-tafe/coffee/blob/main/view/subscription.php): `view/subscription.php`
- [Subscription actions](https://github.com/rw-tafe/coffee/blob/main/controller/subscription_add_process.php): `controller/subscription_add_process.php`
- [Subscription data](https://github.com/rw-tafe/coffee/blob/main/model/functions_subscription.php): `model/functions_subscription.php`

### Shared runtime

- [Shared header](https://github.com/rw-tafe/coffee/blob/main/view/header.php): `view/header.php`
- [Shared navigation](https://github.com/rw-tafe/coffee/blob/main/view/nav.php): `view/nav.php`
- [Shared footer](https://github.com/rw-tafe/coffee/blob/main/view/footer.php): `view/footer.php`
- [User messages](https://github.com/rw-tafe/coffee/blob/main/model/functions_messages.php): `model/functions_messages.php`
- [Database connection](https://github.com/rw-tafe/coffee/blob/main/model/database.php): `model/database.php`

### Other components

- **Shop visitor**
- **MySQL database**

## Connections

- Shop visitor → Coffee catalog: browses (evidence: `view/coffees.php`)
- Coffee catalog → Coffee data: loads coffees (evidence: `view/coffees.php`)
- Coffee catalog → Cart actions: adds item (evidence: `view/coffees.php`)
- Cart actions → Cart data: updates cart (evidence: `controller/cart_add_process.php`)
- Cart view → Cart data: loads cart (evidence: `view/cart.php`)
- Cart view → Checkout: submits checkout
- Checkout → Checkout logic: processes checkout (evidence: `controller/checkout_process.php`)
- Checkout → User data: loads user (evidence: `controller/checkout_process.php`)
- Checkout → Order data: uses order data
- Coffee management → Coffee data: manages coffees (evidence: `controller/coffee_add_process.php`)
- Login and registration → Authentication actions: submits login
- Authentication actions → User data: checks credentials (evidence: `controller/authentication.php`)
- Registration action → User data: creates user (evidence: `controller/registration_process.php`)
- Account page → Order data: loads orders (evidence: `view/account.php`)
- Subscription settings → Subscription data: loads subscription (evidence: `view/subscription.php`)
- Subscription actions → Subscription data: updates subscription (evidence: `controller/subscription_add_process.php`)
- Shared header → Subscription data: loads categories (evidence: `view/header.php`)
- Shared footer → Subscription actions: submits subscription (evidence: `view/footer.php`)
- Shared navigation → User data: loads user (evidence: `view/nav.php`)
- Shared navigation → Cart data: counts cart (evidence: `view/nav.php`)
- Coffee catalog → Shared header: renders (evidence: `view/coffees.php`)
- Coffee catalog → Shared navigation: renders (evidence: `view/coffees.php`)
- Coffee catalog → Shared footer: renders (evidence: `view/coffees.php`)
- Coffee catalog → User messages: displays messages (evidence: `view/coffees.php`)
- Database connection → MySQL database: connects (evidence: `model/database.php`)
- Database connection → Database connection: renders connection error (evidence: `model/database.php`)
