# baizhi2503/cafe--standalone- architecture

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

- Interactive diagram: https://gitdiagram.com/baizhi2503/cafe--standalone-
- Repository: https://github.com/baizhi2503/cafe--standalone-

## Overview

This is a standalone Discord cafe-ordering bot. A staff member opens a cafe session for a customer; the customer browses the menu or builds a custom drink, adds items, checks out, selects dine-in or takeaway and a tip, then receives a preparation estimate and completed-order delivery. The map preserves menu presentation, order/session handling, custom-drink composition, and delivery/logging. Source excerpts support the principal calls; menu JSON structure and some interaction branches are not shown, so no extra links are inferred for them.

Main entry points: [`interaction_handler.js`](https://github.com/baizhi2503/cafe--standalone-/blob/master/interaction_handler.js) (Button handling), [`cafeindex.js`](https://github.com/baizhi2503/cafe--standalone-/blob/master/cafeindex.js) (Cafe command), [`cafe_utils.js`](https://github.com/baizhi2503/cafe--standalone-/blob/master/cafe_utils.js) (Delivery and logging), [`embed_builder.js`](https://github.com/baizhi2503/cafe--standalone-/blob/master/embed_builder.js) (Order presentation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Discord entry"]
  node_cafe_command["Cafe command<br/>[cafeindex.js]"]
  node_session_store[("Active orders<br/>[cafeindex.js]")]
  node_interaction_router["Interaction router<br/>[cafeindex.js]"]
end

subgraph group_ordering["Ordering experience"]
  node_button_flow["Button handling"]
  node_modal_flow["Modal handling"]
  node_menu_logic["Menu browsing<br/>[menu_logic.js]"]
  node_menu_data[("Menu catalog<br/>[menu.json]")]
  node_custom_drink["Custom drink builder"]
  node_drink_naming["Drink naming<br/>[cafe_utils.js]"]
  node_order_embeds["Order presentation<br/>[embed_builder.js]"]
  node_button_components["Order controls<br/>[embed_builder.js]"]
end

subgraph group_fulfillment["Order fulfillment"]
  node_prep_time["Preparation estimate<br/>[cafe_utils.js]"]
  node_delivery["Delivery and logging<br/>[cafe_utils.js]"]
end

node_staff(("Cafe staff"))
node_customer(("Customer"))
node_discord["Discord API"]
node_dinein_channel["Dine-in channel"]
node_customer_dm["Customer DM"]
node_cafe_log["Cafe log channel"]

node_staff -->|"invokes command"| node_discord
node_discord -->|"routes command"| node_cafe_command
node_cafe_command -->|"creates session"| node_session_store
node_cafe_command -->|"renders terminal"| node_order_embeds
node_cafe_command -->|"adds controls"| node_button_components
node_cafe_command -->|"replies"| node_discord
node_customer -->|"submits interactions"| node_discord
node_discord -->|"dispatches events"| node_interaction_router
node_interaction_router -->|"routes buttons"| node_button_flow
node_interaction_router -->|"routes modals"| node_modal_flow
node_button_flow -->|"reads and updates"| node_session_store
node_modal_flow -->|"reads and updates"| node_session_store
node_button_flow -->|"requests menu data"| node_menu_logic
node_menu_logic -->|"reads catalog"| node_menu_data
node_button_flow -->|"renders order"| node_order_embeds
node_button_flow -->|"requests controls"| node_button_components
node_modal_flow -->|"renders updated order"| node_order_embeds
node_button_flow -->|"advances drink steps"| node_custom_drink
node_modal_flow -->|"constructs drink name"| node_drink_naming
node_button_flow -->|"constructs drink name"| node_drink_naming
node_button_flow -->|"calculates estimate"| node_prep_time
node_button_flow -->|"finalizes order"| node_delivery
node_delivery -->|"posts served order"| node_dinein_channel
node_delivery -->|"sends takeaway"| node_customer_dm
node_delivery -->|"logs completion"| node_cafe_log

click node_cafe_command "https://github.com/baizhi2503/cafe--standalone-/blob/master/cafeindex.js"
click node_session_store "https://github.com/baizhi2503/cafe--standalone-/blob/master/cafeindex.js"
click node_interaction_router "https://github.com/baizhi2503/cafe--standalone-/blob/master/cafeindex.js"
click node_button_flow "https://github.com/baizhi2503/cafe--standalone-/blob/master/interaction_handler.js"
click node_modal_flow "https://github.com/baizhi2503/cafe--standalone-/blob/master/interaction_handler.js"
click node_menu_logic "https://github.com/baizhi2503/cafe--standalone-/blob/master/menu_logic.js"
click node_menu_data "https://github.com/baizhi2503/cafe--standalone-/blob/master/menu.json"
click node_custom_drink "https://github.com/baizhi2503/cafe--standalone-/blob/master/interaction_handler.js"
click node_drink_naming "https://github.com/baizhi2503/cafe--standalone-/blob/master/cafe_utils.js"
click node_order_embeds "https://github.com/baizhi2503/cafe--standalone-/blob/master/embed_builder.js"
click node_button_components "https://github.com/baizhi2503/cafe--standalone-/blob/master/embed_builder.js"
click node_prep_time "https://github.com/baizhi2503/cafe--standalone-/blob/master/cafe_utils.js"
click node_delivery "https://github.com/baizhi2503/cafe--standalone-/blob/master/cafe_utils.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_cafe_command,node_session_store,node_interaction_router toneBlue
class node_button_flow,node_modal_flow,node_menu_logic,node_menu_data,node_custom_drink,node_drink_naming,node_order_embeds,node_button_components toneAmber
class node_prep_time,node_delivery,node_discord toneMint
class node_staff,node_customer,node_dinein_channel,node_customer_dm,node_cafe_log toneIndigo
```

## Components

### Discord entry

- [Cafe command](https://github.com/baizhi2503/cafe--standalone-/blob/master/cafeindex.js): `cafeindex.js`
- [Active orders](https://github.com/baizhi2503/cafe--standalone-/blob/master/cafeindex.js): `cafeindex.js`
- [Interaction router](https://github.com/baizhi2503/cafe--standalone-/blob/master/cafeindex.js): `cafeindex.js`

### Ordering experience

- [Button handling](https://github.com/baizhi2503/cafe--standalone-/blob/master/interaction_handler.js): `interaction_handler.js`
- [Modal handling](https://github.com/baizhi2503/cafe--standalone-/blob/master/interaction_handler.js): `interaction_handler.js`
- [Menu browsing](https://github.com/baizhi2503/cafe--standalone-/blob/master/menu_logic.js): `menu_logic.js`
- [Menu catalog](https://github.com/baizhi2503/cafe--standalone-/blob/master/menu.json): `menu.json`
- [Custom drink builder](https://github.com/baizhi2503/cafe--standalone-/blob/master/interaction_handler.js): `interaction_handler.js`
- [Drink naming](https://github.com/baizhi2503/cafe--standalone-/blob/master/cafe_utils.js): `cafe_utils.js`
- [Order presentation](https://github.com/baizhi2503/cafe--standalone-/blob/master/embed_builder.js): `embed_builder.js`
- [Order controls](https://github.com/baizhi2503/cafe--standalone-/blob/master/embed_builder.js): `embed_builder.js`

### Order fulfillment

- [Preparation estimate](https://github.com/baizhi2503/cafe--standalone-/blob/master/cafe_utils.js): `cafe_utils.js`
- [Delivery and logging](https://github.com/baizhi2503/cafe--standalone-/blob/master/cafe_utils.js): `cafe_utils.js`

### Other components

- **Cafe staff**
- **Customer**
- **Discord API**
- **Dine-in channel**
- **Customer DM**
- **Cafe log channel**

## Connections

- Cafe staff → Discord API: invokes command
- Discord API → Cafe command: routes command (evidence: `cafeindex.js`)
- Cafe command → Active orders: creates session (evidence: `cafeindex.js`)
- Cafe command → Order presentation: renders terminal (evidence: `cafeindex.js`)
- Cafe command → Order controls: adds controls (evidence: `cafeindex.js`)
- Cafe command → Discord API: replies (evidence: `cafeindex.js`)
- Customer → Discord API: submits interactions
- Discord API → Interaction router: dispatches events (evidence: `cafeindex.js`)
- Interaction router → Button handling: routes buttons (evidence: `cafeindex.js`)
- Interaction router → Modal handling: routes modals (evidence: `cafeindex.js`)
- Button handling → Active orders: reads and updates (evidence: `interaction_handler.js`)
- Modal handling → Active orders: reads and updates (evidence: `interaction_handler.js`)
- Button handling → Menu browsing: requests menu data (evidence: `interaction_handler.js`)
- Menu browsing → Menu catalog: reads catalog (evidence: `menu_logic.js`)
- Button handling → Order presentation: renders order (evidence: `interaction_handler.js`)
- Button handling → Order controls: requests controls (evidence: `interaction_handler.js`)
- Modal handling → Order presentation: renders updated order (evidence: `interaction_handler.js`)
- Button handling → Custom drink builder: advances drink steps (evidence: `interaction_handler.js`)
- Modal handling → Drink naming: constructs drink name (evidence: `interaction_handler.js`)
- Button handling → Drink naming: constructs drink name (evidence: `interaction_handler.js`)
- Button handling → Preparation estimate: calculates estimate (evidence: `interaction_handler.js`)
- Button handling → Delivery and logging: finalizes order (evidence: `interaction_handler.js`)
- Delivery and logging → Dine-in channel: posts served order (evidence: `cafe_utils.js`)
- Delivery and logging → Customer DM: sends takeaway (evidence: `cafe_utils.js`)
- Delivery and logging → Cafe log channel: logs completion (evidence: `cafe_utils.js`)
