# vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm architecture

> Architecture diagram of the GitHub repository vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm, 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/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm
- Repository: https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm

## Overview

OpticShop is a Vietnamese eyewear storefront with customer shopping, account and warranty pages, plus staff and admin operations. The main customer flow is browse/search products, inspect a product, add it to the persistent cart, submit checkout, and reach order confirmation; the implemented order API writes through a database adapter. Separate login and registration handlers support accounts, while admin/staff screens cover catalog, inventory, users, and order handling. The README documents SQLite persistence and these capabilities; several UI routes and integrations were not sampled, so edges are limited to evidenced calls or documented relationships.

Main entry points: [`lib/data/mock-admin.ts`](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/lib/data/mock-admin.ts) (Operations Data), [`lib/data/mock-products.ts`](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/lib/data/mock-products.ts) (Product Data), [`lib/db.ts`](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/lib/db.ts) (Database Adapter), [`lib/context/CartContext.tsx`](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/lib/context/CartContext.tsx) (Cart State)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_shop["Customer Storefront"]
  node_catalog["Product Catalog<br/>[page.tsx]"]
  node_product["Product Detail<br/>[page.tsx]"]
  node_search["Product Search<br/>[page.tsx]"]
  node_home["Storefront Home<br/>[page.tsx]"]
  node_warranty["Warranty Service<br/>[page.tsx]"]
end

subgraph group_commerce["Cart and Checkout"]
  node_cart["Cart State<br/>[CartContext.tsx]"]
  node_cartpage["Cart Page<br/>[page.tsx]"]
  node_checkout["Checkout<br/>[page.tsx]"]
  node_confirmation["Order Confirmation<br/>[page.tsx]"]
  node_orderspage["Customer Orders<br/>[page.tsx]"]
end

subgraph group_identity["Accounts"]
  node_register["Registration<br/>[page.tsx]"]
  node_login["Sign In<br/>[page.tsx]"]
  node_account["Customer Account<br/>[page.tsx]"]
end

subgraph group_operations["Staff and Admin"]
  node_admin["Admin Console<br/>[page.tsx]"]
  node_adminproducts["Product Management<br/>[page.tsx]"]
  node_newproduct["Product Entry<br/>[page.tsx]"]
  node_inventory["Inventory<br/>[page.tsx]"]
  node_adminorders["Order Management<br/>[page.tsx]"]
  node_users["User Management<br/>[page.tsx]"]
  node_stafforders["Staff Order Queue<br/>[page.tsx]"]
  node_staffdone["Processed Orders<br/>[page.tsx]"]
end

subgraph group_platform["API and Data"]
  node_productdata["Product Data<br/>[mock-products.ts]"]
  node_admindata["Operations Data<br/>[mock-admin.ts]"]
  node_productsapi["Products API<br/>[route.ts]"]
  node_ordersapi["Orders API<br/>[route.ts]"]
  node_loginapi["Login API<br/>[route.ts]"]
  node_registerapi["Registration API<br/>[route.ts]"]
  node_db["Database Adapter<br/>[db.ts]"]
  node_sqlite[("SQLite Database<br/>[opticshop.db]")]
end

node_customer(("Shopper"))

node_customer -.->|"browses"| node_catalog
node_customer -.->|"searches"| node_search
node_catalog -->|"reads catalog"| node_productdata
node_search -->|"searches data"| node_productdata
node_product -->|"loads product"| node_productdata
node_product -->|"adds item"| node_cart
node_catalog -.->|"adds item"| node_cart
node_cart -.->|"provides state"| node_cartpage
node_checkout -->|"reads and clears"| node_cart
node_checkout -.->|"submits order"| node_ordersapi
node_ordersapi -->|"queries and writes"| node_db
node_productsapi -->|"loads products"| node_db
node_login -.->|"authenticates"| node_loginapi
node_register -.->|"registers"| node_registerapi
node_loginapi -->|"checks and logs"| node_db
node_registerapi -->|"checks and creates"| node_db
node_db -.->|"uses local store"| node_sqlite
node_admin -->|"reads metrics"| node_admindata
node_admin -->|"reads stock"| node_productdata
node_adminorders -->|"reads order data"| node_admindata
node_users -->|"reads user data"| node_admindata
node_adminproducts -->|"uses catalog data"| node_productdata
node_inventory -->|"uses stock data"| node_productdata
node_stafforders -->|"reads order data"| node_admindata
node_staffdone -->|"reads processed data"| node_admindata
node_orderspage -->|"reads order data"| node_admindata
node_account -->|"uses account data"| node_admindata

