# nguyenkhanhhungdev/assignment_2_brewlite architecture

> Architecture diagram of the GitHub repository nguyenkhanhhungdev/assignment_2_brewlite, 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/nguyenkhanhhungdev/assignment_2_brewlite
- Repository: https://github.com/nguyenkhanhhungdev/assignment_2_brewlite

## Overview

BrewLite is a pickup-drink ordering site with customer accounts, sandbox payment, order tracking, and admin tools. The main journey is browsing and customizing a menu, building a cart, placing an order, paying, then following its status; members can also review history and loyalty rewards. Admins separately manage recipes, ingredients and stock, orders, and payment reconciliation. The graph reflects documented capabilities and sampled API calls; several web-to-API and unsampled feature connections are only documented at a high level, so those links are dashed.

Main entry points: [`apps/api/src/app.module.ts`](https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/app.module.ts) (API Modules), [`apps/web/components/admin/orders/OrdersManager.tsx`](https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/web/components/admin/orders/OrdersManager.tsx) (Admin Web), [`apps/api/src/orders/orders.service.ts`](https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/orders/orders.service.ts) (Order Processing), [`apps/api/src/payments/payments.service.ts`](https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/payments/payments.service.ts) (Payment Processing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Customer Web"]
  node_storefront["Storefront<br/>[page.tsx]"]
  node_menu["Menu Catalog<br/>[MenuCatalog.tsx]"]
  node_cart["Cart<br/>[page.tsx]"]
  node_checkout["Checkout<br/>[page.tsx]"]
  node_account["Account &amp; History<br/>[page.tsx]"]
  node_webbff["Web BFF<br/>[route.ts]"]
  node_sessionbff["Session BFF<br/>[route.ts]"]
end

subgraph group_api["API Services"]
  node_auth["Authentication<br/>[auth.service.ts]"]
  node_products["Products &amp; Recipes"]
  node_orders["Order Processing<br/>[orders.service.ts]"]
  node_orderstate["Order Status"]
  node_orderhistory["Order History"]
  node_payments["Payment Processing"]
  node_zalopay["ZaloPay Sandbox<br/>[zalopay.service.ts]"]
  node_loyalty["Loyalty<br/>[loyalty.service.ts]"]
end

subgraph group_operations["Admin Operations"]
  node_ingredientadmin["Ingredient Inventory"]
  node_recipeadmin["Recipe Management<br/>[recipes.service.ts]"]
  node_orderadmin["Order Administration"]
  node_paymentadmin["Payment Reconciliation"]
  node_webadmin["Admin Web<br/>[OrdersManager.tsx]"]
end

subgraph group_platform["Runtime"]
  node_database[("PostgreSQL")]
  node_apiroot["API Modules<br/>[app.module.ts]"]
end

node_customer(("Customer"))
node_administrator(("Administrator"))

node_customer -->|"browses"| node_storefront
node_storefront -.->|"shows menu"| node_menu
node_customer -->|"selects drinks"| node_menu
node_customer -->|"manages cart"| node_cart
node_customer -->|"places order"| node_checkout
node_customer -->|"views account"| node_account
node_checkout -.->|"requests API"| node_webbff
node_webbff -.->|"forwards requests"| node_orders
node_webbff -.->|"forwards requests"| node_products
node_sessionbff -.->|"forwards session"| node_auth
node_orders -.->|"supports payment"| node_payments
node_payments -->|"uses sandbox"| node_zalopay
node_customer -->|"pays sandbox"| node_zalopay
node_account -.->|"views history"| node_orderhistory
node_administrator -->|"manages operations"| node_webadmin
node_webadmin -.->|"manages stock"| node_ingredientadmin
node_webadmin -.->|"manages recipes"| node_recipeadmin
node_webadmin -.->|"manages orders"| node_orderadmin
node_webadmin -.->|"reviews payments"| node_paymentadmin
node_orderadmin -->|"queries orders"| node_orders
node_orderadmin -->|"changes status"| node_orderstate
node_paymentadmin -->|"rechecks attempts"| node_payments
node_administrator -->|"manages ingredients"| node_ingredientadmin
node_auth -->|"reads and writes"| node_database
node_apiroot -->|"registers module"| node_auth
node_apiroot -->|"registers module"| node_products
node_apiroot -->|"registers module"| node_orders
node_apiroot -->|"registers module"| node_payments
node_apiroot -->|"registers module"| node_ingredientadmin
node_apiroot -->|"registers module"| node_recipeadmin
node_administrator -.->|"reviews loyalty"| node_loyalty

click node_storefront "https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/web/app/page.tsx"
click node_menu "https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/web/components/MenuCatalog.tsx"
click node_cart "https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/web/app/cart/page.tsx"
click node_checkout "https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/web/app/checkout/page.tsx"
click node_account "https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/web/app/account/page.tsx"
click node_webbff "https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/web/app/api/%5B...path%5D/route.ts"
click node_sessionbff "https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/web/app/api/session/%5B...path%5D/route.ts"
click node_auth "https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/auth/auth.service.ts"
click node_products "https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/products/products.service.ts"
click node_orders "https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/orders/orders.service.ts"
click node_orderstate "https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/orders/order-state.service.ts"
click node_orderhistory "https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/orders/orders-history.service.ts"
click node_payments "https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/payments/payments.service.ts"
click node_zalopay "https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/payments/zalopay.service.ts"
click node_loyalty "https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/loyalty/loyalty.service.ts"
click node_ingredientadmin "https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/ingredients/ingredients.service.ts"
click node_recipeadmin "https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/recipes/recipes.service.ts"
click node_orderadmin "https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/orders/admin-orders.controller.ts"
click node_paymentadmin "https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/payments/payment-operations.controller.ts"
click node_webadmin "https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/web/components/admin/orders/OrdersManager.tsx"
click node_apiroot "https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/app.module.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_menu,node_cart,node_checkout,node_account,node_webbff,node_sessionbff toneBlue
class node_auth,node_products,node_orders,node_orderstate,node_orderhistory,node_payments,node_zalopay,node_loyalty toneAmber
class node_ingredientadmin,node_recipeadmin,node_orderadmin,node_paymentadmin,node_webadmin toneMint
class node_database,node_apiroot toneRose
class node_customer,node_administrator toneIndigo
```

## Components

### Customer Web

- [Storefront](https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/web/app/page.tsx): `apps/web/app/page.tsx`
- [Menu Catalog](https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/web/components/MenuCatalog.tsx): `apps/web/components/MenuCatalog.tsx`
- [Cart](https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/web/app/cart/page.tsx): `apps/web/app/cart/page.tsx`
- [Checkout](https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/web/app/checkout/page.tsx): `apps/web/app/checkout/page.tsx`
- [Account & History](https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/web/app/account/page.tsx): `apps/web/app/account/page.tsx`
- [Web BFF](https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/web/app/api/%5B...path%5D/route.ts): `apps/web/app/api/[...path]/route.ts`
- [Session BFF](https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/web/app/api/session/%5B...path%5D/route.ts): `apps/web/app/api/session/[...path]/route.ts`

### API Services

- [Authentication](https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/auth/auth.service.ts): `apps/api/src/auth/auth.service.ts`
- [Products & Recipes](https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/products/products.service.ts): `apps/api/src/products/products.service.ts`
- [Order Processing](https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/orders/orders.service.ts): `apps/api/src/orders/orders.service.ts`
- [Order Status](https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/orders/order-state.service.ts): `apps/api/src/orders/order-state.service.ts`
- [Order History](https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/orders/orders-history.service.ts): `apps/api/src/orders/orders-history.service.ts`
- [Payment Processing](https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/payments/payments.service.ts): `apps/api/src/payments/payments.service.ts`
- [ZaloPay Sandbox](https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/payments/zalopay.service.ts): `apps/api/src/payments/zalopay.service.ts`
- [Loyalty](https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/loyalty/loyalty.service.ts): `apps/api/src/loyalty/loyalty.service.ts`

### Admin Operations

- [Ingredient Inventory](https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/ingredients/ingredients.service.ts): `apps/api/src/ingredients/ingredients.service.ts`
- [Recipe Management](https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/recipes/recipes.service.ts): `apps/api/src/recipes/recipes.service.ts`
- [Order Administration](https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/orders/admin-orders.controller.ts): `apps/api/src/orders/admin-orders.controller.ts`
- [Payment Reconciliation](https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/payments/payment-operations.controller.ts): `apps/api/src/payments/payment-operations.controller.ts`
- [Admin Web](https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/web/components/admin/orders/OrdersManager.tsx): `apps/web/components/admin/orders/OrdersManager.tsx`

### Runtime

- **PostgreSQL**
- [API Modules](https://github.com/nguyenkhanhhungdev/assignment_2_brewlite/blob/main/apps/api/src/app.module.ts): `apps/api/src/app.module.ts`

### Other components

- **Customer**
- **Administrator**

## Connections

- Customer → Storefront: browses (evidence: `README.md`)
- Storefront → Menu Catalog: shows menu
- Customer → Menu Catalog: selects drinks (evidence: `README.md`)
- Customer → Cart: manages cart (evidence: `README.md`)
- Customer → Checkout: places order (evidence: `README.md`)
- Customer → Account & History: views account (evidence: `README.md`)
- Checkout → Web BFF: requests API
- Web BFF → Order Processing: forwards requests
- Web BFF → Products & Recipes: forwards requests
- Session BFF → Authentication: forwards session
- Order Processing → Payment Processing: supports payment
- Payment Processing → ZaloPay Sandbox: uses sandbox (evidence: `README.md`)
- Customer → ZaloPay Sandbox: pays sandbox (evidence: `README.md`)
- Account & History → Order History: views history
- Administrator → Admin Web: manages operations (evidence: `README.md`)
- Admin Web → Ingredient Inventory: manages stock
- Admin Web → Recipe Management: manages recipes
- Admin Web → Order Administration: manages orders
- Admin Web → Payment Reconciliation: reviews payments
- Order Administration → Order Processing: queries orders (evidence: `apps/api/src/orders/admin-orders.controller.ts`)
- Order Administration → Order Status: changes status (evidence: `apps/api/src/orders/admin-orders.controller.ts`)
- Payment Reconciliation → Payment Processing: rechecks attempts (evidence: `apps/api/src/payments/payment-operations.controller.ts`)
- Administrator → Ingredient Inventory: manages ingredients (evidence: `README.md`)
- Authentication → PostgreSQL: reads and writes (evidence: `apps/api/src/auth/auth.service.ts`)
- API Modules → Authentication: registers module (evidence: `apps/api/src/app.module.ts`)
- API Modules → Products & Recipes: registers module (evidence: `apps/api/src/app.module.ts`)
- API Modules → Order Processing: registers module (evidence: `apps/api/src/app.module.ts`)
- API Modules → Payment Processing: registers module (evidence: `apps/api/src/app.module.ts`)
- API Modules → Ingredient Inventory: registers module (evidence: `apps/api/src/app.module.ts`)
- API Modules → Recipe Management: registers module (evidence: `apps/api/src/app.module.ts`)
- Administrator → Loyalty: reviews loyalty
