# prronald/beer-challenge architecture

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

- Interactive diagram: https://gitdiagram.com/prronald/beer-challenge
- Repository: https://github.com/prronald/beer-challenge

## Overview

Beer Challenge is a beer-catalog browsing application: a visitor lands on a welcome screen, moves to a product list, and can open a beer’s detail page to inspect its size, price, and stock. The React client retrieves catalog and stock data through Redux async thunks from a separate Express server. The graph includes the catalog, detail, routing/state, and server data stages. Relationships reflect the shown imports, dispatches, routes, and HTTP requests; unsampled modules are represented only where the tree or README supports them.

Main entry points: [`src/viewproduct/ViewProduct.jsx`](https://github.com/prronald/beer-challenge/blob/main/src/viewproduct/ViewProduct.jsx) (Product detail page), [`src/main.jsx`](https://github.com/prronald/beer-challenge/blob/main/src/main.jsx) (App entry and routes), [`src/App.jsx`](https://github.com/prronald/beer-challenge/blob/main/src/App.jsx) (Catalog page), [`src/body/itemsSlice.js`](https://github.com/prronald/beer-challenge/blob/main/src/body/itemsSlice.js) (Catalog and stock state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React client"]
  node_router["App entry and routes<br/>[main.jsx]"]
  node_welcome["Welcome screen<br/>[Welcome.jsx]"]
  node_error["Error page<br/>[ErrorPage.jsx]"]
  node_store["Redux store<br/>[store.js]"]
  node_fetchstate["Catalog and stock state<br/>[itemsSlice.js]"]
end

subgraph group_catalog["Catalog browsing"]
  node_app["Catalog page<br/>[App.jsx]"]
  node_header["Catalog header<br/>[Header.jsx]"]
  node_body["Catalog body<br/>[Body.jsx]"]
  node_items["Catalog loader<br/>[Items.jsx]"]
  node_products["Product cards<br/>[Products.jsx]"]
  node_addlink["Product link<br/>[AddButton.jsx]"]
end

subgraph group_detail["Product details"]
  node_detail["Product detail page<br/>[ViewProduct.jsx]"]
  node_detailnav["Detail navigation<br/>[Nav.jsx]"]
  node_detailimage["Product image<br/>[ImgView.jsx]"]
  node_addbutton["Cart action button<br/>[ButtonAdd.jsx]"]
  node_truncate["Size label formatter<br/>[truncateString.js]"]
  node_redirect["Redirect helper<br/>[redirect.js]"]
end

subgraph group_server["Beer API"]
  node_api["Express API routes<br/>[server.js]"]
  node_catalogdata["Beer catalog data<br/>[products.js]"]
  node_stockdata["Stock and price data<br/>[stock-price.js]"]
end

node_visitor(("Visitor"))

node_visitor -->|"opens app"| node_router
node_router -->|"routes to"| node_welcome
node_router -->|"routes to"| node_app
node_router -->|"routes to"| node_detail
node_router -->|"routes errors to"| node_error
node_welcome -->|"navigates to"| node_app
node_app -->|"renders"| node_header
node_app -->|"renders"| node_body
node_body -->|"renders"| node_items
node_items -->|"dispatches fetches"| node_fetchstate
node_items -->|"renders results"| node_products
node_products -->|"renders links"| node_addlink
node_addlink -->|"links to"| node_detail
node_detail -->|"dispatches fetches"| node_fetchstate
node_detail -->|"renders"| node_detailnav
node_detail -->|"renders"| node_detailimage
node_detail -->|"renders"| node_addbutton
node_detail -->|"formats sizes"| node_truncate
node_detail -->|"imports helper"| node_redirect
node_store -->|"uses reducers"| node_fetchstate
node_fetchstate -->|"requests catalog and stock"| node_api
node_api -->|"serves catalog"| node_catalogdata
node_api -->|"serves stock and prices"| node_stockdata

click node_router "https://github.com/prronald/beer-challenge/blob/main/src/main.jsx"
click node_welcome "https://github.com/prronald/beer-challenge/blob/main/src/components/Welcome.jsx"
click node_error "https://github.com/prronald/beer-challenge/blob/main/src/components/ErrorPage.jsx"
click node_app "https://github.com/prronald/beer-challenge/blob/main/src/App.jsx"
click node_header "https://github.com/prronald/beer-challenge/blob/main/src/header/Header.jsx"
click node_body "https://github.com/prronald/beer-challenge/blob/main/src/body/Body.jsx"
click node_items "https://github.com/prronald/beer-challenge/blob/main/src/body/Items.jsx"
click node_products "https://github.com/prronald/beer-challenge/blob/main/src/body/Products.jsx"
click node_addlink "https://github.com/prronald/beer-challenge/blob/main/src/AddButton.jsx"
click node_detail "https://github.com/prronald/beer-challenge/blob/main/src/viewproduct/ViewProduct.jsx"
click node_detailnav "https://github.com/prronald/beer-challenge/blob/main/src/viewproduct/Nav.jsx"
click node_detailimage "https://github.com/prronald/beer-challenge/blob/main/src/viewproduct/ImgView.jsx"
click node_addbutton "https://github.com/prronald/beer-challenge/blob/main/src/viewproduct/ButtonAdd.jsx"
click node_truncate "https://github.com/prronald/beer-challenge/blob/main/src/viewproduct/truncateString.js"
click node_redirect "https://github.com/prronald/beer-challenge/blob/main/src/functions/redirect.js"
click node_store "https://github.com/prronald/beer-challenge/blob/main/src/store.js"
click node_fetchstate "https://github.com/prronald/beer-challenge/blob/main/src/body/itemsSlice.js"
click node_api "https://github.com/prronald/beer-challenge/blob/main/beer-server-challenge/server.js"
click node_catalogdata "https://github.com/prronald/beer-challenge/blob/main/beer-server-challenge/items/products.js"
click node_stockdata "https://github.com/prronald/beer-challenge/blob/main/beer-server-challenge/items/stock-price.js"

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_router,node_welcome,node_error,node_store,node_fetchstate toneBlue
class node_app,node_header,node_body,node_items,node_products,node_addlink toneAmber
class node_detail,node_detailnav,node_detailimage,node_addbutton,node_truncate,node_redirect toneMint
class node_api,node_catalogdata,node_stockdata toneRose
class node_visitor toneIndigo
```

## Components

### React client

- [App entry and routes](https://github.com/prronald/beer-challenge/blob/main/src/main.jsx): `src/main.jsx`
- [Welcome screen](https://github.com/prronald/beer-challenge/blob/main/src/components/Welcome.jsx): `src/components/Welcome.jsx`
- [Error page](https://github.com/prronald/beer-challenge/blob/main/src/components/ErrorPage.jsx): `src/components/ErrorPage.jsx`
- [Redux store](https://github.com/prronald/beer-challenge/blob/main/src/store.js): `src/store.js`
- [Catalog and stock state](https://github.com/prronald/beer-challenge/blob/main/src/body/itemsSlice.js): `src/body/itemsSlice.js`

### Catalog browsing

- [Catalog page](https://github.com/prronald/beer-challenge/blob/main/src/App.jsx): `src/App.jsx`
- [Catalog header](https://github.com/prronald/beer-challenge/blob/main/src/header/Header.jsx): `src/header/Header.jsx`
- [Catalog body](https://github.com/prronald/beer-challenge/blob/main/src/body/Body.jsx): `src/body/Body.jsx`
- [Catalog loader](https://github.com/prronald/beer-challenge/blob/main/src/body/Items.jsx): `src/body/Items.jsx`
- [Product cards](https://github.com/prronald/beer-challenge/blob/main/src/body/Products.jsx): `src/body/Products.jsx`
- [Product link](https://github.com/prronald/beer-challenge/blob/main/src/AddButton.jsx): `src/AddButton.jsx`

### Product details

- [Product detail page](https://github.com/prronald/beer-challenge/blob/main/src/viewproduct/ViewProduct.jsx): `src/viewproduct/ViewProduct.jsx`
- [Detail navigation](https://github.com/prronald/beer-challenge/blob/main/src/viewproduct/Nav.jsx): `src/viewproduct/Nav.jsx`
- [Product image](https://github.com/prronald/beer-challenge/blob/main/src/viewproduct/ImgView.jsx): `src/viewproduct/ImgView.jsx`
- [Cart action button](https://github.com/prronald/beer-challenge/blob/main/src/viewproduct/ButtonAdd.jsx): `src/viewproduct/ButtonAdd.jsx`
- [Size label formatter](https://github.com/prronald/beer-challenge/blob/main/src/viewproduct/truncateString.js): `src/viewproduct/truncateString.js`
- [Redirect helper](https://github.com/prronald/beer-challenge/blob/main/src/functions/redirect.js): `src/functions/redirect.js`

### Beer API

- [Express API routes](https://github.com/prronald/beer-challenge/blob/main/beer-server-challenge/server.js): `beer-server-challenge/server.js`
- [Beer catalog data](https://github.com/prronald/beer-challenge/blob/main/beer-server-challenge/items/products.js): `beer-server-challenge/items/products.js`
- [Stock and price data](https://github.com/prronald/beer-challenge/blob/main/beer-server-challenge/items/stock-price.js): `beer-server-challenge/items/stock-price.js`

### Other components

- **Visitor**

## Connections

- Visitor → App entry and routes: opens app (evidence: `src/main.jsx`)
- App entry and routes → Welcome screen: routes to (evidence: `src/main.jsx`)
- App entry and routes → Catalog page: routes to (evidence: `src/main.jsx`)
- App entry and routes → Product detail page: routes to (evidence: `src/main.jsx`)
- App entry and routes → Error page: routes errors to (evidence: `src/main.jsx`)
- Welcome screen → Catalog page: navigates to (evidence: `src/components/Welcome.jsx`)
- Catalog page → Catalog header: renders (evidence: `src/App.jsx`)
- Catalog page → Catalog body: renders (evidence: `src/App.jsx`)
- Catalog body → Catalog loader: renders (evidence: `src/body/Body.jsx`)
- Catalog loader → Catalog and stock state: dispatches fetches (evidence: `src/body/Items.jsx`)
- Catalog loader → Product cards: renders results (evidence: `src/body/Items.jsx`)
- Product cards → Product link: renders links (evidence: `src/body/Products.jsx`)
- Product link → Product detail page: links to
- Product detail page → Catalog and stock state: dispatches fetches (evidence: `src/viewproduct/ViewProduct.jsx`)
- Product detail page → Detail navigation: renders (evidence: `src/viewproduct/ViewProduct.jsx`)
- Product detail page → Product image: renders (evidence: `src/viewproduct/ViewProduct.jsx`)
- Product detail page → Cart action button: renders (evidence: `src/viewproduct/ViewProduct.jsx`)
- Product detail page → Size label formatter: formats sizes (evidence: `src/viewproduct/ViewProduct.jsx`)
- Product detail page → Redirect helper: imports helper (evidence: `src/viewproduct/ViewProduct.jsx`)
- Redux store → Catalog and stock state: uses reducers (evidence: `src/store.js`)
- Catalog and stock state → Express API routes: requests catalog and stock (evidence: `src/body/itemsSlice.js`)
- Express API routes → Beer catalog data: serves catalog (evidence: `beer-server-challenge/server.js`)
- Express API routes → Stock and price data: serves stock and prices (evidence: `beer-server-challenge/server.js`)
