# bayronearljames-source/stocklink-inventory-system architecture

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

- Interactive diagram: https://gitdiagram.com/bayronearljames-source/stocklink-inventory-system
- Repository: https://github.com/bayronearljames-source/stocklink-inventory-system

## Overview

StockLink is a multi-branch inventory and restocking system. Staff use role-specific dashboards and pages to view branch stock, record stock movements, and create or track restock requests; administrators manage catalog data, review requests, and access audit and reporting views. The React client sends authenticated requests to an Express API, which enforces identity and role checks and accesses PostgreSQL through Prisma. The README and sampled sources document database-triggered low-stock requests, audit logging, and atomic restock fulfillment; several page-to-endpoint details are unsampled, so those links are not expanded.

Main entry points: [`client/src/routes/AppRoutes.jsx`](https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/routes/AppRoutes.jsx) (Role-based routes), [`client/src/api/client.js`](https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/api/client.js) (API client), [`index.js`](https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/index.js) (Express API), [`client/src/App.jsx`](https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/App.jsx) (Client app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React client"]
  node_app["Client app<br/>[App.jsx]"]
  node_routes["Role-based routes<br/>[AppRoutes.jsx]"]
  node_dashboards["Role dashboards"]
  node_catalog["Catalog management<br/>[ItemCatalog.jsx]"]
  node_branches["Branch management"]
  node_suppliers["Supplier management"]
  node_stock["Branch stock<br/>[BranchStock.jsx]"]
  node_movements["Stock movements<br/>[StockMovements.jsx]"]
  node_restock["Restock requests"]
  node_reports["Reports<br/>[Reports.jsx]"]
  node_audit["Audit logs<br/>[AuditLogs.jsx]"]
  node_clientapi["API client<br/>[client.js]"]
end

subgraph group_security["Authentication and access"]
  node_authcontext["Session context<br/>[AuthContext.jsx]"]
  node_middleware["Token and role guards<br/>[auth.js]"]
end

subgraph group_api["Express API"]
  node_login["Login API<br/>[auth.js]"]
  node_server["Express API<br/>[index.js]"]
end

subgraph group_data["Inventory data"]
  node_schema[("Relational schema")]
  node_triggers["Stock and audit triggers"]
  node_fulfillment["Atomic fulfillment procedure"]
end

node_staff(("Staff user"))
node_postgres[("PostgreSQL service")]

node_staff -->|"uses"| node_app
node_app -->|"renders"| node_routes
node_routes -->|"checks session"| node_authcontext
node_routes -->|"routes by role"| node_dashboards
node_routes -->|"routes"| node_catalog
node_routes -->|"routes"| node_branches
node_routes -->|"routes"| node_suppliers
node_routes -->|"routes"| node_stock
node_routes -->|"routes"| node_movements
node_routes -->|"routes"| node_restock
node_routes -->|"routes"| node_reports
node_routes -->|"routes"| node_audit
node_authcontext -->|"posts login"| node_login
node_login -->|"reads users"| node_postgres
node_staff -->|"requests data"| node_clientapi
node_dashboards -->|"fetches data"| node_clientapi
node_stock -->|"fetches data"| node_clientapi
node_movements -->|"records movements"| node_clientapi
node_restock -->|"manages requests"| node_clientapi
node_catalog -->|"API requests"| node_clientapi
node_branches -->|"API requests"| node_clientapi
node_suppliers -->|"API requests"| node_clientapi
node_reports -->|"API requests"| node_clientapi
node_audit -->|"API requests"| node_clientapi
node_clientapi -->|"HTTP requests"| node_server
node_server -->|"verifies access"| node_middleware
node_server -->|"queries and writes"| node_postgres
node_schema -->|"defines tables"| node_postgres
node_postgres -->|"runs on stock changes"| node_triggers
node_postgres -->|"runs fulfillment"| node_fulfillment

click node_app "https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/App.jsx"
click node_routes "https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/routes/AppRoutes.jsx"
click node_dashboards "https://github.com/bayronearljames-source/stocklink-inventory-system/tree/main/client/src/pages/dashboard"
click node_catalog "https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/pages/catalog/ItemCatalog.jsx"
click node_branches "https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/pages/branches/BranchManagement.jsx"
click node_suppliers "https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/pages/suppliers/SupplierManagement.jsx"
click node_stock "https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/pages/stock/BranchStock.jsx"
click node_movements "https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/pages/movements/StockMovements.jsx"
click node_restock "https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/pages/restock/RestockRequests.jsx"
click node_reports "https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/pages/reports/Reports.jsx"
click node_audit "https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/pages/audit/AuditLogs.jsx"
click node_authcontext "https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/context/AuthContext.jsx"
click node_login "https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/routes/auth.js"
click node_middleware "https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/middleware/auth.js"
click node_clientapi "https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/api/client.js"
click node_server "https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/index.js"
click node_schema "https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/migrations/001_init_schema.sql"
click node_triggers "https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/migrations/004_add_stock_movements_logging.sql"
click node_fulfillment "https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/migrations/003_fix_restock_fulfill_transaction.sql"

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_routes,node_dashboards,node_catalog,node_branches,node_suppliers,node_stock,node_movements,node_restock,node_reports,node_audit,node_clientapi,node_staff toneBlue
class node_authcontext,node_middleware,node_postgres toneAmber
class node_login,node_server toneMint
class node_schema,node_triggers,node_fulfillment toneRose
```

## Components

### React client

- [Client app](https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Role-based routes](https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/routes/AppRoutes.jsx): `client/src/routes/AppRoutes.jsx`
- [Role dashboards](https://github.com/bayronearljames-source/stocklink-inventory-system/tree/main/client/src/pages/dashboard): `client/src/pages/dashboard`
- [Catalog management](https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/pages/catalog/ItemCatalog.jsx): `client/src/pages/catalog/ItemCatalog.jsx`
- [Branch management](https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/pages/branches/BranchManagement.jsx): `client/src/pages/branches/BranchManagement.jsx`
- [Supplier management](https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/pages/suppliers/SupplierManagement.jsx): `client/src/pages/suppliers/SupplierManagement.jsx`
- [Branch stock](https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/pages/stock/BranchStock.jsx): `client/src/pages/stock/BranchStock.jsx`
- [Stock movements](https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/pages/movements/StockMovements.jsx): `client/src/pages/movements/StockMovements.jsx`
- [Restock requests](https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/pages/restock/RestockRequests.jsx): `client/src/pages/restock/RestockRequests.jsx`
- [Reports](https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/pages/reports/Reports.jsx): `client/src/pages/reports/Reports.jsx`
- [Audit logs](https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/pages/audit/AuditLogs.jsx): `client/src/pages/audit/AuditLogs.jsx`
- [API client](https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/api/client.js): `client/src/api/client.js`

### Authentication and access

- [Session context](https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [Token and role guards](https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/middleware/auth.js): `middleware/auth.js`

### Express API

- [Login API](https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/routes/auth.js): `routes/auth.js`
- [Express API](https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/index.js): `index.js`

### Inventory data

- [Relational schema](https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/migrations/001_init_schema.sql): `migrations/001_init_schema.sql`
- [Stock and audit triggers](https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/migrations/004_add_stock_movements_logging.sql): `migrations/004_add_stock_movements_logging.sql`
- [Atomic fulfillment procedure](https://github.com/bayronearljames-source/stocklink-inventory-system/blob/main/migrations/003_fix_restock_fulfill_transaction.sql): `migrations/003_fix_restock_fulfill_transaction.sql`

### Other components

- **Staff user**
- **PostgreSQL service**

## Connections

- Staff user → Client app: uses
- Client app → Role-based routes: renders
- Role-based routes → Session context: checks session
- Role-based routes → Role dashboards: routes by role
- Role-based routes → Catalog management: routes
- Role-based routes → Branch management: routes
- Role-based routes → Supplier management: routes
- Role-based routes → Branch stock: routes
- Role-based routes → Stock movements: routes
- Role-based routes → Restock requests: routes
- Role-based routes → Reports: routes
- Role-based routes → Audit logs: routes
- Session context → Login API: posts login
- Login API → PostgreSQL service: reads users
- Staff user → API client: requests data
- Role dashboards → API client: fetches data
- Branch stock → API client: fetches data
- Stock movements → API client: records movements
- Restock requests → API client: manages requests
- Catalog management → API client: API requests
- Branch management → API client: API requests
- Supplier management → API client: API requests
- Reports → API client: API requests
- Audit logs → API client: API requests
- API client → Express API: HTTP requests
- Express API → Token and role guards: verifies access
- Express API → PostgreSQL service: queries and writes
- Relational schema → PostgreSQL service: defines tables
- PostgreSQL service → Stock and audit triggers: runs on stock changes
- PostgreSQL service → Atomic fulfillment procedure: runs fulfillment
