# leizxc/siomai architecture

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

- Interactive diagram: https://gitdiagram.com/leizxc/siomai
- Repository: https://github.com/leizxc/siomai

## Overview

This is a browser-based business management app with employee sales/POS, inventory and product assignment, attendance, and owner/admin operations such as payroll, expenses, reports, and notifications. The employee workflow includes shift-state checks and POS order recording; the sampled code also shows offline user/product storage and synchronization. Five groups capture the product’s main domains. Several feature modules are represented by their names and paths, but their internal calls were not sampled, so relationships are shown only where excerpts document them.

Main entry points: [`BackEnd/public/js/empoleyee.js`](https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/empoleyee.js) (Employee POS), [`BackEnd/public/js/IndexDB.js`](https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/IndexDB.js) (Offline data), [`BackEnd/public/js/attendanceAccess.js`](https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/attendanceAccess.js) (Shift access), [`BackEnd/public/js/adminaddproduct.js`](https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/adminaddproduct.js) (Product assignment)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sales["Employee sales"]
  node_employee["Employee POS<br/>[empoleyee.js]"]
  node_orders[("Sales orders<br/>[empoleyee.js]")]
  node_income["Income cart<br/>[incomeCart.js]"]
  node_sales_view["Sales views<br/>[sales.js]"]
end

subgraph group_inventory["Inventory"]
  node_inventory_admin["Inventory admin<br/>[adminBE.js]"]
  node_product_assign["Product assignment<br/>[adminaddproduct.js]"]
  node_product_menu["Product menu<br/>[productmenu.js]"]
  node_stock["Stock tracking<br/>[stock.js]"]
end

subgraph group_workforce["Workforce"]
  node_attendance["Attendance<br/>[attendance.js]"]
  node_attendance_access["Shift access"]
  node_attendance_admin["Attendance admin<br/>[attendanceAdmin.js]"]
  node_employee_admin["Employee admin<br/>[adminEmployee.js]"]
  node_payroll["Payroll<br/>[payroll.js]"]
end

subgraph group_management["Owner and admin"]
  node_admin_dashboard["Admin dashboard<br/>[adminDashboard.js]"]
  node_owner_dashboard["Owner dashboard<br/>[ownerDashboard.js]"]
  node_owner_features["Owner features<br/>[ownerFeatures.js]"]
  node_expenses["Expense management<br/>[adminExpenses.js]"]
  node_reports["Reports<br/>[report.js]"]
  node_notifications["Notifications"]
end

subgraph group_platform["App platform"]
  node_indexeddb[("Offline data<br/>[IndexDB.js]")]
  node_app["App startup<br/>[app.js]"]
  node_service_worker["Offline and push worker<br/>[service-worker.js]"]
  node_server["Express auth API<br/>[server.js]"]
end

node_user(("Employee or admin"))
node_firestore[("Firebase Firestore")]
node_firebase_auth["Firebase Auth"]
node_browser_storage[("Browser IndexedDB")]
node_firebase_admin["Firebase Admin"]

node_app -->|"syncs users"| node_indexeddb
node_employee -->|"loads offline products"| node_indexeddb
node_employee -->|"checks shift access"| node_attendance_access
node_employee -->|"records orders"| node_firestore
node_employee -->|"updates stock"| node_firestore
node_indexeddb -->|"syncs users and products"| node_firestore
node_indexeddb -->|"stores offline data"| node_browser_storage
node_inventory_admin -->|"reads inventory"| node_firestore
node_product_assign -->|"assigns products"| node_firestore
node_product_assign -->|"adjusts inventory"| node_firestore
node_product_menu -->|"manages menu data"| node_firestore
node_attendance_access -->|"observes sign-in"| node_firebase_auth
node_attendance_access -->|"watches shift record"| node_firestore
node_user -.->|"requests admin actions"| node_server
node_server -->|"verifies admin token"| node_firebase_admin

