# jasperbriedel/minute-coffee architecture

> Architecture diagram of the GitHub repository jasperbriedel/minute-coffee, 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/jasperbriedel/minute-coffee
- Repository: https://github.com/jasperbriedel/minute-coffee

## Overview

Minute Coffee is a teaching-oriented coffee shop CRUD application with a server-rendered Express/EJS site and a separate React client for the JSON API. The main customer workflow is browsing/searching products, viewing details, submitting an order, and receiving confirmation; staff authenticate to manage orders and inspect sales, while product and employee administration support operations. The graph preserves both interfaces and the documented MVC/session/database capabilities. Evidence is limited to the README and indexed excerpts; unsampled route and view wiring is not asserted.

Main entry points: [`frontend/src/main.jsx`](https://github.com/jasperbriedel/minute-coffee/blob/main/frontend/src/main.jsx) (Client routes), [`frontend/src/api.mjs`](https://github.com/jasperbriedel/minute-coffee/blob/main/frontend/src/api.mjs) (HTTP API client), [`backend/server.mjs`](https://github.com/jasperbriedel/minute-coffee/blob/main/backend/server.mjs) (Express server), [`backend/controllers/api/APIController.mjs`](https://github.com/jasperbriedel/minute-coffee/blob/main/backend/controllers/api/APIController.mjs) (API routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Server-rendered site"]
  node_server["Express server<br/>[server.mjs]"]
  node_web_auth["Session authentication"]
  node_web_products["Product pages and admin"]
  node_web_orders["Order handling"]
  node_employee_admin["Employee administration"]
  node_ejs_views["Rendered views"]
  node_xml_view["Order XML template<br/>[orders.xml.ejs]"]
end

subgraph group_api["JSON API"]
  node_api_router["API routes<br/>[APIController.mjs]"]
  node_api_auth["Key authentication"]
  node_api_products["Product API"]
  node_api_orders["Order API and export"]
  node_api_employees["Employee API"]
end

subgraph group_client["React client"]
  node_react_entry["Client routes<br/>[main.jsx]"]
  node_auth_hook["Client authentication"]
  node_login_view["Staff login<br/>[LoginView.jsx]"]
  node_product_list["Product browsing"]
  node_product_details["Product details"]
  node_checkout["Order checkout"]
  node_confirmation["Order confirmation"]
  node_order_management["Order management"]
  node_sales_view["Sales reporting"]
  node_xml_download["XML download"]
  node_api_client["HTTP API client<br/>[api.mjs]"]
end

subgraph group_domain["Domain and persistence"]
  node_products_model["Product records<br/>[ProductModel.mjs]"]
  node_orders_model["Order records<br/>[OrderModel.mjs]"]
  node_order_products["Order line items"]
  node_employees_model["Employee records<br/>[EmployeeModel.mjs]"]
  node_sales_model["Sales records<br/>[SaleModel.mjs]"]
  node_sale_products["Product sales"]
  node_product_employee["Product attribution"]
  node_database[("MySQL access<br/>[DatabaseModel.mjs]")]
end

node_visitor(("Shopper or staff"))
node_mysql[("MySQL database")]

node_visitor -->|"uses pages"| node_server
node_server -->|"mounts routes"| node_web_auth
node_server -->|"mounts routes"| node_web_products
node_server -->|"mounts routes"| node_web_orders
node_server -->|"mounts routes"| node_employee_admin
node_server -->|"mounts API"| node_api_router
node_web_auth -->|"authenticates with"| node_employees_model
node_web_products -->|"reads and updates"| node_products_model
node_web_products -->|"renders pages"| node_ejs_views
node_web_products -->|"checks roles"| node_web_auth
node_web_orders -->|"creates orders"| node_orders_model
node_web_orders -->|"adjusts stock"| node_products_model
node_web_orders -->|"uses line items"| node_order_products
node_web_orders -->|"checks roles"| node_web_auth
node_employee_admin -->|"manages employees"| node_employees_model
node_api_router -->|"routes products"| node_api_products
node_api_router -->|"routes orders"| node_api_orders
node_api_router -->|"routes authentication"| node_api_auth
node_api_router -->|"routes employees"| node_api_employees
node_api_auth -->|"looks up keys"| node_employees_model
node_api_products -->|"reads and writes"| node_products_model
node_api_products -->|"queries sales"| node_sale_products
node_api_orders -->|"creates and reads"| node_orders_model
node_api_orders -->|"exports completed orders"| node_order_products
node_api_orders -->|"formats export date"| node_database
node_api_orders -->|"renders XML"| node_xml_view
node_react_entry -->|"routes to"| node_product_list
node_react_entry -->|"routes to"| node_product_details
node_react_entry -->|"routes to"| node_checkout
node_react_entry -->|"routes to"| node_confirmation
node_react_entry -->|"routes to"| node_order_management
node_react_entry -->|"routes to"| node_sales_view
node_react_entry -->|"routes to"| node_login_view
node_react_entry -->|"provides authentication"| node_auth_hook
node_login_view -->|"uses authentication"| node_auth_hook
node_auth_hook -->|"sends requests"| node_api_client
node_product_list -->|"fetches products"| node_api_client
node_product_details -->|"fetches product"| node_api_client
node_checkout -->|"submits order"| node_api_client
node_confirmation -->|"fetches order"| node_api_client
node_order_management -->|"offers export"| node_xml_download
node_order_management -->|"checks staff"| node_auth_hook
node_sales_view -->|"fetches sales"| node_api_client
node_api_client -.->|"calls JSON API"| node_api_router
node_products_model -->|"queries through"| node_database
node_orders_model -->|"queries through"| node_database
node_order_products -->|"queries through"| node_database
node_employees_model -->|"queries through"| node_database

click node_server "https://github.com/jasperbriedel/minute-coffee/blob/main/backend/server.mjs"
click node_web_auth "https://github.com/jasperbriedel/minute-coffee/blob/main/backend/controllers/AuthenticationController.mjs"
click node_web_products "https://github.com/jasperbriedel/minute-coffee/blob/main/backend/controllers/ProductController.mjs"
click node_web_orders "https://github.com/jasperbriedel/minute-coffee/blob/main/backend/controllers/OrderController.mjs"
click node_employee_admin "https://github.com/jasperbriedel/minute-coffee/blob/main/backend/controllers/EmployeeController.mjs"
click node_ejs_views "https://github.com/jasperbriedel/minute-coffee/tree/main/backend/views"
click node_xml_view "https://github.com/jasperbriedel/minute-coffee/blob/main/backend/views/xml/orders.xml.ejs"
click node_api_router "https://github.com/jasperbriedel/minute-coffee/blob/main/backend/controllers/api/APIController.mjs"
click node_api_auth "https://github.com/jasperbriedel/minute-coffee/blob/main/backend/controllers/api/APIAuthenticationController.mjs"
click node_api_products "https://github.com/jasperbriedel/minute-coffee/blob/main/backend/controllers/api/APIProductsController.mjs"
click node_api_orders "https://github.com/jasperbriedel/minute-coffee/blob/main/backend/controllers/api/APIOrderController.mjs"
click node_api_employees "https://github.com/jasperbriedel/minute-coffee/blob/main/backend/controllers/api/APIEmployeeController.mjs"
click node_react_entry "https://github.com/jasperbriedel/minute-coffee/blob/main/frontend/src/main.jsx"
click node_auth_hook "https://github.com/jasperbriedel/minute-coffee/blob/main/frontend/src/authentication/useAuthenticate.jsx"
click node_login_view "https://github.com/jasperbriedel/minute-coffee/blob/main/frontend/src/authentication/LoginView.jsx"
click node_product_list "https://github.com/jasperbriedel/minute-coffee/blob/main/frontend/src/products/ProductListView.jsx"
click node_product_details "https://github.com/jasperbriedel/minute-coffee/blob/main/frontend/src/products/ProductDetailsView.jsx"
click node_checkout "https://github.com/jasperbriedel/minute-coffee/blob/main/frontend/src/products/ProductCheckoutView.jsx"
click node_confirmation "https://github.com/jasperbriedel/minute-coffee/blob/main/frontend/src/orders/OrderConfirmationView.jsx"
click node_order_management "https://github.com/jasperbriedel/minute-coffee/blob/main/frontend/src/orders/OrderManagementView.jsx"
click node_sales_view "https://github.com/jasperbriedel/minute-coffee/blob/main/frontend/src/products/ProductSalesView.jsx"
click node_xml_download "https://github.com/jasperbriedel/minute-coffee/blob/main/frontend/src/common/XMLDownloadButton.jsx"
click node_api_client "https://github.com/jasperbriedel/minute-coffee/blob/main/frontend/src/api.mjs"
click node_products_model "https://github.com/jasperbriedel/minute-coffee/blob/main/backend/models/ProductModel.mjs"
click node_orders_model "https://github.com/jasperbriedel/minute-coffee/blob/main/backend/models/OrderModel.mjs"
click node_order_products "https://github.com/jasperbriedel/minute-coffee/blob/main/backend/models/OrderProductModel.mjs"
click node_employees_model "https://github.com/jasperbriedel/minute-coffee/blob/main/backend/models/EmployeeModel.mjs"
click node_sales_model "https://github.com/jasperbriedel/minute-coffee/blob/main/backend/models/SaleModel.mjs"
click node_sale_products "https://github.com/jasperbriedel/minute-coffee/blob/main/backend/models/SaleProductModel.mjs"
click node_product_employee "https://github.com/jasperbriedel/minute-coffee/blob/main/backend/models/ProductEmployeeModel.mjs"
click node_database "https://github.com/jasperbriedel/minute-coffee/blob/main/backend/models/DatabaseModel.mjs"

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_server,node_web_auth,node_web_products,node_web_orders,node_employee_admin,node_ejs_views,node_xml_view toneBlue
class node_api_router,node_api_auth,node_api_products,node_api_orders,node_api_employees,node_mysql toneAmber
class node_react_entry,node_auth_hook,node_login_view,node_product_list,node_product_details,node_checkout,node_confirmation,node_order_management,node_sales_view,node_xml_download,node_api_client toneMint
class node_products_model,node_orders_model,node_order_products,node_employees_model,node_sales_model,node_sale_products,node_product_employee,node_database toneRose
class node_visitor toneIndigo
```

## Components

### Server-rendered site

- [Express server](https://github.com/jasperbriedel/minute-coffee/blob/main/backend/server.mjs): `backend/server.mjs`
- [Session authentication](https://github.com/jasperbriedel/minute-coffee/blob/main/backend/controllers/AuthenticationController.mjs): `backend/controllers/AuthenticationController.mjs`
- [Product pages and admin](https://github.com/jasperbriedel/minute-coffee/blob/main/backend/controllers/ProductController.mjs): `backend/controllers/ProductController.mjs`
- [Order handling](https://github.com/jasperbriedel/minute-coffee/blob/main/backend/controllers/OrderController.mjs): `backend/controllers/OrderController.mjs`
- [Employee administration](https://github.com/jasperbriedel/minute-coffee/blob/main/backend/controllers/EmployeeController.mjs): `backend/controllers/EmployeeController.mjs`
- [Rendered views](https://github.com/jasperbriedel/minute-coffee/tree/main/backend/views): `backend/views`
- [Order XML template](https://github.com/jasperbriedel/minute-coffee/blob/main/backend/views/xml/orders.xml.ejs): `backend/views/xml/orders.xml.ejs`

### JSON API

- [API routes](https://github.com/jasperbriedel/minute-coffee/blob/main/backend/controllers/api/APIController.mjs): `backend/controllers/api/APIController.mjs`
- [Key authentication](https://github.com/jasperbriedel/minute-coffee/blob/main/backend/controllers/api/APIAuthenticationController.mjs): `backend/controllers/api/APIAuthenticationController.mjs`
- [Product API](https://github.com/jasperbriedel/minute-coffee/blob/main/backend/controllers/api/APIProductsController.mjs): `backend/controllers/api/APIProductsController.mjs`
- [Order API and export](https://github.com/jasperbriedel/minute-coffee/blob/main/backend/controllers/api/APIOrderController.mjs): `backend/controllers/api/APIOrderController.mjs`
- [Employee API](https://github.com/jasperbriedel/minute-coffee/blob/main/backend/controllers/api/APIEmployeeController.mjs): `backend/controllers/api/APIEmployeeController.mjs`

### React client

- [Client routes](https://github.com/jasperbriedel/minute-coffee/blob/main/frontend/src/main.jsx): `frontend/src/main.jsx`
- [Client authentication](https://github.com/jasperbriedel/minute-coffee/blob/main/frontend/src/authentication/useAuthenticate.jsx): `frontend/src/authentication/useAuthenticate.jsx`
- [Staff login](https://github.com/jasperbriedel/minute-coffee/blob/main/frontend/src/authentication/LoginView.jsx): `frontend/src/authentication/LoginView.jsx`
- [Product browsing](https://github.com/jasperbriedel/minute-coffee/blob/main/frontend/src/products/ProductListView.jsx): `frontend/src/products/ProductListView.jsx`
- [Product details](https://github.com/jasperbriedel/minute-coffee/blob/main/frontend/src/products/ProductDetailsView.jsx): `frontend/src/products/ProductDetailsView.jsx`
- [Order checkout](https://github.com/jasperbriedel/minute-coffee/blob/main/frontend/src/products/ProductCheckoutView.jsx): `frontend/src/products/ProductCheckoutView.jsx`
- [Order confirmation](https://github.com/jasperbriedel/minute-coffee/blob/main/frontend/src/orders/OrderConfirmationView.jsx): `frontend/src/orders/OrderConfirmationView.jsx`
- [Order management](https://github.com/jasperbriedel/minute-coffee/blob/main/frontend/src/orders/OrderManagementView.jsx): `frontend/src/orders/OrderManagementView.jsx`
- [Sales reporting](https://github.com/jasperbriedel/minute-coffee/blob/main/frontend/src/products/ProductSalesView.jsx): `frontend/src/products/ProductSalesView.jsx`
- [XML download](https://github.com/jasperbriedel/minute-coffee/blob/main/frontend/src/common/XMLDownloadButton.jsx): `frontend/src/common/XMLDownloadButton.jsx`
- [HTTP API client](https://github.com/jasperbriedel/minute-coffee/blob/main/frontend/src/api.mjs): `frontend/src/api.mjs`

### Domain and persistence

- [Product records](https://github.com/jasperbriedel/minute-coffee/blob/main/backend/models/ProductModel.mjs): `backend/models/ProductModel.mjs`
- [Order records](https://github.com/jasperbriedel/minute-coffee/blob/main/backend/models/OrderModel.mjs): `backend/models/OrderModel.mjs`
- [Order line items](https://github.com/jasperbriedel/minute-coffee/blob/main/backend/models/OrderProductModel.mjs): `backend/models/OrderProductModel.mjs`
- [Employee records](https://github.com/jasperbriedel/minute-coffee/blob/main/backend/models/EmployeeModel.mjs): `backend/models/EmployeeModel.mjs`
- [Sales records](https://github.com/jasperbriedel/minute-coffee/blob/main/backend/models/SaleModel.mjs): `backend/models/SaleModel.mjs`
- [Product sales](https://github.com/jasperbriedel/minute-coffee/blob/main/backend/models/SaleProductModel.mjs): `backend/models/SaleProductModel.mjs`
- [Product attribution](https://github.com/jasperbriedel/minute-coffee/blob/main/backend/models/ProductEmployeeModel.mjs): `backend/models/ProductEmployeeModel.mjs`
- [MySQL access](https://github.com/jasperbriedel/minute-coffee/blob/main/backend/models/DatabaseModel.mjs): `backend/models/DatabaseModel.mjs`

### Other components

- **Shopper or staff**
- **MySQL database**

## Connections

- Shopper or staff → Express server: uses pages (evidence: `readme.md`)
- Express server → Session authentication: mounts routes (evidence: `backend/server.mjs`)
- Express server → Product pages and admin: mounts routes (evidence: `backend/server.mjs`)
- Express server → Order handling: mounts routes (evidence: `backend/server.mjs`)
- Express server → Employee administration: mounts routes (evidence: `backend/server.mjs`)
- Express server → API routes: mounts API (evidence: `backend/server.mjs`)
- Session authentication → Employee records: authenticates with (evidence: `backend/controllers/AuthenticationController.mjs`)
- Product pages and admin → Product records: reads and updates (evidence: `backend/controllers/ProductController.mjs`)
- Product pages and admin → Rendered views: renders pages (evidence: `backend/controllers/ProductController.mjs`)
- Product pages and admin → Session authentication: checks roles (evidence: `backend/controllers/ProductController.mjs`)
- Order handling → Order records: creates orders (evidence: `backend/controllers/OrderController.mjs`)
- Order handling → Product records: adjusts stock (evidence: `backend/controllers/OrderController.mjs`)
- Order handling → Order line items: uses line items (evidence: `backend/controllers/OrderController.mjs`)
- Order handling → Session authentication: checks roles (evidence: `backend/controllers/OrderController.mjs`)
- Employee administration → Employee records: manages employees (evidence: `backend/controllers/EmployeeController.mjs`)
- API routes → Product API: routes products (evidence: `backend/controllers/api/APIController.mjs`)
- API routes → Order API and export: routes orders (evidence: `backend/controllers/api/APIController.mjs`)
- API routes → Key authentication: routes authentication (evidence: `backend/controllers/api/APIController.mjs`)
- API routes → Employee API: routes employees (evidence: `backend/controllers/api/APIController.mjs`)
- Key authentication → Employee records: looks up keys (evidence: `backend/controllers/api/APIAuthenticationController.mjs`)
- Product API → Product records: reads and writes (evidence: `backend/controllers/api/APIProductsController.mjs`)
- Product API → Product sales: queries sales (evidence: `backend/controllers/api/APIProductsController.mjs`)
- Order API and export → Order records: creates and reads (evidence: `backend/controllers/api/APIOrderController.mjs`)
- Order API and export → Order line items: exports completed orders (evidence: `backend/controllers/api/APIOrderController.mjs`)
- Order API and export → MySQL access: formats export date (evidence: `backend/controllers/api/APIOrderController.mjs`)
- Order API and export → Order XML template: renders XML (evidence: `backend/controllers/api/APIOrderController.mjs`)
- Client routes → Product browsing: routes to (evidence: `frontend/src/main.jsx`)
- Client routes → Product details: routes to (evidence: `frontend/src/main.jsx`)
- Client routes → Order checkout: routes to (evidence: `frontend/src/main.jsx`)
- Client routes → Order confirmation: routes to (evidence: `frontend/src/main.jsx`)
- Client routes → Order management: routes to (evidence: `frontend/src/main.jsx`)
- Client routes → Sales reporting: routes to (evidence: `frontend/src/main.jsx`)
- Client routes → Staff login: routes to (evidence: `frontend/src/main.jsx`)
- Client routes → Client authentication: provides authentication (evidence: `frontend/src/main.jsx`)
- Staff login → Client authentication: uses authentication (evidence: `frontend/src/authentication/LoginView.jsx`)
- Client authentication → HTTP API client: sends requests (evidence: `frontend/src/authentication/useAuthenticate.jsx`)
- Product browsing → HTTP API client: fetches products (evidence: `frontend/src/products/ProductListView.jsx`)
- Product details → HTTP API client: fetches product (evidence: `frontend/src/products/ProductDetailsView.jsx`)
- Order checkout → HTTP API client: submits order (evidence: `frontend/src/products/ProductCheckoutView.jsx`)
- Order confirmation → HTTP API client: fetches order (evidence: `frontend/src/orders/OrderConfirmationView.jsx`)
- Order management → XML download: offers export (evidence: `frontend/src/orders/OrderManagementView.jsx`)
- Order management → Client authentication: checks staff (evidence: `frontend/src/main.jsx`)
- Sales reporting → HTTP API client: fetches sales (evidence: `frontend/src/products/ProductSalesView.jsx`)
- HTTP API client → API routes: calls JSON API
- Product records → MySQL access: queries through (evidence: `backend/models/ProductModel.mjs`)
- Order records → MySQL access: queries through (evidence: `backend/models/OrderModel.mjs`)
- Order line items → MySQL access: queries through (evidence: `backend/models/OrderProductModel.mjs`)
- Employee records → MySQL access: queries through (evidence: `backend/models/EmployeeModel.mjs`)
