# youngoat911/inventory architecture

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

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

## Overview

Gymkhana Inventory is a web-based equipment inventory and borrowing system. Users authenticate in the React client, navigate operational pages, and send requests through a shared API client to protected REST routes; domain modules implement inventory, loans, transfers, and related workflows. The README also documents purchasing, maintenance, disposal, verification, reporting, audit, notifications, and alerts. The graph uses documented route and import relationships where available; links among unsampled domain internals are omitted rather than inferred.

Main entry points: [`src/routes/api.routes.js`](https://github.com/youngoat911/inventory/blob/main/src/routes/api.routes.js) (API route registry), [`frontend/src/App.jsx`](https://github.com/youngoat911/inventory/blob/main/frontend/src/App.jsx) (React application), [`frontend/src/api/client.js`](https://github.com/youngoat911/inventory/blob/main/frontend/src/api/client.js) (API client), [`src/app.js`](https://github.com/youngoat911/inventory/blob/main/src/app.js) (Express application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_webapp["React application<br/>[App.jsx]"]
  node_authcontext["Session context<br/>[AuthContext.jsx]"]
  node_apiclient["API client<br/>[client.js]"]
  node_assetspage["Asset catalog<br/>[Assets.jsx]"]
  node_catalogpage["Catalog views<br/>[Catalog.jsx]"]
  node_issuespage["Loan workflow<br/>[Issues.jsx]"]
  node_skeleton["Loading skeletons<br/>[Skeleton.jsx]"]
  node_notificationcontext["Notification context"]
  node_toastcontext["Toast context<br/>[ToastContext.jsx]"]
end

subgraph group_server["API runtime"]
  node_apiapp["Express application<br/>[app.js]"]
  node_apirouter["API route registry<br/>[api.routes.js]"]
  node_database[("PostgreSQL<br/>[pool.js]")]
  node_logger["Structured logging<br/>[logger.js]"]
end

subgraph group_identity["Identity and access"]
  node_authcontroller["Authentication<br/>[auth.controller.js]"]
  node_tokenservice["PASETO tokens<br/>[paseto.util.js]"]
  node_authorization["Role authorization<br/>[authorize.js]"]
  node_userrepo["User records"]
  node_rolesrepo["Role assignments"]
end

subgraph group_inventory["Inventory workflows"]
  node_assets["Asset management"]
  node_loans["Checkout and returns"]
  node_blocks["Borrower restrictions"]
  node_transfers["Custody transfers"]
  node_purchases["Purchasing and vendors"]
end

subgraph group_operations["Operations and insight"]
  node_operations["Maintenance and disposal"]
  node_verification["Inventory verification"]
  node_alerts["Threshold and overdue alerts"]
  node_reports["Reports and analytics"]
  node_audit["Audit log"]
  node_notifications["Notifications and realtime"]
end

node_user(("Inventory user"))

node_user -->|"uses"| node_webapp
node_webapp -->|"checks session"| node_authcontext
node_webapp -->|"renders loading"| node_skeleton
node_webapp -->|"routes to"| node_assetspage
node_webapp -->|"routes to"| node_catalogpage
node_webapp -->|"routes to"| node_issuespage
node_authcontext -->|"calls auth API"| node_apiclient
node_assetspage -->|"requests data"| node_apiclient
node_catalogpage -->|"requests data"| node_apiclient
node_issuespage -->|"requests data"| node_apiclient
node_user -->|"receives alerts"| node_apiclient
node_apiclient -->|"sends HTTP requests"| node_apiapp
node_apiapp -->|"mounts API"| node_apirouter
node_apirouter -->|"mounts auth routes"| node_authcontroller
node_apirouter -->|"mounts asset routes"| node_assets
node_apirouter -->|"mounts issue routes"| node_loans
node_apirouter -->|"mounts block routes"| node_blocks
node_apirouter -->|"mounts transfer routes"| node_transfers
node_apirouter -->|"mounts purchase routes"| node_purchases
node_apirouter -->|"mounts alert routes"| node_alerts
node_apirouter -->|"mounts report routes"| node_reports
node_apirouter -->|"mounts domain routes"| node_operations
node_apirouter -->|"mounts verification routes"| node_verification
node_apirouter -->|"mounts audit routes"| node_audit
node_apirouter -->|"mounts notification routes"| node_notifications
node_authcontroller -->|"generates tokens"| node_tokenservice
node_authcontroller -->|"loads roles"| node_rolesrepo
node_authcontroller -->|"persists credentials"| node_database
node_authorization -->|"checks scoped access"| node_database
node_notifications -->|"authenticates user"| node_userrepo
node_notifications -->|"loads roles"| node_rolesrepo
node_apiapp -->|"checks health"| node_database
node_apiapp -->|"logs errors"| node_logger

click node_webapp "https://github.com/youngoat911/inventory/blob/main/frontend/src/App.jsx"
click node_authcontext "https://github.com/youngoat911/inventory/blob/main/frontend/src/auth/AuthContext.jsx"
click node_apiclient "https://github.com/youngoat911/inventory/blob/main/frontend/src/api/client.js"
click node_assetspage "https://github.com/youngoat911/inventory/blob/main/frontend/src/pages/Assets.jsx"
click node_catalogpage "https://github.com/youngoat911/inventory/blob/main/frontend/src/pages/Catalog.jsx"
click node_issuespage "https://github.com/youngoat911/inventory/blob/main/frontend/src/pages/Issues.jsx"
click node_skeleton "https://github.com/youngoat911/inventory/blob/main/frontend/src/components/Skeleton.jsx"
click node_notificationcontext "https://github.com/youngoat911/inventory/blob/main/frontend/src/context/NotificationContext.jsx"
click node_toastcontext "https://github.com/youngoat911/inventory/blob/main/frontend/src/context/ToastContext.jsx"
click node_apiapp "https://github.com/youngoat911/inventory/blob/main/src/app.js"
click node_apirouter "https://github.com/youngoat911/inventory/blob/main/src/routes/api.routes.js"
click node_database "https://github.com/youngoat911/inventory/blob/main/src/db/pool.js"
click node_authcontroller "https://github.com/youngoat911/inventory/blob/main/src/modules/auth/auth.controller.js"
click node_tokenservice "https://github.com/youngoat911/inventory/blob/main/src/utils/paseto.util.js"
click node_authorization "https://github.com/youngoat911/inventory/blob/main/src/middleware/authorize.js"
click node_userrepo "https://github.com/youngoat911/inventory/blob/main/src/modules/users/users.repository.js"
click node_rolesrepo "https://github.com/youngoat911/inventory/blob/main/src/modules/roles/roles.repository.js"
click node_assets "https://github.com/youngoat911/inventory/tree/main/src/modules"
click node_loans "https://github.com/youngoat911/inventory/blob/main/src/modules/issues/issues.controller.js"
click node_blocks "https://github.com/youngoat911/inventory/blob/main/src/modules/borrower-blocks/borrower-blocks.controller.js"
click node_transfers "https://github.com/youngoat911/inventory/blob/main/src/modules/transfers/transfers.controller.js"
click node_purchases "https://github.com/youngoat911/inventory/blob/main/src/modules/purchases/purchases.controller.js"
click node_operations "https://github.com/youngoat911/inventory/tree/main/src/modules"
click node_verification "https://github.com/youngoat911/inventory/tree/main/src/modules/verifications"
click node_alerts "https://github.com/youngoat911/inventory/blob/main/src/modules/alerts/alerts.controller.js"
click node_reports "https://github.com/youngoat911/inventory/blob/main/src/modules/reports/reports.controller.js"
click node_audit "https://github.com/youngoat911/inventory/tree/main/src/modules/audit-log"
click node_notifications "https://github.com/youngoat911/inventory/blob/main/src/services/websocket.service.js"
click node_logger "https://github.com/youngoat911/inventory/blob/main/src/utils/logger.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_webapp,node_authcontext,node_apiclient,node_assetspage,node_catalogpage,node_issuespage,node_skeleton,node_notificationcontext,node_toastcontext,node_user toneBlue
class node_apiapp,node_apirouter,node_database,node_logger toneAmber
class node_authcontroller,node_tokenservice,node_authorization,node_userrepo,node_rolesrepo toneMint
class node_assets,node_loans,node_blocks,node_transfers,node_purchases toneRose
class node_operations,node_verification,node_alerts,node_reports,node_audit,node_notifications toneIndigo
```

## Components

### Web client

- [React application](https://github.com/youngoat911/inventory/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Session context](https://github.com/youngoat911/inventory/blob/main/frontend/src/auth/AuthContext.jsx): `frontend/src/auth/AuthContext.jsx`
- [API client](https://github.com/youngoat911/inventory/blob/main/frontend/src/api/client.js): `frontend/src/api/client.js`
- [Asset catalog](https://github.com/youngoat911/inventory/blob/main/frontend/src/pages/Assets.jsx): `frontend/src/pages/Assets.jsx`
- [Catalog views](https://github.com/youngoat911/inventory/blob/main/frontend/src/pages/Catalog.jsx): `frontend/src/pages/Catalog.jsx`
- [Loan workflow](https://github.com/youngoat911/inventory/blob/main/frontend/src/pages/Issues.jsx): `frontend/src/pages/Issues.jsx`
- [Loading skeletons](https://github.com/youngoat911/inventory/blob/main/frontend/src/components/Skeleton.jsx): `frontend/src/components/Skeleton.jsx`
- [Notification context](https://github.com/youngoat911/inventory/blob/main/frontend/src/context/NotificationContext.jsx): `frontend/src/context/NotificationContext.jsx`
- [Toast context](https://github.com/youngoat911/inventory/blob/main/frontend/src/context/ToastContext.jsx): `frontend/src/context/ToastContext.jsx`

### API runtime

- [Express application](https://github.com/youngoat911/inventory/blob/main/src/app.js): `src/app.js`
- [API route registry](https://github.com/youngoat911/inventory/blob/main/src/routes/api.routes.js): `src/routes/api.routes.js`
- [PostgreSQL](https://github.com/youngoat911/inventory/blob/main/src/db/pool.js): `src/db/pool.js`
- [Structured logging](https://github.com/youngoat911/inventory/blob/main/src/utils/logger.js): `src/utils/logger.js`

### Identity and access

- [Authentication](https://github.com/youngoat911/inventory/blob/main/src/modules/auth/auth.controller.js): `src/modules/auth/auth.controller.js`
- [PASETO tokens](https://github.com/youngoat911/inventory/blob/main/src/utils/paseto.util.js): `src/utils/paseto.util.js`
- [Role authorization](https://github.com/youngoat911/inventory/blob/main/src/middleware/authorize.js): `src/middleware/authorize.js`
- [User records](https://github.com/youngoat911/inventory/blob/main/src/modules/users/users.repository.js): `src/modules/users/users.repository.js`
- [Role assignments](https://github.com/youngoat911/inventory/blob/main/src/modules/roles/roles.repository.js): `src/modules/roles/roles.repository.js`

### Inventory workflows

- [Asset management](https://github.com/youngoat911/inventory/tree/main/src/modules): `src/modules`
- [Checkout and returns](https://github.com/youngoat911/inventory/blob/main/src/modules/issues/issues.controller.js): `src/modules/issues/issues.controller.js`
- [Borrower restrictions](https://github.com/youngoat911/inventory/blob/main/src/modules/borrower-blocks/borrower-blocks.controller.js): `src/modules/borrower-blocks/borrower-blocks.controller.js`
- [Custody transfers](https://github.com/youngoat911/inventory/blob/main/src/modules/transfers/transfers.controller.js): `src/modules/transfers/transfers.controller.js`
- [Purchasing and vendors](https://github.com/youngoat911/inventory/blob/main/src/modules/purchases/purchases.controller.js): `src/modules/purchases/purchases.controller.js`

### Operations and insight

- [Maintenance and disposal](https://github.com/youngoat911/inventory/tree/main/src/modules): `src/modules`
- [Inventory verification](https://github.com/youngoat911/inventory/tree/main/src/modules/verifications): `src/modules/verifications`
- [Threshold and overdue alerts](https://github.com/youngoat911/inventory/blob/main/src/modules/alerts/alerts.controller.js): `src/modules/alerts/alerts.controller.js`
- [Reports and analytics](https://github.com/youngoat911/inventory/blob/main/src/modules/reports/reports.controller.js): `src/modules/reports/reports.controller.js`
- [Audit log](https://github.com/youngoat911/inventory/tree/main/src/modules/audit-log): `src/modules/audit-log`
- [Notifications and realtime](https://github.com/youngoat911/inventory/blob/main/src/services/websocket.service.js): `src/services/websocket.service.js`

### Other components

- **Inventory user**

## Connections

- Inventory user → React application: uses
- React application → Session context: checks session (evidence: `frontend/src/App.jsx`)
- React application → Loading skeletons: renders loading (evidence: `frontend/src/App.jsx`)
- React application → Asset catalog: routes to (evidence: `frontend/src/App.jsx`)
- React application → Catalog views: routes to (evidence: `frontend/src/App.jsx`)
- React application → Loan workflow: routes to (evidence: `frontend/src/App.jsx`)
- Session context → API client: calls auth API (evidence: `frontend/src/auth/AuthContext.jsx`)
- Asset catalog → API client: requests data
- Catalog views → API client: requests data
- Loan workflow → API client: requests data
- Inventory user → API client: receives alerts
- API client → Express application: sends HTTP requests
- Express application → API route registry: mounts API (evidence: `src/app.js`)
- API route registry → Authentication: mounts auth routes (evidence: `src/routes/api.routes.js`)
- API route registry → Asset management: mounts asset routes (evidence: `src/routes/api.routes.js`)
- API route registry → Checkout and returns: mounts issue routes (evidence: `src/routes/api.routes.js`)
- API route registry → Borrower restrictions: mounts block routes (evidence: `src/routes/api.routes.js`)
- API route registry → Custody transfers: mounts transfer routes (evidence: `src/routes/api.routes.js`)
- API route registry → Purchasing and vendors: mounts purchase routes (evidence: `src/routes/api.routes.js`)
- API route registry → Threshold and overdue alerts: mounts alert routes (evidence: `src/routes/api.routes.js`)
- API route registry → Reports and analytics: mounts report routes (evidence: `src/routes/api.routes.js`)
- API route registry → Maintenance and disposal: mounts domain routes (evidence: `src/routes/api.routes.js`)
- API route registry → Inventory verification: mounts verification routes (evidence: `src/routes/api.routes.js`)
- API route registry → Audit log: mounts audit routes (evidence: `src/routes/api.routes.js`)
- API route registry → Notifications and realtime: mounts notification routes (evidence: `src/routes/api.routes.js`)
- Authentication → PASETO tokens: generates tokens (evidence: `src/modules/auth/auth.controller.js`)
- Authentication → Role assignments: loads roles (evidence: `src/modules/auth/auth.controller.js`)
- Authentication → PostgreSQL: persists credentials (evidence: `src/modules/auth/auth.controller.js`)
- Role authorization → PostgreSQL: checks scoped access (evidence: `src/middleware/authorize.js`)
- Notifications and realtime → User records: authenticates user (evidence: `src/services/websocket.service.js`)
- Notifications and realtime → Role assignments: loads roles (evidence: `src/services/websocket.service.js`)
- Express application → PostgreSQL: checks health (evidence: `src/app.js`)
- Express application → Structured logging: logs errors