click node_catalog "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(shop)/san-pham/page.tsx"
click node_product "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(shop)/san-pham/%5Bid%5D/page.tsx"
click node_search "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(shop)/tim-kiem/page.tsx"
click node_home "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(shop)/page.tsx"
click node_warranty "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(shop)/bao-hanh/page.tsx"
click node_cart "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/lib/context/CartContext.tsx"
click node_cartpage "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(shop)/gio-hang/page.tsx"
click node_checkout "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(shop)/thanh-toan/page.tsx"
click node_confirmation "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(shop)/dat-hang-thanh-cong/page.tsx"
click node_orderspage "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(shop)/don-hang/page.tsx"
click node_register "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(auth)/dang-ky/page.tsx"
click node_login "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(auth)/dang-nhap/page.tsx"
click node_account "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(shop)/tai-khoan/page.tsx"
click node_admin "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(admin)/quan-tri/page.tsx"
click node_adminproducts "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(admin)/quan-tri/san-pham/page.tsx"
click node_newproduct "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(admin)/quan-tri/san-pham/them-moi/page.tsx"
click node_inventory "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(admin)/quan-tri/kho-hang/page.tsx"
click node_adminorders "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(admin)/quan-tri/don-hang/page.tsx"
click node_users "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(admin)/quan-tri/nguoi-dung/page.tsx"
click node_stafforders "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(nhan-vien)/nhan-vien/don-hang/page.tsx"
click node_staffdone "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(nhan-vien)/nhan-vien/da-xu-ly/page.tsx"
click node_productdata "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/lib/data/mock-products.ts"
click node_admindata "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/lib/data/mock-admin.ts"
click node_productsapi "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/api/products/route.ts"
click node_ordersapi "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/api/orders/route.ts"
click node_loginapi "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/api/auth/login/route.ts"
click node_registerapi "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/api/auth/register/route.ts"
click node_db "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/lib/db.ts"
click node_sqlite "https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/database/opticshop.db"

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_catalog,node_product,node_search,node_home,node_warranty toneBlue
class node_cart,node_cartpage,node_checkout,node_confirmation,node_orderspage toneAmber
class node_register,node_login,node_account toneMint
class node_admin,node_adminproducts,node_newproduct,node_inventory,node_adminorders,node_users,node_stafforders,node_staffdone toneRose
class node_productdata,node_admindata,node_productsapi,node_ordersapi,node_loginapi,node_registerapi,node_db,node_sqlite,node_customer toneIndigo
```

## Components

### Customer Storefront

- [Product Catalog](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(shop)/san-pham/page.tsx): `app/(shop)/san-pham/page.tsx`
- [Product Detail](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(shop)/san-pham/%5Bid%5D/page.tsx): `app/(shop)/san-pham/[id]/page.tsx`
- [Product Search](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(shop)/tim-kiem/page.tsx): `app/(shop)/tim-kiem/page.tsx`
- [Storefront Home](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(shop)/page.tsx): `app/(shop)/page.tsx`
- [Warranty Service](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(shop)/bao-hanh/page.tsx): `app/(shop)/bao-hanh/page.tsx`

### Cart and Checkout

- [Cart State](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/lib/context/CartContext.tsx): `lib/context/CartContext.tsx`
- [Cart Page](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(shop)/gio-hang/page.tsx): `app/(shop)/gio-hang/page.tsx`
- [Checkout](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(shop)/thanh-toan/page.tsx): `app/(shop)/thanh-toan/page.tsx`
- [Order Confirmation](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(shop)/dat-hang-thanh-cong/page.tsx): `app/(shop)/dat-hang-thanh-cong/page.tsx`
- [Customer Orders](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(shop)/don-hang/page.tsx): `app/(shop)/don-hang/page.tsx`

### Accounts

- [Registration](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(auth)/dang-ky/page.tsx): `app/(auth)/dang-ky/page.tsx`
- [Sign In](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(auth)/dang-nhap/page.tsx): `app/(auth)/dang-nhap/page.tsx`
- [Customer Account](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(shop)/tai-khoan/page.tsx): `app/(shop)/tai-khoan/page.tsx`

### Staff and Admin

- [Admin Console](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(admin)/quan-tri/page.tsx): `app/(admin)/quan-tri/page.tsx`
- [Product Management](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(admin)/quan-tri/san-pham/page.tsx): `app/(admin)/quan-tri/san-pham/page.tsx`
- [Product Entry](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(admin)/quan-tri/san-pham/them-moi/page.tsx): `app/(admin)/quan-tri/san-pham/them-moi/page.tsx`
- [Inventory](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(admin)/quan-tri/kho-hang/page.tsx): `app/(admin)/quan-tri/kho-hang/page.tsx`
- [Order Management](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(admin)/quan-tri/don-hang/page.tsx): `app/(admin)/quan-tri/don-hang/page.tsx`
- [User Management](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(admin)/quan-tri/nguoi-dung/page.tsx): `app/(admin)/quan-tri/nguoi-dung/page.tsx`
- [Staff Order Queue](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(nhan-vien)/nhan-vien/don-hang/page.tsx): `app/(nhan-vien)/nhan-vien/don-hang/page.tsx`
- [Processed Orders](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/(nhan-vien)/nhan-vien/da-xu-ly/page.tsx): `app/(nhan-vien)/nhan-vien/da-xu-ly/page.tsx`

### API and Data

- [Product Data](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/lib/data/mock-products.ts): `lib/data/mock-products.ts`
- [Operations Data](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/lib/data/mock-admin.ts): `lib/data/mock-admin.ts`
- [Products API](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/api/products/route.ts): `app/api/products/route.ts`
- [Orders API](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/api/orders/route.ts): `app/api/orders/route.ts`
- [Login API](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/api/auth/login/route.ts): `app/api/auth/login/route.ts`
- [Registration API](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/app/api/auth/register/route.ts): `app/api/auth/register/route.ts`
- [Database Adapter](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/lib/db.ts): `lib/db.ts`
- [SQLite Database](https://github.com/vietthangpq099-prog/nguyenhuuvietthang-24ct1-cnpm/blob/main/database/opticshop.db): `database/opticshop.db`

### Other components

- **Shopper**

## Connections

- Shopper → Product Catalog: browses
- Shopper → Product Search: searches
- Product Catalog → Product Data: reads catalog (evidence: `app/(shop)/san-pham/page.tsx`)
- Product Search → Product Data: searches data (evidence: `app/(shop)/tim-kiem/page.tsx`)
- Product Detail → Product Data: loads product (evidence: `app/(shop)/san-pham/[id]/page.tsx`)
- Product Detail → Cart State: adds item (evidence: `app/(shop)/san-pham/[id]/page.tsx`)
- Product Catalog → Cart State: adds item
- Cart State → Cart Page: provides state
- Checkout → Cart State: reads and clears (evidence: `app/(shop)/thanh-toan/page.tsx`)
- Checkout → Orders API: submits order
- Orders API → Database Adapter: queries and writes (evidence: `app/api/orders/route.ts`)
- Products API → Database Adapter: loads products (evidence: `app/api/products/route.ts`)
- Sign In → Login API: authenticates
- Registration → Registration API: registers
- Login API → Database Adapter: checks and logs (evidence: `app/api/auth/login/route.ts`)
- Registration API → Database Adapter: checks and creates (evidence: `app/api/auth/register/route.ts`)
- Database Adapter → SQLite Database: uses local store (evidence: `README.md`)
- Admin Console → Operations Data: reads metrics (evidence: `app/(admin)/quan-tri/page.tsx`)
- Admin Console → Product Data: reads stock (evidence: `app/(admin)/quan-tri/page.tsx`)
- Order Management → Operations Data: reads order data (evidence: `app/(admin)/quan-tri/don-hang/page.tsx`)
- User Management → Operations Data: reads user data (evidence: `app/(admin)/quan-tri/nguoi-dung/page.tsx`)
- Product Management → Product Data: uses catalog data (evidence: `app/(admin)/quan-tri/san-pham/page.tsx`)
- Inventory → Product Data: uses stock data (evidence: `app/(admin)/quan-tri/kho-hang/page.tsx`)
- Staff Order Queue → Operations Data: reads order data (evidence: `app/(nhan-vien)/nhan-vien/don-hang/page.tsx`)
- Processed Orders → Operations Data: reads processed data (evidence: `app/(nhan-vien)/nhan-vien/da-xu-ly/page.tsx`)
- Customer Orders → Operations Data: reads order data (evidence: `app/(shop)/don-hang/page.tsx`)
- Customer Account → Operations Data: uses account data (evidence: `app/(shop)/tai-khoan/page.tsx`)