click node_employee "https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/empoleyee.js"
click node_orders "https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/empoleyee.js"
click node_income "https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/incomeCart.js"
click node_sales_view "https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/sales.js"
click node_inventory_admin "https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/adminBE.js"
click node_product_assign "https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/adminaddproduct.js"
click node_product_menu "https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/productmenu.js"
click node_stock "https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/stock.js"
click node_attendance "https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/attendance.js"
click node_attendance_access "https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/attendanceAccess.js"
click node_attendance_admin "https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/attendanceAdmin.js"
click node_employee_admin "https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/adminEmployee.js"
click node_payroll "https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/payroll.js"
click node_admin_dashboard "https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/adminDashboard.js"
click node_owner_dashboard "https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/ownerDashboard.js"
click node_owner_features "https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/ownerFeatures.js"
click node_expenses "https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/adminExpenses.js"
click node_reports "https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/report.js"
click node_notifications "https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/adminnotifications.js"
click node_indexeddb "https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/IndexDB.js"
click node_app "https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/app.js"
click node_service_worker "https://github.com/leizxc/siomai/blob/main/BackEnd/public/service-worker.js"
click node_server "https://github.com/leizxc/siomai/blob/main/BackEnd/server.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_employee,node_orders,node_income,node_sales_view toneBlue
class node_inventory_admin,node_product_assign,node_product_menu,node_stock,node_firestore,node_browser_storage toneAmber
class node_attendance,node_attendance_access,node_attendance_admin,node_employee_admin,node_payroll toneMint
class node_admin_dashboard,node_owner_dashboard,node_owner_features,node_expenses,node_reports,node_notifications toneRose
class node_indexeddb,node_app,node_service_worker,node_server,node_user,node_firebase_auth,node_firebase_admin toneIndigo
```

## Components

### Employee sales

- [Employee POS](https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/empoleyee.js): `BackEnd/public/js/empoleyee.js`
- [Sales orders](https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/empoleyee.js): `BackEnd/public/js/empoleyee.js`
- [Income cart](https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/incomeCart.js): `BackEnd/public/js/incomeCart.js`
- [Sales views](https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/sales.js): `BackEnd/public/js/sales.js`

### Inventory

- [Inventory admin](https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/adminBE.js): `BackEnd/public/js/adminBE.js`
- [Product assignment](https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/adminaddproduct.js): `BackEnd/public/js/adminaddproduct.js`
- [Product menu](https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/productmenu.js): `BackEnd/public/js/productmenu.js`
- [Stock tracking](https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/stock.js): `BackEnd/public/js/stock.js`

### Workforce

- [Attendance](https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/attendance.js): `BackEnd/public/js/attendance.js`
- [Shift access](https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/attendanceAccess.js): `BackEnd/public/js/attendanceAccess.js`
- [Attendance admin](https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/attendanceAdmin.js): `BackEnd/public/js/attendanceAdmin.js`
- [Employee admin](https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/adminEmployee.js): `BackEnd/public/js/adminEmployee.js`
- [Payroll](https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/payroll.js): `BackEnd/public/js/payroll.js`

### Owner and admin

- [Admin dashboard](https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/adminDashboard.js): `BackEnd/public/js/adminDashboard.js`
- [Owner dashboard](https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/ownerDashboard.js): `BackEnd/public/js/ownerDashboard.js`
- [Owner features](https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/ownerFeatures.js): `BackEnd/public/js/ownerFeatures.js`
- [Expense management](https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/adminExpenses.js): `BackEnd/public/js/adminExpenses.js`
- [Reports](https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/report.js): `BackEnd/public/js/report.js`
- [Notifications](https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/adminnotifications.js): `BackEnd/public/js/adminnotifications.js`

### App platform

- [Offline data](https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/IndexDB.js): `BackEnd/public/js/IndexDB.js`
- [App startup](https://github.com/leizxc/siomai/blob/main/BackEnd/public/js/app.js): `BackEnd/public/js/app.js`
- [Offline and push worker](https://github.com/leizxc/siomai/blob/main/BackEnd/public/service-worker.js): `BackEnd/public/service-worker.js`
- [Express auth API](https://github.com/leizxc/siomai/blob/main/BackEnd/server.js): `BackEnd/server.js`

### Other components

- **Employee or admin**
- **Firebase Firestore**
- **Firebase Auth**
- **Browser IndexedDB**
- **Firebase Admin**

## Connections

- App startup → Offline data: syncs users (evidence: `BackEnd/public/js/app.js`)
- Employee POS → Offline data: loads offline products (evidence: `BackEnd/public/js/empoleyee.js`)
- Employee POS → Shift access: checks shift access (evidence: `BackEnd/public/js/empoleyee.js`)
- Employee POS → Firebase Firestore: records orders (evidence: `BackEnd/public/js/empoleyee.js`)
- Employee POS → Firebase Firestore: updates stock (evidence: `BackEnd/public/js/empoleyee.js`)
- Offline data → Firebase Firestore: syncs users and products (evidence: `BackEnd/public/js/IndexDB.js`)
- Offline data → Browser IndexedDB: stores offline data (evidence: `BackEnd/public/js/IndexDB.js`)
- Inventory admin → Firebase Firestore: reads inventory (evidence: `BackEnd/public/js/adminBE.js`)
- Product assignment → Firebase Firestore: assigns products (evidence: `BackEnd/public/js/adminaddproduct.js`)
- Product assignment → Firebase Firestore: adjusts inventory (evidence: `BackEnd/public/js/adminaddproduct.js`)
- Product menu → Firebase Firestore: manages menu data (evidence: `BackEnd/public/js/productmenu.js`)
- Shift access → Firebase Auth: observes sign-in (evidence: `BackEnd/public/js/attendanceAccess.js`)
- Shift access → Firebase Firestore: watches shift record (evidence: `BackEnd/public/js/attendanceAccess.js`)
- Employee or admin → Express auth API: requests admin actions
- Express auth API → Firebase Admin: verifies admin token (evidence: `BackEnd/server.js`)
