# joshleejhankimgbunao-ops/inventory architecture

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

- Interactive diagram: https://gitdiagram.com/joshleejhankimgbunao-ops/inventory
- Repository: https://github.com/joshleejhankimgbunao-ops/inventory

## Overview

Inventory System is a browser-based inventory and point-of-sale product backed by an Express API and MongoDB. Users sign in, manage catalog and stock, complete sales or credit transactions, and review history, reports, partners, and special orders. The frontend contexts and API clients mediate page workflows; backend routes dispatch requests to domain controllers, which use models and services. The README establishes the overall stack, while sampled source confirms selected auth, sale, credit, logging, and realtime relationships; other capability links are documented but not traced through unsampled handlers.

Main entry points: [`src/services/inventoryApi.js`](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/services/inventoryApi.js) (Inventory API client), [`server/src/controllers/creditTransactionController.js`](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/controllers/creditTransactionController.js) (Credit workflow), [`server/src/controllers/saleController.js`](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/controllers/saleController.js) (Sales workflow), [`server/src/app.js`](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/app.js) (Express application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_app["Application routing<br/>[App.jsx]"]
  node_authctx["Session context<br/>[AuthContext.jsx]"]
  node_invctx["Inventory context"]
  node_pos["Point of sale<br/>[PointOfSale.jsx]"]
  node_catalogui["Catalog management<br/>[ProductList.jsx]"]
  node_dashboard["Dashboard and reports<br/>[Dashboard.jsx]"]
  node_history["Sales history<br/>[History.jsx]"]
  node_ordersui["Special orders<br/>[SpecialOrders.jsx]"]
  node_creditui["Credit transactions"]
  node_settingsui["Settings and users<br/>[Settings.jsx]"]
  node_apiclient["HTTP API client<br/>[apiClient.js]"]
  node_inventoryapi["Inventory API client<br/>[inventoryApi.js]"]
  node_realtimeclient["Realtime client<br/>[realtimeClient.js]"]
end

subgraph group_api["API and identity"]
  node_express["Express application<br/>[app.js]"]
  node_authroutes["Auth routes and guards<br/>[authRoutes.js]"]
  node_authcontroller["Authentication<br/>[authController.js]"]
  node_userdb[("User records<br/>[User.js]")]
end

subgraph group_commerce["Commerce operations"]
  node_salecontroller["Sales workflow<br/>[saleController.js]"]
  node_saleroutes["Sales routes<br/>[saleRoutes.js]"]
  node_creditcontroller["Credit workflow"]
  node_saledb[("Sales records<br/>[Sale.js]")]
  node_creditdb[("Credit records")]
  node_productcontroller["Product and category workflows"]
  node_specialorders["Special order workflow"]
  node_partners["Partner management"]
end

subgraph group_platform["Shared services"]
  node_settings["Settings workflow"]
  node_logs["Audit and inventory logs<br/>[logService.js]"]
  node_realtime["Realtime event service<br/>[realtimeService.js]"]
  node_storage["Document object storage"]
end

node_user(("Staff user"))
node_mongo[("MongoDB")]
node_r2[("Cloudflare R2")]

node_user -->|"uses"| node_app
node_app -->|"hosts"| node_authctx
node_app -->|"routes to"| node_dashboard
node_pos -->|"reads state"| node_invctx
node_catalogui -->|"uses state"| node_invctx
node_dashboard -.->|"uses state"| node_invctx
node_invctx -->|"loads data"| node_inventoryapi
node_authctx -->|"requests"| node_apiclient
node_inventoryapi -->|"uses"| node_apiclient
node_apiclient -.->|"HTTP requests"| node_express
node_express -->|"mounts"| node_authroutes
node_express -->|"mounts"| node_saleroutes
node_saleroutes -->|"dispatches"| node_salecontroller
node_authroutes -->|"dispatches"| node_authcontroller
node_authcontroller -->|"reads and writes"| node_userdb
node_salecontroller -->|"reads and writes"| node_saledb
node_creditcontroller -->|"reads and writes"| node_creditdb
node_creditcontroller -->|"looks up sales"| node_saledb
node_salecontroller -->|"writes activity"| node_logs
node_creditcontroller -->|"writes activity"| node_logs
node_authcontroller -->|"writes activity"| node_logs
node_salecontroller -->|"publishes updates"| node_realtime
node_creditcontroller -->|"publishes updates"| node_realtime
node_realtimeclient -.->|"requests stream"| node_express
node_salecontroller -.->|"stores documents"| node_storage
node_creditcontroller -->|"loads proofs"| node_storage
node_storage -->|"object operations"| node_r2
node_productcontroller -.->|"catalog data"| node_mongo
node_specialorders -.->|"order data"| node_mongo
node_partners -.->|"partner data"| node_mongo
node_settings -.->|"settings data"| node_mongo
node_history -.->|"requests history"| node_inventoryapi
node_ordersui -.->|"requests orders"| node_inventoryapi
node_creditui -.->|"requests credit"| node_inventoryapi
node_settingsui -.->|"requests settings"| node_inventoryapi

click node_app "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/App.jsx"
click node_authctx "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/context/AuthContext.jsx"
click node_invctx "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/context/InventoryContext.jsx"
click node_pos "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/pages/PointOfSale.jsx"
click node_catalogui "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/pages/ProductList.jsx"
click node_dashboard "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/pages/Dashboard.jsx"
click node_history "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/pages/History.jsx"
click node_ordersui "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/pages/SpecialOrders.jsx"
click node_creditui "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/pages/CreditTransactions.jsx"
click node_settingsui "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/pages/Settings.jsx"
click node_apiclient "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/services/apiClient.js"
click node_inventoryapi "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/services/inventoryApi.js"
click node_realtimeclient "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/services/realtimeClient.js"
click node_express "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/app.js"
click node_authroutes "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/routes/authRoutes.js"
click node_authcontroller "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/controllers/authController.js"
click node_userdb "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/models/User.js"
click node_salecontroller "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/controllers/saleController.js"
click node_saleroutes "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/routes/saleRoutes.js"
click node_creditcontroller "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/controllers/creditTransactionController.js"
click node_saledb "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/models/Sale.js"
click node_creditdb "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/models/CreditTransaction.js"
click node_productcontroller "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/controllers/productController.js"
click node_specialorders "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/controllers/specialOrderController.js"
click node_partners "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/controllers/partnerController.js"
click node_settings "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/controllers/settingController.js"
click node_logs "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/services/logService.js"
click node_realtime "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/services/realtimeService.js"
click node_storage "https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/services/r2StorageService.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_authctx,node_invctx,node_pos,node_catalogui,node_dashboard,node_history,node_ordersui,node_creditui,node_settingsui,node_apiclient,node_inventoryapi,node_realtimeclient,node_user toneBlue
class node_express,node_authroutes,node_authcontroller,node_userdb,node_mongo,node_r2 toneAmber
class node_salecontroller,node_saleroutes,node_creditcontroller,node_saledb,node_creditdb,node_productcontroller,node_specialorders,node_partners toneMint
class node_settings,node_logs,node_realtime,node_storage toneRose
```

## Components

### Web application

- [Application routing](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/App.jsx): `src/App.jsx`
- [Session context](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/context/AuthContext.jsx): `src/context/AuthContext.jsx`
- [Inventory context](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/context/InventoryContext.jsx): `src/context/InventoryContext.jsx`
- [Point of sale](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/pages/PointOfSale.jsx): `src/pages/PointOfSale.jsx`
- [Catalog management](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/pages/ProductList.jsx): `src/pages/ProductList.jsx`
- [Dashboard and reports](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/pages/Dashboard.jsx): `src/pages/Dashboard.jsx`
- [Sales history](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/pages/History.jsx): `src/pages/History.jsx`
- [Special orders](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/pages/SpecialOrders.jsx): `src/pages/SpecialOrders.jsx`
- [Credit transactions](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/pages/CreditTransactions.jsx): `src/pages/CreditTransactions.jsx`
- [Settings and users](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/pages/Settings.jsx): `src/pages/Settings.jsx`
- [HTTP API client](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/services/apiClient.js): `src/services/apiClient.js`
- [Inventory API client](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/services/inventoryApi.js): `src/services/inventoryApi.js`
- [Realtime client](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/src/services/realtimeClient.js): `src/services/realtimeClient.js`

### API and identity

- [Express application](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/app.js): `server/src/app.js`
- [Auth routes and guards](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/routes/authRoutes.js): `server/src/routes/authRoutes.js`
- [Authentication](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/controllers/authController.js): `server/src/controllers/authController.js`
- [User records](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/models/User.js): `server/src/models/User.js`

### Commerce operations

- [Sales workflow](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/controllers/saleController.js): `server/src/controllers/saleController.js`
- [Sales routes](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/routes/saleRoutes.js): `server/src/routes/saleRoutes.js`
- [Credit workflow](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/controllers/creditTransactionController.js): `server/src/controllers/creditTransactionController.js`
- [Sales records](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/models/Sale.js): `server/src/models/Sale.js`
- [Credit records](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/models/CreditTransaction.js): `server/src/models/CreditTransaction.js`
- [Product and category workflows](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/controllers/productController.js): `server/src/controllers/productController.js`
- [Special order workflow](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/controllers/specialOrderController.js): `server/src/controllers/specialOrderController.js`
- [Partner management](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/controllers/partnerController.js): `server/src/controllers/partnerController.js`

### Shared services

- [Settings workflow](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/controllers/settingController.js): `server/src/controllers/settingController.js`
- [Audit and inventory logs](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/services/logService.js): `server/src/services/logService.js`
- [Realtime event service](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/services/realtimeService.js): `server/src/services/realtimeService.js`
- [Document object storage](https://github.com/joshleejhankimgbunao-ops/inventory/blob/main/server/src/services/r2StorageService.js): `server/src/services/r2StorageService.js`

### Other components

- **Staff user**
- **MongoDB**
- **Cloudflare R2**

## Connections

- Staff user → Application routing: uses (evidence: `README.md`)
- Application routing → Session context: hosts (evidence: `src/App.jsx`)
- Application routing → Dashboard and reports: routes to (evidence: `src/App.jsx`)
- Point of sale → Inventory context: reads state (evidence: `src/pages/PointOfSale.jsx`)
- Catalog management → Inventory context: uses state
- Dashboard and reports → Inventory context: uses state
- Inventory context → Inventory API client: loads data (evidence: `src/context/InventoryContext.jsx`)
- Session context → HTTP API client: requests (evidence: `src/context/AuthContext.jsx`)
- Inventory API client → HTTP API client: uses (evidence: `src/services/inventoryApi.js`)
- HTTP API client → Express application: HTTP requests (evidence: `README.md`)
- Express application → Auth routes and guards: mounts (evidence: `server/src/app.js`)
- Express application → Sales routes: mounts (evidence: `server/src/app.js`)
- Sales routes → Sales workflow: dispatches (evidence: `server/src/routes/saleRoutes.js`)
- Auth routes and guards → Authentication: dispatches (evidence: `server/src/routes/authRoutes.js`)
- Authentication → User records: reads and writes (evidence: `server/src/controllers/authController.js`)
- Sales workflow → Sales records: reads and writes (evidence: `server/src/controllers/saleController.js`)
- Credit workflow → Credit records: reads and writes (evidence: `server/src/controllers/creditTransactionController.js`)
- Credit workflow → Sales records: looks up sales (evidence: `server/src/controllers/creditTransactionController.js`)
- Sales workflow → Audit and inventory logs: writes activity (evidence: `server/src/controllers/saleController.js`)
- Credit workflow → Audit and inventory logs: writes activity (evidence: `server/src/controllers/creditTransactionController.js`)
- Authentication → Audit and inventory logs: writes activity (evidence: `server/src/controllers/authController.js`)
- Sales workflow → Realtime event service: publishes updates (evidence: `server/src/controllers/saleController.js`)
- Credit workflow → Realtime event service: publishes updates (evidence: `server/src/controllers/creditTransactionController.js`)
- Realtime client → Express application: requests stream
- Sales workflow → Document object storage: stores documents (evidence: `server/src/controllers/saleController.js`)
- Credit workflow → Document object storage: loads proofs (evidence: `server/src/controllers/creditTransactionController.js`)
- Document object storage → Cloudflare R2: object operations (evidence: `server/src/services/r2StorageService.js`)
- Product and category workflows → MongoDB: catalog data
- Special order workflow → MongoDB: order data
- Partner management → MongoDB: partner data
- Settings workflow → MongoDB: settings data
- Sales history → Inventory API client: requests history
- Special orders → Inventory API client: requests orders
- Credit transactions → Inventory API client: requests credit
- Settings and users → Inventory API client: requests settings (evidence: `src/pages/Settings.jsx`)
