# gargharshit304-lab/stocksense architecture

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

- Interactive diagram: https://gitdiagram.com/gargharshit304-lab/stocksense
- Repository: https://github.com/gargharshit304-lab/stocksense

## Overview

StockSense is a role-based warehouse inventory system. Managers and staff use the React application to review stock and perform receiving, delivery, transfer, and count workflows; the documented operational stages update inventory and movement history. The backend exposes authenticated APIs, with authentication and inventory operations backed by Prisma. The README describes broader capabilities than the sampled runtime excerpts; edges for unsampled workflows are limited to documented relationships, and the frontend is described as demo-mode/localStorage by default.

Main entry points: [`src/App.tsx`](https://github.com/gargharshit304-lab/stocksense/blob/main/src/App.tsx) (App workflow shell), [`backend/src/services/auth.ts`](https://github.com/gargharshit304-lab/stocksense/blob/main/backend/src/services/auth.ts) (Auth service), [`backend/src/controllers`](https://github.com/gargharshit304-lab/stocksense/tree/main/backend/src/controllers) (Inventory handlers), [`backend/src/utils/prisma.ts`](https://github.com/gargharshit304-lab/stocksense/blob/main/backend/src/utils/prisma.ts) (PostgreSQL via Prisma)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_app["App workflow shell<br/>[App.tsx]"]
  node_authview["Sign-in and signup<br/>[AuthView.tsx]"]
  node_dashboard["Manager dashboard<br/>[DashboardView.tsx]"]
  node_staffdash["Staff operations"]
  node_catalog["Product catalog<br/>[ProductsView.tsx]"]
  node_receipts["Receiving workflow<br/>[ReceiptsView.tsx]"]
  node_deliveries["Delivery picking"]
  node_adjustments["Stock counting"]
  node_warehouse["Warehouse transfers<br/>[WarehouseView.tsx]"]
  node_history["Movement audit"]
  node_staffhistory["Staff task history"]
  node_api["HTTP client<br/>[client.ts]"]
end

subgraph group_identity["Identity and access"]
  node_authcontext["Auth state<br/>[AuthContext.tsx]"]
  node_authroutes["Authentication routes<br/>[auth.ts]"]
  node_authcontroller["Auth handlers<br/>[auth.ts]"]
  node_authservice["Auth service<br/>[auth.ts]"]
  node_authmiddleware["Token and role guards<br/>[auth.ts]"]
  node_jwt["JWT utilities<br/>[jwt.ts]"]
end

subgraph group_operations["Inventory operations"]
  node_picking["Picking and workflows<br/>[picking.ts]"]
  node_stockservice["Stock logic<br/>[stock.ts]"]
  node_dashboardservice["Dashboard queries<br/>[dashboard.ts]"]
end

subgraph group_backend["API and domain services"]
  node_apiend["Express API<br/>[app.ts]"]
  node_routes["API route registry<br/>[index.ts]"]
  node_inventoryroutes["Inventory API routes"]
  node_inventorycontrollers["Inventory handlers"]
end

subgraph group_persistence["Persistence and messaging"]
  node_database[("PostgreSQL via Prisma<br/>[prisma.ts]")]
  node_email["Transactional email<br/>[sendEmail.ts]"]
end

node_user(("Manager or staff"))

node_user -->|"uses"| node_app
node_app -->|"renders"| node_authview
node_app -->|"renders"| node_dashboard
node_app -->|"renders"| node_staffdash
node_app -->|"renders"| node_catalog
node_app -->|"renders"| node_receipts
node_app -->|"renders"| node_deliveries
node_app -->|"renders"| node_adjustments
node_app -->|"renders"| node_warehouse
node_app -->|"renders"| node_history
node_app -->|"renders"| node_staffhistory
node_app -->|"reads auth"| node_authcontext
node_authview -->|"calls auth"| node_authcontext
node_authcontext -->|"sends requests"| node_api
node_api -.->|"HTTP requests"| node_apiend
node_apiend -->|"mounts routes"| node_routes
node_routes -->|"registers"| node_authroutes
node_routes -->|"registers"| node_inventoryroutes
node_authroutes -->|"dispatches"| node_authcontroller
node_authcontroller -->|"calls"| node_authservice
node_authcontroller -->|"uses guards"| node_authmiddleware
node_authservice -->|"reads and writes"| node_database
node_authservice -->|"creates tokens"| node_jwt
node_authservice -->|"sends OTP"| node_email
node_inventoryroutes -.->|"dispatches"| node_inventorycontrollers
node_inventorycontrollers -.->|"invokes workflows"| node_picking
node_inventorycontrollers -.->|"invokes stock logic"| node_stockservice
node_inventorycontrollers -.->|"queries dashboard"| node_dashboardservice
node_picking -.->|"updates operations"| node_database
node_stockservice -.->|"persists stock"| node_database
node_dashboardservice -.->|"reads metrics"| node_database
node_receipts -.->|"creates and validates"| node_user
node_deliveries -.->|"picks packs validates"| node_user
node_warehouse -.->|"coordinates transfer"| node_user
node_adjustments -.->|"records count"| node_user

click node_app "https://github.com/gargharshit304-lab/stocksense/blob/main/src/App.tsx"
click node_authview "https://github.com/gargharshit304-lab/stocksense/blob/main/src/components/AuthView.tsx"
click node_dashboard "https://github.com/gargharshit304-lab/stocksense/blob/main/src/components/DashboardView.tsx"
click node_staffdash "https://github.com/gargharshit304-lab/stocksense/blob/main/src/components/StaffDashboardView.tsx"
click node_catalog "https://github.com/gargharshit304-lab/stocksense/blob/main/src/components/ProductsView.tsx"
click node_receipts "https://github.com/gargharshit304-lab/stocksense/blob/main/src/components/ReceiptsView.tsx"
click node_deliveries "https://github.com/gargharshit304-lab/stocksense/blob/main/src/components/DeliveryOrdersView.tsx"
click node_adjustments "https://github.com/gargharshit304-lab/stocksense/blob/main/src/components/InventoryAdjustmentView.tsx"
click node_warehouse "https://github.com/gargharshit304-lab/stocksense/blob/main/src/components/WarehouseView.tsx"
click node_history "https://github.com/gargharshit304-lab/stocksense/blob/main/src/components/MoveHistoryView.tsx"
click node_staffhistory "https://github.com/gargharshit304-lab/stocksense/blob/main/src/components/StaffOperationHistoryView.tsx"
click node_authcontext "https://github.com/gargharshit304-lab/stocksense/blob/main/src/context/AuthContext.tsx"
click node_api "https://github.com/gargharshit304-lab/stocksense/blob/main/src/api/client.ts"
click node_apiend "https://github.com/gargharshit304-lab/stocksense/blob/main/backend/src/app.ts"
click node_routes "https://github.com/gargharshit304-lab/stocksense/blob/main/backend/src/routes/index.ts"
click node_authroutes "https://github.com/gargharshit304-lab/stocksense/blob/main/backend/src/routes/auth.ts"
click node_authcontroller "https://github.com/gargharshit304-lab/stocksense/blob/main/backend/src/controllers/auth.ts"
click node_authservice "https://github.com/gargharshit304-lab/stocksense/blob/main/backend/src/services/auth.ts"
click node_authmiddleware "https://github.com/gargharshit304-lab/stocksense/blob/main/backend/src/middleware/auth.ts"
click node_inventoryroutes "https://github.com/gargharshit304-lab/stocksense/tree/main/backend/src/routes"
click node_inventorycontrollers "https://github.com/gargharshit304-lab/stocksense/tree/main/backend/src/controllers"
click node_picking "https://github.com/gargharshit304-lab/stocksense/blob/main/backend/src/services/picking.ts"
click node_stockservice "https://github.com/gargharshit304-lab/stocksense/blob/main/backend/src/services/stock.ts"
click node_dashboardservice "https://github.com/gargharshit304-lab/stocksense/blob/main/backend/src/services/dashboard.ts"
click node_database "https://github.com/gargharshit304-lab/stocksense/blob/main/backend/src/utils/prisma.ts"
click node_email "https://github.com/gargharshit304-lab/stocksense/blob/main/backend/src/utils/sendEmail.ts"
click node_jwt "https://github.com/gargharshit304-lab/stocksense/blob/main/backend/src/utils/jwt.ts"

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_authview,node_dashboard,node_staffdash,node_catalog,node_receipts,node_deliveries,node_adjustments,node_warehouse,node_history,node_staffhistory,node_api toneBlue
class node_authcontext,node_authroutes,node_authcontroller,node_authservice,node_authmiddleware,node_jwt toneAmber
class node_picking,node_stockservice,node_dashboardservice toneMint
class node_apiend,node_routes,node_inventoryroutes,node_inventorycontrollers toneRose
class node_database,node_email,node_user toneIndigo
```

## Components

### Web application

- [App workflow shell](https://github.com/gargharshit304-lab/stocksense/blob/main/src/App.tsx): `src/App.tsx`
- [Sign-in and signup](https://github.com/gargharshit304-lab/stocksense/blob/main/src/components/AuthView.tsx): `src/components/AuthView.tsx`
- [Manager dashboard](https://github.com/gargharshit304-lab/stocksense/blob/main/src/components/DashboardView.tsx): `src/components/DashboardView.tsx`
- [Staff operations](https://github.com/gargharshit304-lab/stocksense/blob/main/src/components/StaffDashboardView.tsx): `src/components/StaffDashboardView.tsx`
- [Product catalog](https://github.com/gargharshit304-lab/stocksense/blob/main/src/components/ProductsView.tsx): `src/components/ProductsView.tsx`
- [Receiving workflow](https://github.com/gargharshit304-lab/stocksense/blob/main/src/components/ReceiptsView.tsx): `src/components/ReceiptsView.tsx`
- [Delivery picking](https://github.com/gargharshit304-lab/stocksense/blob/main/src/components/DeliveryOrdersView.tsx): `src/components/DeliveryOrdersView.tsx`
- [Stock counting](https://github.com/gargharshit304-lab/stocksense/blob/main/src/components/InventoryAdjustmentView.tsx): `src/components/InventoryAdjustmentView.tsx`
- [Warehouse transfers](https://github.com/gargharshit304-lab/stocksense/blob/main/src/components/WarehouseView.tsx): `src/components/WarehouseView.tsx`
- [Movement audit](https://github.com/gargharshit304-lab/stocksense/blob/main/src/components/MoveHistoryView.tsx): `src/components/MoveHistoryView.tsx`
- [Staff task history](https://github.com/gargharshit304-lab/stocksense/blob/main/src/components/StaffOperationHistoryView.tsx): `src/components/StaffOperationHistoryView.tsx`
- [HTTP client](https://github.com/gargharshit304-lab/stocksense/blob/main/src/api/client.ts): `src/api/client.ts`

### Identity and access

- [Auth state](https://github.com/gargharshit304-lab/stocksense/blob/main/src/context/AuthContext.tsx): `src/context/AuthContext.tsx`
- [Authentication routes](https://github.com/gargharshit304-lab/stocksense/blob/main/backend/src/routes/auth.ts): `backend/src/routes/auth.ts`
- [Auth handlers](https://github.com/gargharshit304-lab/stocksense/blob/main/backend/src/controllers/auth.ts): `backend/src/controllers/auth.ts`
- [Auth service](https://github.com/gargharshit304-lab/stocksense/blob/main/backend/src/services/auth.ts): `backend/src/services/auth.ts`
- [Token and role guards](https://github.com/gargharshit304-lab/stocksense/blob/main/backend/src/middleware/auth.ts): `backend/src/middleware/auth.ts`
- [JWT utilities](https://github.com/gargharshit304-lab/stocksense/blob/main/backend/src/utils/jwt.ts): `backend/src/utils/jwt.ts`

### Inventory operations

- [Picking and workflows](https://github.com/gargharshit304-lab/stocksense/blob/main/backend/src/services/picking.ts): `backend/src/services/picking.ts`
- [Stock logic](https://github.com/gargharshit304-lab/stocksense/blob/main/backend/src/services/stock.ts): `backend/src/services/stock.ts`
- [Dashboard queries](https://github.com/gargharshit304-lab/stocksense/blob/main/backend/src/services/dashboard.ts): `backend/src/services/dashboard.ts`

### API and domain services

- [Express API](https://github.com/gargharshit304-lab/stocksense/blob/main/backend/src/app.ts): `backend/src/app.ts`
- [API route registry](https://github.com/gargharshit304-lab/stocksense/blob/main/backend/src/routes/index.ts): `backend/src/routes/index.ts`
- [Inventory API routes](https://github.com/gargharshit304-lab/stocksense/tree/main/backend/src/routes): `backend/src/routes`
- [Inventory handlers](https://github.com/gargharshit304-lab/stocksense/tree/main/backend/src/controllers): `backend/src/controllers`

### Persistence and messaging

- [PostgreSQL via Prisma](https://github.com/gargharshit304-lab/stocksense/blob/main/backend/src/utils/prisma.ts): `backend/src/utils/prisma.ts`
- [Transactional email](https://github.com/gargharshit304-lab/stocksense/blob/main/backend/src/utils/sendEmail.ts): `backend/src/utils/sendEmail.ts`

### Other components

- **Manager or staff**

## Connections

- Manager or staff → App workflow shell: uses
- App workflow shell → Sign-in and signup: renders (evidence: `src/App.tsx`)
- App workflow shell → Manager dashboard: renders (evidence: `src/App.tsx`)
- App workflow shell → Staff operations: renders (evidence: `src/App.tsx`)
- App workflow shell → Product catalog: renders (evidence: `src/App.tsx`)
- App workflow shell → Receiving workflow: renders (evidence: `src/App.tsx`)
- App workflow shell → Delivery picking: renders (evidence: `src/App.tsx`)
- App workflow shell → Stock counting: renders (evidence: `src/App.tsx`)
- App workflow shell → Warehouse transfers: renders (evidence: `src/App.tsx`)
- App workflow shell → Movement audit: renders (evidence: `src/App.tsx`)
- App workflow shell → Staff task history: renders (evidence: `src/App.tsx`)
- App workflow shell → Auth state: reads auth (evidence: `src/App.tsx`)
- Sign-in and signup → Auth state: calls auth (evidence: `src/components/AuthView.tsx`)
- Auth state → HTTP client: sends requests (evidence: `src/context/AuthContext.tsx`)
- HTTP client → Express API: HTTP requests
- Express API → API route registry: mounts routes (evidence: `backend/src/app.ts`)
- API route registry → Authentication routes: registers (evidence: `backend/src/routes/index.ts`)
- API route registry → Inventory API routes: registers (evidence: `backend/src/routes/index.ts`)
- Authentication routes → Auth handlers: dispatches (evidence: `backend/src/routes/auth.ts`)
- Auth handlers → Auth service: calls (evidence: `backend/src/controllers/auth.ts`)
- Auth handlers → Token and role guards: uses guards (evidence: `backend/src/routes/auth.ts`)
- Auth service → PostgreSQL via Prisma: reads and writes (evidence: `backend/src/services/auth.ts`)
- Auth service → JWT utilities: creates tokens (evidence: `backend/src/services/auth.ts`)
- Auth service → Transactional email: sends OTP (evidence: `backend/src/services/auth.ts`)
- Inventory API routes → Inventory handlers: dispatches (evidence: `backend/src/routes/auth.ts`)
- Inventory handlers → Picking and workflows: invokes workflows
- Inventory handlers → Stock logic: invokes stock logic
- Inventory handlers → Dashboard queries: queries dashboard
- Picking and workflows → PostgreSQL via Prisma: updates operations
- Stock logic → PostgreSQL via Prisma: persists stock
- Dashboard queries → PostgreSQL via Prisma: reads metrics
- Receiving workflow → Manager or staff: creates and validates
- Delivery picking → Manager or staff: picks packs validates
- Warehouse transfers → Manager or staff: coordinates transfer
- Stock counting → Manager or staff: records count
