# as178/mini-munch architecture

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

- Interactive diagram: https://gitdiagram.com/as178/mini-munch
- Repository: https://github.com/as178/mini-munch

## Overview

Mini Munch is a browser-based restaurant ordering system with an Express/Mongoose backend. Customers occupy a table, create and edit a draft order, then submit it; staff manage menu items and progress or discard orders. The graph separates the UI, HTTP routing, service logic, and persisted domain state. The README documents the customer and staff workflows; sampled source confirms the server wiring and several service calls. Some frontend and backend implementation details were not sampled, so uncertain internal links are omitted.

Main entry points: [`mini-munch-backend/server.ts`](https://github.com/as178/mini-munch/blob/main/mini-munch-backend/server.ts) (Express server), [`mini-munch-frontend/src/router.tsx`](https://github.com/as178/mini-munch/blob/main/mini-munch-frontend/src/router.tsx) (Page router), [`mini-munch-backend/services/orderService.ts`](https://github.com/as178/mini-munch/blob/main/mini-munch-backend/services/orderService.ts) (Order service), [`mini-munch-frontend/src/services/api.ts`](https://github.com/as178/mini-munch/blob/main/mini-munch-frontend/src/services/api.ts) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_browser["Browser app<br/>[main.tsx]"]
  node_router["Page router<br/>[router.tsx]"]
  node_tablepage["Table input<br/>[TableInput.tsx]"]
  node_customerpage["Customer dashboard"]
  node_staffpage["Staff dashboard<br/>[StaffDashboard.tsx]"]
  node_apiclient["API client<br/>[api.ts]"]
  node_generated["Generated endpoints"]
end

subgraph group_http["HTTP API"]
  node_server["Express server<br/>[server.ts]"]
  node_tablehttp["Table routes<br/>[tableRoutes.ts]"]
  node_menuhttp["Menu routes<br/>[menuItemRoutes.ts]"]
  node_orderhttp["Order routes<br/>[orderRoutes.ts]"]
  node_tablecontroller["Table controller<br/>[tableController.ts]"]
  node_menucontroller["Menu controller"]
  node_ordercontroller["Order controller<br/>[orderController.ts]"]
  node_errors["Error middleware<br/>[errorMiddleware.ts]"]
end

subgraph group_services["Domain Services"]
  node_tableservice["Table service<br/>[tableService.ts]"]
  node_menuservice["Menu service<br/>[menuItemService.ts]"]
  node_orderservice["Order service<br/>[orderService.ts]"]
end

subgraph group_persistence["Persistence"]
  node_tablemodel["Table model<br/>[Table.ts]"]
  node_menumodel["Menu model<br/>[MenuItem.ts]"]
  node_ordermodel["Order model<br/>[Order.ts]"]
end

node_customer(("Customer"))
node_staff(("Staff"))
node_database[("MongoDB")]

node_customer -->|"uses"| node_browser
node_staff -->|"uses"| node_browser
node_browser -->|"renders"| node_router
node_router -->|"routes to"| node_tablepage
node_router -->|"routes to"| node_customerpage
node_router -->|"routes to"| node_staffpage
node_tablepage -->|"requests"| node_apiclient
node_customerpage -->|"requests"| node_apiclient
node_staffpage -->|"requests"| node_apiclient
node_apiclient -->|"uses"| node_generated
node_generated -->|"HTTP requests"| node_server
node_server -->|"mounts"| node_tablehttp
node_server -->|"mounts"| node_menuhttp
node_server -->|"mounts"| node_orderhttp
node_tablehttp -->|"dispatches"| node_tablecontroller
node_menuhttp -->|"dispatches"| node_menucontroller
node_orderhttp -->|"dispatches"| node_ordercontroller
node_tablecontroller -->|"calls"| node_tableservice
node_menucontroller -->|"calls"| node_menuservice
node_ordercontroller -->|"calls"| node_orderservice
node_tablecontroller -->|"forwards errors"| node_errors
node_menucontroller -->|"forwards errors"| node_errors
node_ordercontroller -->|"forwards errors"| node_errors
node_tableservice -->|"queries"| node_tablemodel
node_orderservice -->|"queries and updates"| node_ordermodel
node_orderservice -->|"checks table"| node_tableservice
node_orderservice -->|"looks up item"| node_menuservice
node_server -->|"connects"| node_database
node_tablemodel -->|"persists"| node_database
node_menumodel -->|"persists"| node_database
node_ordermodel -->|"persists"| node_database

click node_browser "https://github.com/as178/mini-munch/blob/main/mini-munch-frontend/src/main.tsx"
click node_router "https://github.com/as178/mini-munch/blob/main/mini-munch-frontend/src/router.tsx"
click node_tablepage "https://github.com/as178/mini-munch/blob/main/mini-munch-frontend/src/pages/TableInput.tsx"
click node_customerpage "https://github.com/as178/mini-munch/blob/main/mini-munch-frontend/src/pages/CustomerDashboard.tsx"
click node_staffpage "https://github.com/as178/mini-munch/blob/main/mini-munch-frontend/src/pages/StaffDashboard.tsx"
click node_apiclient "https://github.com/as178/mini-munch/blob/main/mini-munch-frontend/src/services/api.ts"
click node_generated "https://github.com/as178/mini-munch/tree/main/mini-munch-frontend/src/services/generated"
click node_server "https://github.com/as178/mini-munch/blob/main/mini-munch-backend/server.ts"
click node_tablehttp "https://github.com/as178/mini-munch/blob/main/mini-munch-backend/routes/tableRoutes.ts"
click node_menuhttp "https://github.com/as178/mini-munch/blob/main/mini-munch-backend/routes/menuItemRoutes.ts"
click node_orderhttp "https://github.com/as178/mini-munch/blob/main/mini-munch-backend/routes/orderRoutes.ts"
click node_tablecontroller "https://github.com/as178/mini-munch/blob/main/mini-munch-backend/controllers/tableController.ts"
click node_menucontroller "https://github.com/as178/mini-munch/blob/main/mini-munch-backend/controllers/menuItemController.ts"
click node_ordercontroller "https://github.com/as178/mini-munch/blob/main/mini-munch-backend/controllers/orderController.ts"
click node_errors "https://github.com/as178/mini-munch/blob/main/mini-munch-backend/middleware/errorMiddleware.ts"
click node_tableservice "https://github.com/as178/mini-munch/blob/main/mini-munch-backend/services/tableService.ts"
click node_menuservice "https://github.com/as178/mini-munch/blob/main/mini-munch-backend/services/menuItemService.ts"
click node_orderservice "https://github.com/as178/mini-munch/blob/main/mini-munch-backend/services/orderService.ts"
click node_tablemodel "https://github.com/as178/mini-munch/blob/main/mini-munch-backend/models/Table.ts"
click node_menumodel "https://github.com/as178/mini-munch/blob/main/mini-munch-backend/models/MenuItem.ts"
click node_ordermodel "https://github.com/as178/mini-munch/blob/main/mini-munch-backend/models/Order.ts"

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_browser,node_router,node_tablepage,node_customerpage,node_staffpage,node_apiclient,node_generated toneBlue
class node_server,node_tablehttp,node_menuhttp,node_orderhttp,node_tablecontroller,node_menucontroller,node_ordercontroller,node_errors,node_database toneAmber
class node_tableservice,node_menuservice,node_orderservice toneMint
class node_tablemodel,node_menumodel,node_ordermodel toneRose
class node_customer,node_staff toneIndigo
```

## Components

### Frontend

- [Browser app](https://github.com/as178/mini-munch/blob/main/mini-munch-frontend/src/main.tsx): `mini-munch-frontend/src/main.tsx`
- [Page router](https://github.com/as178/mini-munch/blob/main/mini-munch-frontend/src/router.tsx): `mini-munch-frontend/src/router.tsx`
- [Table input](https://github.com/as178/mini-munch/blob/main/mini-munch-frontend/src/pages/TableInput.tsx): `mini-munch-frontend/src/pages/TableInput.tsx`
- [Customer dashboard](https://github.com/as178/mini-munch/blob/main/mini-munch-frontend/src/pages/CustomerDashboard.tsx): `mini-munch-frontend/src/pages/CustomerDashboard.tsx`
- [Staff dashboard](https://github.com/as178/mini-munch/blob/main/mini-munch-frontend/src/pages/StaffDashboard.tsx): `mini-munch-frontend/src/pages/StaffDashboard.tsx`
- [API client](https://github.com/as178/mini-munch/blob/main/mini-munch-frontend/src/services/api.ts): `mini-munch-frontend/src/services/api.ts`
- [Generated endpoints](https://github.com/as178/mini-munch/tree/main/mini-munch-frontend/src/services/generated): `mini-munch-frontend/src/services/generated`

### HTTP API

- [Express server](https://github.com/as178/mini-munch/blob/main/mini-munch-backend/server.ts): `mini-munch-backend/server.ts`
- [Table routes](https://github.com/as178/mini-munch/blob/main/mini-munch-backend/routes/tableRoutes.ts): `mini-munch-backend/routes/tableRoutes.ts`
- [Menu routes](https://github.com/as178/mini-munch/blob/main/mini-munch-backend/routes/menuItemRoutes.ts): `mini-munch-backend/routes/menuItemRoutes.ts`
- [Order routes](https://github.com/as178/mini-munch/blob/main/mini-munch-backend/routes/orderRoutes.ts): `mini-munch-backend/routes/orderRoutes.ts`
- [Table controller](https://github.com/as178/mini-munch/blob/main/mini-munch-backend/controllers/tableController.ts): `mini-munch-backend/controllers/tableController.ts`
- [Menu controller](https://github.com/as178/mini-munch/blob/main/mini-munch-backend/controllers/menuItemController.ts): `mini-munch-backend/controllers/menuItemController.ts`
- [Order controller](https://github.com/as178/mini-munch/blob/main/mini-munch-backend/controllers/orderController.ts): `mini-munch-backend/controllers/orderController.ts`
- [Error middleware](https://github.com/as178/mini-munch/blob/main/mini-munch-backend/middleware/errorMiddleware.ts): `mini-munch-backend/middleware/errorMiddleware.ts`

### Domain Services

- [Table service](https://github.com/as178/mini-munch/blob/main/mini-munch-backend/services/tableService.ts): `mini-munch-backend/services/tableService.ts`
- [Menu service](https://github.com/as178/mini-munch/blob/main/mini-munch-backend/services/menuItemService.ts): `mini-munch-backend/services/menuItemService.ts`
- [Order service](https://github.com/as178/mini-munch/blob/main/mini-munch-backend/services/orderService.ts): `mini-munch-backend/services/orderService.ts`

### Persistence

- [Table model](https://github.com/as178/mini-munch/blob/main/mini-munch-backend/models/Table.ts): `mini-munch-backend/models/Table.ts`
- [Menu model](https://github.com/as178/mini-munch/blob/main/mini-munch-backend/models/MenuItem.ts): `mini-munch-backend/models/MenuItem.ts`
- [Order model](https://github.com/as178/mini-munch/blob/main/mini-munch-backend/models/Order.ts): `mini-munch-backend/models/Order.ts`

### Other components

- **Customer**
- **Staff**
- **MongoDB**

## Connections

- Customer → Browser app: uses
- Staff → Browser app: uses
- Browser app → Page router: renders
- Page router → Table input: routes to
- Page router → Customer dashboard: routes to
- Page router → Staff dashboard: routes to
- Table input → API client: requests
- Customer dashboard → API client: requests
- Staff dashboard → API client: requests
- API client → Generated endpoints: uses
- Generated endpoints → Express server: HTTP requests
- Express server → Table routes: mounts
- Express server → Menu routes: mounts
- Express server → Order routes: mounts
- Table routes → Table controller: dispatches
- Menu routes → Menu controller: dispatches
- Order routes → Order controller: dispatches
- Table controller → Table service: calls
- Menu controller → Menu service: calls
- Order controller → Order service: calls
- Table controller → Error middleware: forwards errors
- Menu controller → Error middleware: forwards errors
- Order controller → Error middleware: forwards errors
- Table service → Table model: queries
- Order service → Order model: queries and updates
- Order service → Table service: checks table
- Order service → Menu service: looks up item
- Express server → MongoDB: connects
- Table model → MongoDB: persists
- Menu model → MongoDB: persists
- Order model → MongoDB: persists
