# wajeehasajid/inventory-management-system architecture

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

- Interactive diagram: https://gitdiagram.com/wajeehasajid/inventory-management-system
- Repository: https://github.com/wajeehasajid/inventory-management-system

## Overview

This is a full-stack product inventory system. Users sign in, manage products and their category/supplier references, record stock movements, and inspect inventory analytics; administrators additionally manage roles, delete protected records, and import CSV data. Static browser pages call an Express API, whose route handlers validate requests and query PostgreSQL. The graph preserves documented UI and API capabilities, including CSV operations and API documentation. Backend route-to-database links are supported by the source index; unsampled frontend wiring is represented only where the README describes it.

Main entry points: [`backend/server.js`](https://github.com/wajeehasajid/inventory-management-system/blob/main/backend/server.js) (Express API), [`frontend/api.js`](https://github.com/wajeehasajid/inventory-management-system/blob/main/frontend/api.js) (Fetch API client), [`backend/db/pool.js`](https://github.com/wajeehasajid/inventory-management-system/blob/main/backend/db/pool.js) (PostgreSQL pool), [`backend/middleware/auth.js`](https://github.com/wajeehasajid/inventory-management-system/blob/main/backend/middleware/auth.js) (Token and roles)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Browser interface"]
  node_product_ui["Product screens<br/>[products.js]"]
  node_category_ui["Category screens<br/>[categories.js]"]
  node_supplier_ui["Supplier screens<br/>[suppliers.js]"]
  node_dashboard_ui["Dashboard screens<br/>[dashboard.js]"]
  node_login_ui["Login screens<br/>[login.js]"]
  node_settings_ui["Account settings<br/>[settings.js]"]
  node_api_client["Fetch API client<br/>[api.js]"]
end

subgraph group_api["API and access"]
  node_server["Express API<br/>[server.js]"]
  node_auth_routes["Authentication<br/>[auth.js]"]
  node_auth_middleware["Token and roles<br/>[auth.js]"]
  node_swagger["API documentation<br/>[swagger.js]"]
end

subgraph group_inventory["Inventory workflows"]
  node_products["Products and CSV<br/>[products.js]"]
  node_categories["Categories<br/>[categories.js]"]
  node_suppliers["Suppliers<br/>[suppliers.js]"]
  node_stock["Stock movements<br/>[products.js]"]
  node_dashboard["Inventory analytics<br/>[dashboard.js]"]
end

subgraph group_data["Persistence and errors"]
  node_pool["PostgreSQL pool<br/>[pool.js]"]
  node_postgres[("Inventory database")]
  node_errors["Error responses<br/>[errorHandler.js]"]
end

node_user(("Inventory user"))

node_user -->|"signs in"| node_login_ui
node_user -->|"manages inventory"| node_product_ui
node_user -->|"manages categories"| node_category_ui
node_user -->|"manages suppliers"| node_supplier_ui
node_user -->|"views analytics"| node_dashboard_ui
node_user -->|"manages account"| node_settings_ui
node_login_ui -.->|"requests API"| node_api_client
node_product_ui -.->|"requests API"| node_api_client
node_category_ui -.->|"requests API"| node_api_client
node_supplier_ui -.->|"requests API"| node_api_client
node_dashboard_ui -.->|"requests API"| node_api_client
node_settings_ui -.->|"requests API"| node_api_client
node_api_client -->|"HTTP requests"| node_server
node_server -->|"mounts routes"| node_auth_routes
node_server -->|"protects routes"| node_auth_middleware
node_server -->|"mounts routes"| node_products
node_server -->|"mounts routes"| node_categories
node_server -->|"mounts routes"| node_suppliers
node_server -->|"mounts routes"| node_dashboard
node_server -->|"serves documentation"| node_swagger
node_server -->|"registers handler"| node_errors
node_auth_routes -->|"queries users"| node_pool
node_auth_routes -->|"guards account routes"| node_auth_middleware
node_products -->|"queries inventory"| node_pool
node_categories -->|"queries categories"| node_pool
node_suppliers -->|"queries suppliers"| node_pool
node_dashboard -->|"queries analytics"| node_pool
node_products -->|"checks admin role"| node_auth_middleware
node_categories -->|"checks admin role"| node_auth_middleware
node_suppliers -->|"checks admin role"| node_auth_middleware
node_stock -->|"records movements"| node_pool
node_pool -->|"reads and writes"| node_postgres
node_products -.->|"forwards failures"| node_errors
node_categories -.->|"forwards failures"| node_errors
node_suppliers -.->|"forwards failures"| node_errors
node_dashboard -.->|"forwards failures"| node_errors

click node_product_ui "https://github.com/wajeehasajid/inventory-management-system/blob/main/frontend/products.js"
click node_category_ui "https://github.com/wajeehasajid/inventory-management-system/blob/main/frontend/categories.js"
click node_supplier_ui "https://github.com/wajeehasajid/inventory-management-system/blob/main/frontend/suppliers.js"
click node_dashboard_ui "https://github.com/wajeehasajid/inventory-management-system/blob/main/frontend/dashboard.js"
click node_login_ui "https://github.com/wajeehasajid/inventory-management-system/blob/main/frontend/login.js"
click node_settings_ui "https://github.com/wajeehasajid/inventory-management-system/blob/main/frontend/settings.js"
click node_api_client "https://github.com/wajeehasajid/inventory-management-system/blob/main/frontend/api.js"
click node_server "https://github.com/wajeehasajid/inventory-management-system/blob/main/backend/server.js"
click node_auth_routes "https://github.com/wajeehasajid/inventory-management-system/blob/main/backend/routes/auth.js"
click node_auth_middleware "https://github.com/wajeehasajid/inventory-management-system/blob/main/backend/middleware/auth.js"
click node_products "https://github.com/wajeehasajid/inventory-management-system/blob/main/backend/routes/products.js"
click node_categories "https://github.com/wajeehasajid/inventory-management-system/blob/main/backend/routes/categories.js"
click node_suppliers "https://github.com/wajeehasajid/inventory-management-system/blob/main/backend/routes/suppliers.js"
click node_stock "https://github.com/wajeehasajid/inventory-management-system/blob/main/backend/routes/products.js"
click node_dashboard "https://github.com/wajeehasajid/inventory-management-system/blob/main/backend/routes/dashboard.js"
click node_swagger "https://github.com/wajeehasajid/inventory-management-system/blob/main/backend/swagger.js"
click node_pool "https://github.com/wajeehasajid/inventory-management-system/blob/main/backend/db/pool.js"
click node_errors "https://github.com/wajeehasajid/inventory-management-system/blob/main/backend/middleware/errorHandler.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_product_ui,node_category_ui,node_supplier_ui,node_dashboard_ui,node_login_ui,node_settings_ui,node_api_client,node_user toneBlue
class node_server,node_auth_routes,node_auth_middleware,node_swagger toneAmber
class node_products,node_categories,node_suppliers,node_stock,node_dashboard toneMint
class node_pool,node_postgres,node_errors toneRose
```

## Components

### Browser interface

- [Product screens](https://github.com/wajeehasajid/inventory-management-system/blob/main/frontend/products.js): `frontend/products.js`
- [Category screens](https://github.com/wajeehasajid/inventory-management-system/blob/main/frontend/categories.js): `frontend/categories.js`
- [Supplier screens](https://github.com/wajeehasajid/inventory-management-system/blob/main/frontend/suppliers.js): `frontend/suppliers.js`
- [Dashboard screens](https://github.com/wajeehasajid/inventory-management-system/blob/main/frontend/dashboard.js): `frontend/dashboard.js`
- [Login screens](https://github.com/wajeehasajid/inventory-management-system/blob/main/frontend/login.js): `frontend/login.js`
- [Account settings](https://github.com/wajeehasajid/inventory-management-system/blob/main/frontend/settings.js): `frontend/settings.js`
- [Fetch API client](https://github.com/wajeehasajid/inventory-management-system/blob/main/frontend/api.js): `frontend/api.js`

### API and access

- [Express API](https://github.com/wajeehasajid/inventory-management-system/blob/main/backend/server.js): `backend/server.js`
- [Authentication](https://github.com/wajeehasajid/inventory-management-system/blob/main/backend/routes/auth.js): `backend/routes/auth.js`
- [Token and roles](https://github.com/wajeehasajid/inventory-management-system/blob/main/backend/middleware/auth.js): `backend/middleware/auth.js`
- [API documentation](https://github.com/wajeehasajid/inventory-management-system/blob/main/backend/swagger.js): `backend/swagger.js`

### Inventory workflows

- [Products and CSV](https://github.com/wajeehasajid/inventory-management-system/blob/main/backend/routes/products.js): `backend/routes/products.js`
- [Categories](https://github.com/wajeehasajid/inventory-management-system/blob/main/backend/routes/categories.js): `backend/routes/categories.js`
- [Suppliers](https://github.com/wajeehasajid/inventory-management-system/blob/main/backend/routes/suppliers.js): `backend/routes/suppliers.js`
- [Stock movements](https://github.com/wajeehasajid/inventory-management-system/blob/main/backend/routes/products.js): `backend/routes/products.js`
- [Inventory analytics](https://github.com/wajeehasajid/inventory-management-system/blob/main/backend/routes/dashboard.js): `backend/routes/dashboard.js`

### Persistence and errors

- [PostgreSQL pool](https://github.com/wajeehasajid/inventory-management-system/blob/main/backend/db/pool.js): `backend/db/pool.js`
- **Inventory database**
- [Error responses](https://github.com/wajeehasajid/inventory-management-system/blob/main/backend/middleware/errorHandler.js): `backend/middleware/errorHandler.js`

### Other components

- **Inventory user**

## Connections

- Inventory user → Login screens: signs in (evidence: `README.md`)
- Inventory user → Product screens: manages inventory (evidence: `README.md`)
- Inventory user → Category screens: manages categories (evidence: `README.md`)
- Inventory user → Supplier screens: manages suppliers (evidence: `README.md`)
- Inventory user → Dashboard screens: views analytics (evidence: `README.md`)
- Inventory user → Account settings: manages account (evidence: `README.md`)
- Login screens → Fetch API client: requests API
- Product screens → Fetch API client: requests API
- Category screens → Fetch API client: requests API
- Supplier screens → Fetch API client: requests API
- Dashboard screens → Fetch API client: requests API
- Account settings → Fetch API client: requests API
- Fetch API client → Express API: HTTP requests (evidence: `README.md`)
- Express API → Authentication: mounts routes (evidence: `backend/server.js`)
- Express API → Token and roles: protects routes (evidence: `backend/server.js`)
- Express API → Products and CSV: mounts routes (evidence: `backend/server.js`)
- Express API → Categories: mounts routes (evidence: `backend/server.js`)
- Express API → Suppliers: mounts routes (evidence: `backend/server.js`)
- Express API → Inventory analytics: mounts routes (evidence: `backend/server.js`)
- Express API → API documentation: serves documentation (evidence: `backend/server.js`)
- Express API → Error responses: registers handler (evidence: `backend/server.js`)
- Authentication → PostgreSQL pool: queries users (evidence: `backend/routes/auth.js`)
- Authentication → Token and roles: guards account routes (evidence: `backend/routes/auth.js`)
- Products and CSV → PostgreSQL pool: queries inventory (evidence: `backend/routes/products.js`)
- Categories → PostgreSQL pool: queries categories (evidence: `backend/routes/categories.js`)
- Suppliers → PostgreSQL pool: queries suppliers (evidence: `backend/routes/suppliers.js`)
- Inventory analytics → PostgreSQL pool: queries analytics (evidence: `backend/routes/dashboard.js`)
- Products and CSV → Token and roles: checks admin role (evidence: `backend/routes/products.js`)
- Categories → Token and roles: checks admin role (evidence: `backend/routes/categories.js`)
- Suppliers → Token and roles: checks admin role (evidence: `backend/routes/suppliers.js`)
- Stock movements → PostgreSQL pool: records movements (evidence: `backend/routes/products.js`)
- PostgreSQL pool → Inventory database: reads and writes (evidence: `backend/db/pool.js`)
- Products and CSV → Error responses: forwards failures
- Categories → Error responses: forwards failures
- Suppliers → Error responses: forwards failures
- Inventory analytics → Error responses: forwards failures
