# beanszza/brenraphaels-smart-inventory-system architecture

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

- Interactive diagram: https://gitdiagram.com/beanszza/brenraphaels-smart-inventory-system
- Repository: https://github.com/beanszza/brenraphaels-smart-inventory-system

## Overview

IMS is a staff-facing inventory and operations management system. Staff sign in through the Portal, then work across resources, procurement, receiving, inventory, production and stock-transfer screens; domain actions provide the server-side operations, with database and external-service integrations behind them. The sampled files show the Portal guard, inventory action boundary, domain client wrappers, Prisma setup, file routes and selected POS/SCMS endpoints. Several major screen capabilities are represented by their exact directories because their implementations were not sampled; those paths do not imply unverified calls.

Main entry points: [`lib/prisma.ts`](https://github.com/beanszza/brenraphaels-smart-inventory-system/blob/main/lib/prisma.ts) (Application database), [`app/actions/inventory`](https://github.com/beanszza/brenraphaels-smart-inventory-system/tree/main/app/actions/inventory) (Inventory actions), [`lib/files.ts`](https://github.com/beanszza/brenraphaels-smart-inventory-system/blob/main/lib/files.ts) (File service boundary), [`lib/portal/staff.ts`](https://github.com/beanszza/brenraphaels-smart-inventory-system/blob/main/lib/portal/staff.ts) (Module access guard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and shell"]
  node_ims["IMS screens"]
  node_auth["Sign-in screens<br/>[AuthScreen.tsx]"]
  node_portal_flow["Portal auth flow"]
  node_staff_guard["Module access guard<br/>[staff.ts]"]
  node_dashboard["Operations dashboard<br/>[page.tsx]"]
end

subgraph group_planning["Resources and procurement"]
  node_resources["Resources and suppliers"]
  node_procurement["Orders and procurement"]
  node_receiving["Goods receiving"]
  node_inbound["Inbound processing"]
end

subgraph group_operations["Inventory operations"]
  node_inventory_ui["Inventory screens"]
  node_inventory_actions["Inventory actions"]
  node_inventory_core["Inventory mutation layer<br/>[mutate.ts]"]
  node_transfer["Stock transfers"]
  node_transfer_api["POS and SCMS transfer API<br/>[route.ts]"]
end

subgraph group_production["Production and quality"]
  node_production["Production and quality"]
  node_production_ui["Production screens"]
  node_recipes["Recipes<br/>[page.tsx]"]
end

subgraph group_integration["Integrations and services"]
  node_database[("Application database<br/>[prisma.ts]")]
  node_files["File service boundary<br/>[files.ts]"]
  node_file_routes["File routes<br/>[file-routes.ts]"]
  node_gateway_files["Files gateway<br/>[files.ts]"]
end

node_staff(("Staff user"))
node_pos(("POS / SCMS"))
node_portal{{"Portal service"}}

node_staff -->|"uses"| node_ims
node_staff -->|"signs in"| node_portal_flow
node_portal_flow -->|"exchanges session"| node_portal
node_ims -->|"checks modules"| node_staff_guard
node_dashboard -->|"requires access"| node_staff_guard
node_dashboard -.->|"loads data"| node_resources
node_inventory_ui -->|"requires access"| node_staff_guard
node_inventory_ui -->|"loads inventory"| node_inventory_actions
node_inventory_actions -->|"mutates stock"| node_inventory_core
node_inventory_actions -->|"reads and writes"| node_database
node_inventory_actions -->|"manages write-off photos"| node_files
node_procurement -.->|"reads and writes"| node_database
node_receiving -.->|"records receipts"| node_database
node_inbound -.->|"supports inbound flow"| node_receiving
node_transfer_api -->|"serves requests"| node_pos
node_transfer_api -->|"records requests"| node_database
node_transfer -.->|"reads and writes"| node_database
node_production_ui -->|"invokes actions"| node_production
node_production -.->|"reads and writes"| node_database
node_recipes -.->|"uses recipe data"| node_resources
node_file_routes -->|"checks route access"| node_staff_guard
node_file_routes -->|"uploads and resolves"| node_files
node_files -->|"uses gateway"| node_gateway_files
node_files -.->|"obtains session context"| node_portal

click node_ims "https://github.com/beanszza/brenraphaels-smart-inventory-system/tree/main/app/(root)"
click node_auth "https://github.com/beanszza/brenraphaels-smart-inventory-system/blob/main/components/auth/AuthScreen.tsx"
click node_portal_flow "https://github.com/beanszza/brenraphaels-smart-inventory-system/tree/main/app/api/portal"
click node_staff_guard "https://github.com/beanszza/brenraphaels-smart-inventory-system/blob/main/lib/portal/staff.ts"
click node_dashboard "https://github.com/beanszza/brenraphaels-smart-inventory-system/blob/main/dashboard/page.tsx"
click node_resources "https://github.com/beanszza/brenraphaels-smart-inventory-system/tree/main/app/actions/resources"
click node_procurement "https://github.com/beanszza/brenraphaels-smart-inventory-system/tree/main/app/actions/orders"
click node_receiving "https://github.com/beanszza/brenraphaels-smart-inventory-system/tree/main/app/actions/receiving"
click node_inbound "https://github.com/beanszza/brenraphaels-smart-inventory-system/tree/main/app/(root)/inbound-processing"
click node_inventory_ui "https://github.com/beanszza/brenraphaels-smart-inventory-system/tree/main/app/(root)/inventory"
click node_inventory_actions "https://github.com/beanszza/brenraphaels-smart-inventory-system/tree/main/app/actions/inventory"
click node_inventory_core "https://github.com/beanszza/brenraphaels-smart-inventory-system/blob/main/lib/inventory/mutate.ts"
click node_transfer "https://github.com/beanszza/brenraphaels-smart-inventory-system/tree/main/app/actions/stock-transfer"
click node_transfer_api "https://github.com/beanszza/brenraphaels-smart-inventory-system/blob/main/app/api/pos/stock-requests/route.ts"
click node_production "https://github.com/beanszza/brenraphaels-smart-inventory-system/tree/main/app/actions/production"
click node_production_ui "https://github.com/beanszza/brenraphaels-smart-inventory-system/tree/main/components/production"
click node_recipes "https://github.com/beanszza/brenraphaels-smart-inventory-system/blob/main/app/(root)/recipes/page.tsx"
click node_database "https://github.com/beanszza/brenraphaels-smart-inventory-system/blob/main/lib/prisma.ts"
click node_files "https://github.com/beanszza/brenraphaels-smart-inventory-system/blob/main/lib/files.ts"
click node_file_routes "https://github.com/beanszza/brenraphaels-smart-inventory-system/blob/main/lib/file-routes.ts"
click node_gateway_files "https://github.com/beanszza/brenraphaels-smart-inventory-system/blob/main/lib/gateway/files.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_ims,node_auth,node_portal_flow,node_staff_guard,node_dashboard,node_staff toneBlue
class node_resources,node_procurement,node_receiving,node_inbound toneAmber
class node_inventory_ui,node_inventory_actions,node_inventory_core,node_transfer,node_transfer_api toneMint
class node_production,node_production_ui,node_recipes toneRose
class node_database,node_files,node_file_routes,node_gateway_files,node_pos,node_portal toneIndigo
```

## Components

### Access and shell

- [IMS screens](https://github.com/beanszza/brenraphaels-smart-inventory-system/tree/main/app/(root)): `app/(root)`
- [Sign-in screens](https://github.com/beanszza/brenraphaels-smart-inventory-system/blob/main/components/auth/AuthScreen.tsx): `components/auth/AuthScreen.tsx`
- [Portal auth flow](https://github.com/beanszza/brenraphaels-smart-inventory-system/tree/main/app/api/portal): `app/api/portal`
- [Module access guard](https://github.com/beanszza/brenraphaels-smart-inventory-system/blob/main/lib/portal/staff.ts): `lib/portal/staff.ts`
- [Operations dashboard](https://github.com/beanszza/brenraphaels-smart-inventory-system/blob/main/dashboard/page.tsx): `dashboard/page.tsx`

### Resources and procurement

- [Resources and suppliers](https://github.com/beanszza/brenraphaels-smart-inventory-system/tree/main/app/actions/resources): `app/actions/resources`
- [Orders and procurement](https://github.com/beanszza/brenraphaels-smart-inventory-system/tree/main/app/actions/orders): `app/actions/orders`
- [Goods receiving](https://github.com/beanszza/brenraphaels-smart-inventory-system/tree/main/app/actions/receiving): `app/actions/receiving`
- [Inbound processing](https://github.com/beanszza/brenraphaels-smart-inventory-system/tree/main/app/(root)/inbound-processing): `app/(root)/inbound-processing`

### Inventory operations

- [Inventory screens](https://github.com/beanszza/brenraphaels-smart-inventory-system/tree/main/app/(root)/inventory): `app/(root)/inventory`
- [Inventory actions](https://github.com/beanszza/brenraphaels-smart-inventory-system/tree/main/app/actions/inventory): `app/actions/inventory`
- [Inventory mutation layer](https://github.com/beanszza/brenraphaels-smart-inventory-system/blob/main/lib/inventory/mutate.ts): `lib/inventory/mutate.ts`
- [Stock transfers](https://github.com/beanszza/brenraphaels-smart-inventory-system/tree/main/app/actions/stock-transfer): `app/actions/stock-transfer`
- [POS and SCMS transfer API](https://github.com/beanszza/brenraphaels-smart-inventory-system/blob/main/app/api/pos/stock-requests/route.ts): `app/api/pos/stock-requests/route.ts`

### Production and quality

- [Production and quality](https://github.com/beanszza/brenraphaels-smart-inventory-system/tree/main/app/actions/production): `app/actions/production`
- [Production screens](https://github.com/beanszza/brenraphaels-smart-inventory-system/tree/main/components/production): `components/production`
- [Recipes](https://github.com/beanszza/brenraphaels-smart-inventory-system/blob/main/app/(root)/recipes/page.tsx): `app/(root)/recipes/page.tsx`

### Integrations and services

- [Application database](https://github.com/beanszza/brenraphaels-smart-inventory-system/blob/main/lib/prisma.ts): `lib/prisma.ts`
- [File service boundary](https://github.com/beanszza/brenraphaels-smart-inventory-system/blob/main/lib/files.ts): `lib/files.ts`
- [File routes](https://github.com/beanszza/brenraphaels-smart-inventory-system/blob/main/lib/file-routes.ts): `lib/file-routes.ts`
- [Files gateway](https://github.com/beanszza/brenraphaels-smart-inventory-system/blob/main/lib/gateway/files.ts): `lib/gateway/files.ts`

### Other components

- **Staff user**
- **POS / SCMS**
- **Portal service**

## Connections

- Staff user → IMS screens: uses (evidence: `README.md`)
- Staff user → Portal auth flow: signs in (evidence: `README.md`)
- Portal auth flow → Portal service: exchanges session (evidence: `README.md`)
- IMS screens → Module access guard: checks modules (evidence: `README.md`)
- Operations dashboard → Module access guard: requires access (evidence: `README.md`)
- Operations dashboard → Resources and suppliers: loads data
- Inventory screens → Module access guard: requires access (evidence: `app/(root)/inventory/page.tsx`)
- Inventory screens → Inventory actions: loads inventory (evidence: `app/(root)/inventory/page.tsx`)
- Inventory actions → Inventory mutation layer: mutates stock (evidence: `app/actions/inventory/balances.ts`)
- Inventory actions → Application database: reads and writes (evidence: `app/actions/inventory/balances.ts`)
- Inventory actions → File service boundary: manages write-off photos (evidence: `app/actions/inventory/write-offs.ts`)
- Orders and procurement → Application database: reads and writes
- Goods receiving → Application database: records receipts
- Inbound processing → Goods receiving: supports inbound flow
- POS and SCMS transfer API → POS / SCMS: serves requests (evidence: `app/api/pos/stock-requests/route.ts`)
- POS and SCMS transfer API → Application database: records requests (evidence: `app/api/pos/stock-requests/route.ts`)
- Stock transfers → Application database: reads and writes
- Production screens → Production and quality: invokes actions
- Production and quality → Application database: reads and writes
- Recipes → Resources and suppliers: uses recipe data
- File routes → Module access guard: checks route access (evidence: `lib/file-routes.ts`)
- File routes → File service boundary: uploads and resolves (evidence: `lib/file-routes.ts`)
- File service boundary → Files gateway: uses gateway (evidence: `lib/files.ts`)
- File service boundary → Portal service: obtains session context
