# phucdang-gif/assignment2 architecture

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

- Interactive diagram: https://gitdiagram.com/phucdang-gif/assignment2
- Repository: https://github.com/phucdang-gif/assignment2

## Overview

BrewLite is a cashless coffee-ordering app. Customers browse drinks and toppings, customize a cart, check out and pay, then track orders; baristas manage the preparation queue. The Next.js client calls a NestJS REST API whose domain services use Prisma and PostgreSQL. README and source-index references support the main stages and several backend calls; unsampled page and service internals are not assumed. Payment-provider integrations are shown as optional because their exact runtime wiring was not excerpted.

Main entry points: [`apps/api/src/prisma/prisma.service.ts`](https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/prisma/prisma.service.ts) (Prisma data access), [`apps/api/src/orders/orders.controller.ts`](https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/orders/orders.controller.ts) (Orders API), [`apps/api/src/users/users.service.ts`](https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/users/users.service.ts) (User service), [`apps/web/app/product/[id]/pageProduct.tsx`](https://github.com/phucdang-gif/assignment2/blob/main/apps/web/app/product/%5Bid%5D/pageProduct.tsx) (Product customization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Customer and staff app"]
  node_storefront["Storefront<br/>[page.tsx]"]
  node_product_detail["Product customization<br/>[pageProduct.tsx]"]
  node_cart["Cart<br/>[pageCart.tsx]"]
  node_checkout["Checkout<br/>[page.tsx]"]
  node_order_history["Order tracking<br/>[page.tsx]"]
  node_order_detail["Order detail<br/>[page.tsx]"]
  node_barista_ui["Barista queue<br/>[page.tsx]"]
  node_auth_ui["Sign in and register<br/>[page.tsx]"]
end

subgraph group_commerce["Ordering and catalog"]
  node_catalog_api["Products and toppings API"]
  node_category_api["Categories API"]
  node_orders_api["Orders API"]
  node_orders_service["Order workflow<br/>[orders.service.ts]"]
  node_toppings_api["Toppings API"]
end

subgraph group_identity["Identity and access"]
  node_auth_api["Authentication API<br/>[auth.controller.ts]"]
  node_auth_service["Authentication<br/>[auth.service.ts]"]
  node_users_api["User management"]
  node_users_service["User service<br/>[users.service.ts]"]
  node_access_control["JWT and role guards<br/>[roles.guard.ts]"]
end

subgraph group_backend["API and persistence"]
  node_prisma["Prisma data access<br/>[prisma.service.ts]"]
  node_database[("PostgreSQL")]
end

subgraph group_payments["Payments"]
  node_payments_api["Payments API"]
  node_payments_service["Payment processing"]
  node_payment_provider["Payment providers"]
end

node_customer(("Customer"))
node_barista(("Barista"))

node_customer -->|"browses menu"| node_storefront
node_customer -->|"customizes drinks"| node_product_detail
node_customer -->|"builds order"| node_cart
node_customer -->|"checks out"| node_checkout
node_customer -->|"signs in"| node_auth_ui
node_barista -->|"works queue"| node_barista_ui
node_storefront -->|"requests menu"| node_catalog_api
node_product_detail -.->|"loads product"| node_catalog_api
node_product_detail -.->|"loads options"| node_toppings_api
node_checkout -->|"submits order"| node_orders_api
node_checkout -->|"initiates payment"| node_payments_api
node_order_history -.->|"loads orders"| node_orders_api
node_order_detail -.->|"loads order"| node_orders_api
node_barista_ui -->|"manages queue"| node_orders_api
node_auth_ui -.->|"authenticates"| node_auth_api
node_catalog_api -->|"delegates to"| node_prisma
node_category_api -->|"delegates to"| node_prisma
node_toppings_api -->|"delegates to"| node_prisma
node_orders_api -->|"dispatches to"| node_orders_service
node_orders_service -->|"reads and writes"| node_prisma
node_orders_service -->|"uses account data"| node_users_service
node_auth_api -->|"dispatches to"| node_auth_service
node_auth_service -->|"looks up users"| node_users_service
node_users_api -->|"dispatches to"| node_users_service
node_users_service -->|"reads and writes"| node_prisma
node_access_control -->|"checks roles"| node_users_service
node_payments_api -->|"dispatches to"| node_payments_service
node_payments_service -->|"reads and writes"| node_prisma
node_payments_service -.->|"connects optionally"| node_payment_provider
node_prisma -->|"queries"| node_database

click node_storefront "https://github.com/phucdang-gif/assignment2/blob/main/apps/web/app/page.tsx"
click node_product_detail "https://github.com/phucdang-gif/assignment2/blob/main/apps/web/app/product/%5Bid%5D/pageProduct.tsx"
click node_cart "https://github.com/phucdang-gif/assignment2/blob/main/apps/web/app/cart/pageCart.tsx"
click node_checkout "https://github.com/phucdang-gif/assignment2/blob/main/apps/web/app/checkout/page.tsx"
click node_order_history "https://github.com/phucdang-gif/assignment2/blob/main/apps/web/app/orders/page.tsx"
click node_order_detail "https://github.com/phucdang-gif/assignment2/blob/main/apps/web/app/orders/%5Bid%5D/page.tsx"
click node_barista_ui "https://github.com/phucdang-gif/assignment2/blob/main/apps/web/app/barista/page.tsx"
click node_auth_ui "https://github.com/phucdang-gif/assignment2/blob/main/apps/web/app/login/page.tsx"
click node_catalog_api "https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/products/products.controller.ts"
click node_category_api "https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/categories/categories.controller.ts"
click node_orders_api "https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/orders/orders.controller.ts"
click node_orders_service "https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/orders/orders.service.ts"
click node_auth_api "https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/auth/auth.controller.ts"
click node_auth_service "https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/auth/auth.service.ts"
click node_users_api "https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/users/users.controller.ts"
click node_users_service "https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/users/users.service.ts"
click node_access_control "https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/auth/roles.guard.ts"
click node_payments_api "https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/payments/payments.controller.ts"
click node_payments_service "https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/payments/payments.service.ts"
click node_toppings_api "https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/toppings/toppings.controller.ts"
click node_prisma "https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/prisma/prisma.service.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_storefront,node_product_detail,node_cart,node_checkout,node_order_history,node_order_detail,node_barista_ui,node_auth_ui toneBlue
class node_catalog_api,node_category_api,node_orders_api,node_orders_service,node_toppings_api toneAmber
class node_auth_api,node_auth_service,node_users_api,node_users_service,node_access_control toneMint
class node_prisma,node_database toneRose
class node_payments_api,node_payments_service,node_payment_provider,node_customer,node_barista toneIndigo
```

## Components

### Customer and staff app

- [Storefront](https://github.com/phucdang-gif/assignment2/blob/main/apps/web/app/page.tsx): `apps/web/app/page.tsx`
- [Product customization](https://github.com/phucdang-gif/assignment2/blob/main/apps/web/app/product/%5Bid%5D/pageProduct.tsx): `apps/web/app/product/[id]/pageProduct.tsx`
- [Cart](https://github.com/phucdang-gif/assignment2/blob/main/apps/web/app/cart/pageCart.tsx): `apps/web/app/cart/pageCart.tsx`
- [Checkout](https://github.com/phucdang-gif/assignment2/blob/main/apps/web/app/checkout/page.tsx): `apps/web/app/checkout/page.tsx`
- [Order tracking](https://github.com/phucdang-gif/assignment2/blob/main/apps/web/app/orders/page.tsx): `apps/web/app/orders/page.tsx`
- [Order detail](https://github.com/phucdang-gif/assignment2/blob/main/apps/web/app/orders/%5Bid%5D/page.tsx): `apps/web/app/orders/[id]/page.tsx`
- [Barista queue](https://github.com/phucdang-gif/assignment2/blob/main/apps/web/app/barista/page.tsx): `apps/web/app/barista/page.tsx`
- [Sign in and register](https://github.com/phucdang-gif/assignment2/blob/main/apps/web/app/login/page.tsx): `apps/web/app/login/page.tsx`

### Ordering and catalog

- [Products and toppings API](https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/products/products.controller.ts): `apps/api/src/products/products.controller.ts`
- [Categories API](https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/categories/categories.controller.ts): `apps/api/src/categories/categories.controller.ts`
- [Orders API](https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/orders/orders.controller.ts): `apps/api/src/orders/orders.controller.ts`
- [Order workflow](https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/orders/orders.service.ts): `apps/api/src/orders/orders.service.ts`
- [Toppings API](https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/toppings/toppings.controller.ts): `apps/api/src/toppings/toppings.controller.ts`

### Identity and access

- [Authentication API](https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/auth/auth.controller.ts): `apps/api/src/auth/auth.controller.ts`
- [Authentication](https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/auth/auth.service.ts): `apps/api/src/auth/auth.service.ts`
- [User management](https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/users/users.controller.ts): `apps/api/src/users/users.controller.ts`
- [User service](https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/users/users.service.ts): `apps/api/src/users/users.service.ts`
- [JWT and role guards](https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/auth/roles.guard.ts): `apps/api/src/auth/roles.guard.ts`

### API and persistence

- [Prisma data access](https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/prisma/prisma.service.ts): `apps/api/src/prisma/prisma.service.ts`
- **PostgreSQL**

### Payments

- [Payments API](https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/payments/payments.controller.ts): `apps/api/src/payments/payments.controller.ts`
- [Payment processing](https://github.com/phucdang-gif/assignment2/blob/main/apps/api/src/payments/payments.service.ts): `apps/api/src/payments/payments.service.ts`
- **Payment providers**

### Other components

- **Customer**
- **Barista**

## Connections

- Customer → Storefront: browses menu (evidence: `README.md`)
- Customer → Product customization: customizes drinks (evidence: `README.md`)
- Customer → Cart: builds order (evidence: `README.md`)
- Customer → Checkout: checks out (evidence: `README.md`)
- Customer → Sign in and register: signs in (evidence: `README.md`)
- Barista → Barista queue: works queue (evidence: `README.md`)
- Storefront → Products and toppings API: requests menu (evidence: `README.md`)
- Product customization → Products and toppings API: loads product
- Product customization → Toppings API: loads options
- Checkout → Orders API: submits order (evidence: `README.md`)
- Checkout → Payments API: initiates payment (evidence: `README.md`)
- Order tracking → Orders API: loads orders
- Order detail → Orders API: loads order
- Barista queue → Orders API: manages queue (evidence: `README.md`)
- Sign in and register → Authentication API: authenticates
- Products and toppings API → Prisma data access: delegates to
- Categories API → Prisma data access: delegates to
- Toppings API → Prisma data access: delegates to
- Orders API → Order workflow: dispatches to (evidence: `apps/api/src/orders/orders.controller.ts`)
- Order workflow → Prisma data access: reads and writes (evidence: `apps/api/src/orders/orders.service.ts`)
- Order workflow → User service: uses account data (evidence: `apps/api/src/orders/orders.service.ts`)
- Authentication API → Authentication: dispatches to (evidence: `apps/api/src/auth/auth.controller.ts`)
- Authentication → User service: looks up users (evidence: `apps/api/src/auth/auth.service.ts`)
- User management → User service: dispatches to (evidence: `apps/api/src/users/users.controller.ts`)
- User service → Prisma data access: reads and writes (evidence: `apps/api/src/users/users.service.ts`)
- JWT and role guards → User service: checks roles (evidence: `apps/api/src/auth/roles.guard.ts`)
- Payments API → Payment processing: dispatches to (evidence: `apps/api/src/payments/payments.controller.ts`)
- Payment processing → Prisma data access: reads and writes (evidence: `apps/api/src/payments/payments.service.ts`)
- Payment processing → Payment providers: connects optionally (evidence: `README.md`)
- Prisma data access → PostgreSQL: queries (evidence: `README.md`)
