# crazyjourney-nice/careloop architecture

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

- Interactive diagram: https://gitdiagram.com/crazyjourney-nice/careloop
- Repository: https://github.com/crazyjourney-nice/careloop

## Overview

CareLoop is a community-canteen ordering demo. The main workflow takes a customer or proxy order through review and confirmation, then tracks kitchen preparation and simulated table delivery; staff can assist customers and operate fulfillment, while administrators manage menus and orders. The README documents these product surfaces, and sampled code confirms the API entry point, order-to-fulfillment calls, and in-memory task simulators. UI, admin, realtime, and persistence internals were not fully sampled, so their links are limited to documented or directly supported relationships.

Main entry points: [`src/api/orders.ts`](https://github.com/crazyjourney-nice/careloop/blob/main/src/api/orders.ts) (Order API), [`src/api/index.ts`](https://github.com/crazyjourney-nice/careloop/blob/main/src/api/index.ts) (HTTP and WS server), [`src/ui`](https://github.com/crazyjourney-nice/careloop/tree/main/src/ui) (Customer ordering), [`packages/domain/src/models/MenuItem.ts`](https://github.com/crazyjourney-nice/careloop/blob/main/packages/domain/src/models/MenuItem.ts) (Menu and tables)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Ordering experience"]
  node_customer_ui["Customer ordering"]
  node_staff_ui["Staff workbench"]
  node_admin_ui["Operations admin"]
end

subgraph group_service["API and operations"]
  node_api["HTTP and WS server<br/>[index.ts]"]
  node_orders_api["Order API<br/>[orders.ts]"]
  node_admin_api["Admin API<br/>[admin.ts]"]
  node_realtime["Realtime events<br/>[realtime.ts]"]
  node_payment["Demo payment options<br/>[orders.ts]"]
end

subgraph group_fulfillment["Order fulfillment"]
  node_kitchen["Kitchen task simulator<br/>[index.ts]"]
  node_conveyor["Conveyor simulator<br/>[index.ts]"]
end

subgraph group_domain["Domain and state"]
  node_voice["Voice intent parsing<br/>[index.ts]"]
  node_order_state["Order domain state<br/>[Order.ts]"]
  node_menu_state["Menu and tables<br/>[MenuItem.ts]"]
  node_seed["Demo data seed<br/>[seed.ts]"]
end

node_customer(("Customer or proxy"))
node_staff(("Staff operator"))
node_operator(("Canteen operator"))
node_websocket(("Browser clients"))

node_customer -->|"places or proxies"| node_customer_ui
node_staff -->|"assists and fulfills"| node_staff_ui
node_operator -->|"manages operations"| node_admin_ui
node_customer_ui -->|"parses speech"| node_voice
node_customer_ui -->|"sends requests"| node_api
node_staff_ui -->|"sends requests"| node_api
node_admin_ui -->|"sends requests"| node_api
node_api -->|"dispatches routes"| node_orders_api
node_api -->|"dispatches routes"| node_admin_api
node_api -->|"registers clients"| node_realtime
node_websocket -->|"connects at /ws"| node_api
node_orders_api -->|"updates status"| node_order_state
node_orders_api -->|"validates items"| node_menu_state
node_seed -->|"seeds demo data"| node_menu_state
node_orders_api -->|"creates and advances tasks"| node_kitchen
node_orders_api -->|"creates and advances tasks"| node_conveyor
node_orders_api -->|"emits order events"| node_realtime
node_admin_api -->|"manages menu"| node_menu_state
node_orders_api -.->|"offers demo methods"| node_payment

click node_customer_ui "https://github.com/crazyjourney-nice/careloop/tree/main/src/ui"
click node_staff_ui "https://github.com/crazyjourney-nice/careloop/tree/main/src/ui"
click node_admin_ui "https://github.com/crazyjourney-nice/careloop/tree/main/src/ui"
click node_voice "https://github.com/crazyjourney-nice/careloop/blob/main/packages/domain/src/voice/index.ts"
click node_api "https://github.com/crazyjourney-nice/careloop/blob/main/src/api/index.ts"
click node_orders_api "https://github.com/crazyjourney-nice/careloop/blob/main/src/api/orders.ts"
click node_admin_api "https://github.com/crazyjourney-nice/careloop/blob/main/src/api/admin.ts"
click node_realtime "https://github.com/crazyjourney-nice/careloop/blob/main/src/api/realtime.ts"
click node_order_state "https://github.com/crazyjourney-nice/careloop/blob/main/packages/domain/src/models/Order.ts"
click node_menu_state "https://github.com/crazyjourney-nice/careloop/blob/main/packages/domain/src/models/MenuItem.ts"
click node_seed "https://github.com/crazyjourney-nice/careloop/blob/main/src/database/seed.ts"
click node_kitchen "https://github.com/crazyjourney-nice/careloop/blob/main/src/kitchen/index.ts"
click node_conveyor "https://github.com/crazyjourney-nice/careloop/blob/main/src/conveyor/index.ts"
click node_payment "https://github.com/crazyjourney-nice/careloop/blob/main/src/api/orders.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_customer_ui,node_staff_ui,node_admin_ui,node_websocket toneBlue
class node_api,node_orders_api,node_admin_api,node_realtime,node_payment toneAmber
class node_kitchen,node_conveyor toneMint
class node_voice,node_order_state,node_menu_state,node_seed toneRose
class node_customer,node_staff,node_operator toneIndigo
```

## Components

### Ordering experience

- [Customer ordering](https://github.com/crazyjourney-nice/careloop/tree/main/src/ui): `src/ui`
- [Staff workbench](https://github.com/crazyjourney-nice/careloop/tree/main/src/ui): `src/ui`
- [Operations admin](https://github.com/crazyjourney-nice/careloop/tree/main/src/ui): `src/ui`

### API and operations

- [HTTP and WS server](https://github.com/crazyjourney-nice/careloop/blob/main/src/api/index.ts): `src/api/index.ts`
- [Order API](https://github.com/crazyjourney-nice/careloop/blob/main/src/api/orders.ts): `src/api/orders.ts`
- [Admin API](https://github.com/crazyjourney-nice/careloop/blob/main/src/api/admin.ts): `src/api/admin.ts`
- [Realtime events](https://github.com/crazyjourney-nice/careloop/blob/main/src/api/realtime.ts): `src/api/realtime.ts`
- [Demo payment options](https://github.com/crazyjourney-nice/careloop/blob/main/src/api/orders.ts): `src/api/orders.ts`

### Order fulfillment

- [Kitchen task simulator](https://github.com/crazyjourney-nice/careloop/blob/main/src/kitchen/index.ts): `src/kitchen/index.ts`
- [Conveyor simulator](https://github.com/crazyjourney-nice/careloop/blob/main/src/conveyor/index.ts): `src/conveyor/index.ts`

### Domain and state

- [Voice intent parsing](https://github.com/crazyjourney-nice/careloop/blob/main/packages/domain/src/voice/index.ts): `packages/domain/src/voice/index.ts`
- [Order domain state](https://github.com/crazyjourney-nice/careloop/blob/main/packages/domain/src/models/Order.ts): `packages/domain/src/models/Order.ts`
- [Menu and tables](https://github.com/crazyjourney-nice/careloop/blob/main/packages/domain/src/models/MenuItem.ts): `packages/domain/src/models/MenuItem.ts`
- [Demo data seed](https://github.com/crazyjourney-nice/careloop/blob/main/src/database/seed.ts): `src/database/seed.ts`

### Other components

- **Customer or proxy**
- **Staff operator**
- **Canteen operator**
- **Browser clients**

## Connections

- Customer or proxy → Customer ordering: places or proxies
- Staff operator → Staff workbench: assists and fulfills
- Canteen operator → Operations admin: manages operations
- Customer ordering → Voice intent parsing: parses speech
- Customer ordering → HTTP and WS server: sends requests
- Staff workbench → HTTP and WS server: sends requests
- Operations admin → HTTP and WS server: sends requests
- HTTP and WS server → Order API: dispatches routes
- HTTP and WS server → Admin API: dispatches routes
- HTTP and WS server → Realtime events: registers clients
- Browser clients → HTTP and WS server: connects at /ws
- Order API → Order domain state: updates status
- Order API → Menu and tables: validates items
- Demo data seed → Menu and tables: seeds demo data
- Order API → Kitchen task simulator: creates and advances tasks
- Order API → Conveyor simulator: creates and advances tasks
- Order API → Realtime events: emits order events
- Admin API → Menu and tables: manages menu
- Order API → Demo payment options: offers demo methods
