# chana758/skincare_firebase architecture

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

- Interactive diagram: https://gitdiagram.com/chana758/skincare_firebase
- Repository: https://github.com/chana758/skincare_firebase

## Overview

This is a skincare e-commerce application with a public storefront, customer accounts and checkout, plus staff POS and administrative consoles. The main customer flow is routed through the storefront to checkout, which creates an order, generates a KHQR payment code, and records an order notification. Staff also have POS and shift-history screens; administrators manage catalog, orders, content, staff, reports, discounts, and messages. The map reflects documented routes and sampled calls; unsampled subsystems are represented at their existing directory paths, without asserting internal wiring that was not shown.

Main entry points: [`src/App.jsx`](https://github.com/chana758/skincare_firebase/blob/main/src/App.jsx) (Route application), [`src/firebase/config.js`](https://github.com/chana758/skincare_firebase/blob/main/src/firebase/config.js) (Firebase setup), [`functions/index.js`](https://github.com/chana758/skincare_firebase/blob/main/functions/index.js) (Cloud Functions exports), [`src/pages/users/Checkout.jsx`](https://github.com/chana758/skincare_firebase/blob/main/src/pages/users/Checkout.jsx) (Checkout)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_app["Route application<br/>[App.jsx]"]
  node_shop["Storefront pages"]
  node_checkout["Checkout<br/>[Checkout.jsx]"]
  node_auth["Account state<br/>[AuthContext.jsx]"]
  node_cart["Shopping cart<br/>[CartContext.jsx]"]
  node_productdata["Product data<br/>[products.js]"]
  node_login["Login<br/>[Login.jsx]"]
end

subgraph group_operations["Staff and admin"]
  node_staffpos["Staff POS"]
  node_poscart["POS cart<br/>[POSCart.jsx]"]
  node_adminconsole["Admin console"]
  node_functions["Cloud Functions exports<br/>[index.js]"]
  node_functionauth["Staff account actions"]
  node_functionorders["Order actions"]
  node_functionpayments["Payment functions"]
  node_webhook["Payment webhook"]
  node_functionreports["Sales summary"]
end

subgraph group_services["Application services"]
  node_paymentservice["Order and payment service<br/>[paymentService.js]"]
  node_notifications["Notification service"]
  node_ordershook["Live orders hook<br/>[useOrders.js]"]
end

subgraph group_backend["Firebase backend"]
  node_firebase["Firebase setup<br/>[config.js]"]
  node_firestore[("Firestore")]
end

node_customer(("Customer"))
node_staff(("Staff"))
node_admin(("Administrator"))
node_bakong["Bakong KHQR library"]

node_customer -->|"uses"| node_app
node_staff -->|"uses"| node_app
node_admin -->|"uses"| node_app
node_app -->|"routes to"| node_shop
node_app -->|"routes to"| node_checkout
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_staffpos
node_app -->|"routes to"| node_adminconsole
node_app -->|"provides"| node_auth
node_login -->|"uses"| node_auth
node_auth -->|"uses"| node_firebase
node_cart -->|"reads and writes"| node_firebase
node_checkout -->|"uses"| node_cart
node_checkout -->|"creates order and QR"| node_paymentservice
node_checkout -->|"creates notification"| node_notifications
node_paymentservice -->|"uses"| node_firebase
node_paymentservice -->|"reads and writes"| node_firestore
node_paymentservice -->|"generates QR with"| node_bakong
node_notifications -->|"uses"| node_firebase
node_notifications -->|"reads and writes"| node_firestore
node_ordershook -->|"uses"| node_firebase
node_ordershook -->|"subscribes to"| node_firestore
node_poscart -.->|"supports"| node_staffpos
node_shop -.->|"uses"| node_productdata
node_functions -->|"exports"| node_functionauth
node_functions -->|"exports"| node_functionorders
node_functions -->|"exports"| node_functionpayments
node_functions -->|"exports"| node_functionreports
node_webhook -->|"updates orders"| node_firestore

click node_app "https://github.com/chana758/skincare_firebase/blob/main/src/App.jsx"
click node_shop "https://github.com/chana758/skincare_firebase/tree/main/src/pages/users"
click node_checkout "https://github.com/chana758/skincare_firebase/blob/main/src/pages/users/Checkout.jsx"
click node_auth "https://github.com/chana758/skincare_firebase/blob/main/src/context/AuthContext.jsx"
click node_cart "https://github.com/chana758/skincare_firebase/blob/main/src/context/CartContext.jsx"
click node_productdata "https://github.com/chana758/skincare_firebase/blob/main/src/data/products.js"
click node_login "https://github.com/chana758/skincare_firebase/blob/main/src/pages/auth/Login.jsx"
click node_staffpos "https://github.com/chana758/skincare_firebase/tree/main/src/pages/staff"
click node_poscart "https://github.com/chana758/skincare_firebase/blob/main/src/components/pos/POSCart.jsx"
click node_adminconsole "https://github.com/chana758/skincare_firebase/tree/main/src/pages/admin"
click node_functions "https://github.com/chana758/skincare_firebase/blob/main/functions/index.js"
click node_functionauth "https://github.com/chana758/skincare_firebase/tree/main/functions/src/auth"
click node_functionorders "https://github.com/chana758/skincare_firebase/tree/main/functions/src/orders"
click node_functionpayments "https://github.com/chana758/skincare_firebase/tree/main/functions/src/payments"
click node_webhook "https://github.com/chana758/skincare_firebase/blob/main/functions/src/payments/verifyPaymentWebhook.js"
click node_functionreports "https://github.com/chana758/skincare_firebase/blob/main/functions/src/reports/dailySalesSummary.js"
click node_paymentservice "https://github.com/chana758/skincare_firebase/blob/main/src/services/paymentService.js"
click node_notifications "https://github.com/chana758/skincare_firebase/blob/main/src/services/notificationService.js"
click node_ordershook "https://github.com/chana758/skincare_firebase/blob/main/src/hooks/useOrders.js"
click node_firebase "https://github.com/chana758/skincare_firebase/blob/main/src/firebase/config.js"

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_app,node_shop,node_checkout,node_auth,node_cart,node_productdata,node_login toneBlue
class node_staffpos,node_poscart,node_adminconsole,node_functions,node_functionauth,node_functionorders,node_functionpayments,node_webhook,node_functionreports toneAmber
class node_paymentservice,node_notifications,node_ordershook toneMint
class node_firebase,node_firestore toneRose
class node_customer,node_staff,node_admin,node_bakong toneIndigo
```

## Components

### Storefront

- [Route application](https://github.com/chana758/skincare_firebase/blob/main/src/App.jsx): `src/App.jsx`
- [Storefront pages](https://github.com/chana758/skincare_firebase/tree/main/src/pages/users): `src/pages/users`
- [Checkout](https://github.com/chana758/skincare_firebase/blob/main/src/pages/users/Checkout.jsx): `src/pages/users/Checkout.jsx`
- [Account state](https://github.com/chana758/skincare_firebase/blob/main/src/context/AuthContext.jsx): `src/context/AuthContext.jsx`
- [Shopping cart](https://github.com/chana758/skincare_firebase/blob/main/src/context/CartContext.jsx): `src/context/CartContext.jsx`
- [Product data](https://github.com/chana758/skincare_firebase/blob/main/src/data/products.js): `src/data/products.js`
- [Login](https://github.com/chana758/skincare_firebase/blob/main/src/pages/auth/Login.jsx): `src/pages/auth/Login.jsx`

### Staff and admin

- [Staff POS](https://github.com/chana758/skincare_firebase/tree/main/src/pages/staff): `src/pages/staff`
- [POS cart](https://github.com/chana758/skincare_firebase/blob/main/src/components/pos/POSCart.jsx): `src/components/pos/POSCart.jsx`
- [Admin console](https://github.com/chana758/skincare_firebase/tree/main/src/pages/admin): `src/pages/admin`
- [Cloud Functions exports](https://github.com/chana758/skincare_firebase/blob/main/functions/index.js): `functions/index.js`
- [Staff account actions](https://github.com/chana758/skincare_firebase/tree/main/functions/src/auth): `functions/src/auth`
- [Order actions](https://github.com/chana758/skincare_firebase/tree/main/functions/src/orders): `functions/src/orders`
- [Payment functions](https://github.com/chana758/skincare_firebase/tree/main/functions/src/payments): `functions/src/payments`
- [Payment webhook](https://github.com/chana758/skincare_firebase/blob/main/functions/src/payments/verifyPaymentWebhook.js): `functions/src/payments/verifyPaymentWebhook.js`
- [Sales summary](https://github.com/chana758/skincare_firebase/blob/main/functions/src/reports/dailySalesSummary.js): `functions/src/reports/dailySalesSummary.js`

### Application services

- [Order and payment service](https://github.com/chana758/skincare_firebase/blob/main/src/services/paymentService.js): `src/services/paymentService.js`
- [Notification service](https://github.com/chana758/skincare_firebase/blob/main/src/services/notificationService.js): `src/services/notificationService.js`
- [Live orders hook](https://github.com/chana758/skincare_firebase/blob/main/src/hooks/useOrders.js): `src/hooks/useOrders.js`

### Firebase backend

- [Firebase setup](https://github.com/chana758/skincare_firebase/blob/main/src/firebase/config.js): `src/firebase/config.js`
- **Firestore**

### Other components

- **Customer**
- **Staff**
- **Administrator**
- **Bakong KHQR library**

## Connections

- Customer → Route application: uses
- Staff → Route application: uses
- Administrator → Route application: uses
- Route application → Storefront pages: routes to (evidence: `src/App.jsx`)
- Route application → Checkout: routes to (evidence: `src/App.jsx`)
- Route application → Login: routes to (evidence: `src/App.jsx`)
- Route application → Staff POS: routes to (evidence: `src/App.jsx`)
- Route application → Admin console: routes to (evidence: `src/App.jsx`)
- Route application → Account state: provides (evidence: `src/main.jsx`)
- Login → Account state: uses (evidence: `src/pages/auth/Login.jsx`)
- Account state → Firebase setup: uses (evidence: `src/context/AuthContext.jsx`)
- Shopping cart → Firebase setup: reads and writes (evidence: `src/context/CartContext.jsx`)
- Checkout → Shopping cart: uses (evidence: `src/pages/users/Checkout.jsx`)
- Checkout → Order and payment service: creates order and QR (evidence: `src/pages/users/Checkout.jsx`)
- Checkout → Notification service: creates notification (evidence: `src/pages/users/Checkout.jsx`)
- Order and payment service → Firebase setup: uses (evidence: `src/services/paymentService.js`)
- Order and payment service → Firestore: reads and writes (evidence: `src/services/paymentService.js`)
- Order and payment service → Bakong KHQR library: generates QR with (evidence: `src/services/paymentService.js`)
- Notification service → Firebase setup: uses (evidence: `src/services/notificationService.js`)
- Notification service → Firestore: reads and writes (evidence: `src/services/notificationService.js`)
- Live orders hook → Firebase setup: uses (evidence: `src/hooks/useOrders.js`)
- Live orders hook → Firestore: subscribes to (evidence: `src/hooks/useOrders.js`)
- POS cart → Staff POS: supports
- Storefront pages → Product data: uses
- Cloud Functions exports → Staff account actions: exports (evidence: `functions/index.js`)
- Cloud Functions exports → Order actions: exports (evidence: `functions/index.js`)
- Cloud Functions exports → Payment functions: exports (evidence: `functions/index.js`)
- Cloud Functions exports → Sales summary: exports (evidence: `functions/index.js`)
- Payment webhook → Firestore: updates orders (evidence: `functions/src/payments/verifyPaymentWebhook.js`)
