# sahebpaper/saheb-paper architecture

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

- Interactive diagram: https://gitdiagram.com/sahebpaper/saheb-paper
- Repository: https://github.com/sahebpaper/saheb-paper

## Overview

Saheb Paper is a multi-role paper-mill ERP spanning shop-floor production through inventory and dispatch. The principal workflow follows documented material and reel traceability, from raw-material receipt and pulping through machine rolls, rewinding, quality checks, finished stock, and dispatch; the app also covers utilities, stores, reporting, and administration. The route map and several shared data/authentication relationships are visible in excerpts and the source index. Most domain screens were not sampled, so their internal calls are not inferred.

Main entry points: [`src/App.tsx`](https://github.com/sahebpaper/saheb-paper/blob/main/src/App.tsx) (ERP routes), [`src/modules/auth/AuthContext.tsx`](https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/auth/AuthContext.tsx) (Login and sessions), [`src/modules/rewinder/RewinderView.tsx`](https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/rewinder/RewinderView.tsx) (Rewinder conversion), [`src/data/index.ts`](https://github.com/sahebpaper/saheb-paper/blob/main/src/data/index.ts) (Operational records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and app shell"]
  node_app["ERP routes<br/>[App.tsx]"]
  node_auth["Login and sessions<br/>[AuthContext.tsx]"]
  node_guard["Role route guard<br/>[ProtectedRoute.tsx]"]
  node_layout["ERP shell<br/>[Layout.tsx]"]
end

subgraph group_operations["Mill operations"]
  node_raw["Raw material inward"]
  node_pulp["Pulp mill batches<br/>[PulpMillView.tsx]"]
  node_machine["Machine production<br/>[MachineView.tsx]"]
  node_rewinder["Rewinder conversion<br/>[RewinderView.tsx]"]
  node_lab["QC laboratory<br/>[LabView.tsx]"]
end

subgraph group_inventory["Inventory and dispatch"]
  node_labels["Label studio"]
  node_finished["Finished stock"]
  node_orders["Customer orders<br/>[OrdersView.tsx]"]
  node_dispatch["Dispatch challans<br/>[DispatchView.tsx]"]
  node_store["Spare parts store<br/>[StoreView.tsx]"]
end

subgraph group_oversight["Utilities and oversight"]
  node_dashboard["Dashboard analytics<br/>[DashboardView.tsx]"]
  node_reports["Management reports<br/>[ReportsView.tsx]"]
  node_utilities["Utilities telemetry<br/>[BoilerView.tsx]"]
  node_etp["ETP operations<br/>[EtpView.tsx]"]
  node_electricity["Electricity logs"]
  node_admin["Administration<br/>[AdminMasters.tsx]"]
end

subgraph group_platform["Shared data services"]
  node_security["PIN security<br/>[security.ts]"]
  node_data[("Operational records<br/>[index.ts]")]
  node_sync["Cloud synchronization<br/>[supabaseSync.ts]"]
  node_supabase["Supabase<br/>[supabase.ts]"]
end

node_operator(("Mill user"))

node_operator -->|"uses"| node_app
node_app -->|"provides context"| node_auth
node_app -->|"routes through"| node_guard
node_app -->|"wraps screens"| node_layout
node_auth -->|"loads users"| node_data
node_auth -->|"verifies PIN"| node_security
node_data -->|"uses PIN helpers"| node_security
node_data -->|"pushes changes"| node_sync
node_sync -->|"uses client"| node_supabase
node_raw -->|"feeds traceability"| node_pulp
node_pulp -->|"batch to rolls"| node_machine
node_machine -->|"parent rolls"| node_rewinder
node_rewinder -->|"reels for testing"| node_lab
node_rewinder -->|"generates QR tags"| node_labels
node_lab -->|"grades stock"| node_finished
node_finished -->|"allocates stock"| node_dispatch
node_orders -->|"fulfills orders"| node_dispatch
node_store -.->|"supports oversight"| node_admin
node_dashboard -->|"analytics capability"| node_reports
node_operator -->|"logs shifts"| node_utilities
node_operator -->|"logs compliance"| node_etp
node_operator -->|"logs readings"| node_electricity

click node_app "https://github.com/sahebpaper/saheb-paper/blob/main/src/App.tsx"
click node_auth "https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/auth/AuthContext.tsx"
click node_guard "https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/auth/ProtectedRoute.tsx"
click node_layout "https://github.com/sahebpaper/saheb-paper/blob/main/src/components/Layout.tsx"
click node_security "https://github.com/sahebpaper/saheb-paper/blob/main/src/lib/security.ts"
click node_data "https://github.com/sahebpaper/saheb-paper/blob/main/src/data/index.ts"
click node_sync "https://github.com/sahebpaper/saheb-paper/blob/main/src/lib/supabaseSync.ts"
click node_supabase "https://github.com/sahebpaper/saheb-paper/blob/main/src/lib/supabase.ts"
click node_raw "https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/raw-material/RawMaterialView.tsx"
click node_pulp "https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/pulp-mill/PulpMillView.tsx"
click node_machine "https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/machine/MachineView.tsx"
click node_rewinder "https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/rewinder/RewinderView.tsx"
click node_lab "https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/lab/LabView.tsx"
click node_labels "https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/label-studio/LabelStudioView.tsx"
click node_finished "https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/finish-stock/FinishStockView.tsx"
click node_orders "https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/orders/OrdersView.tsx"
click node_dispatch "https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/dispatch/DispatchView.tsx"
click node_store "https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/store/StoreView.tsx"
click node_dashboard "https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/dashboard/DashboardView.tsx"
click node_reports "https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/reports/ReportsView.tsx"
click node_utilities "https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/boiler/BoilerView.tsx"
click node_etp "https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/etp/EtpView.tsx"
click node_electricity "https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/electricity/ElectricityView.tsx"
click node_admin "https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/admin/AdminMasters.tsx"

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_auth,node_guard,node_layout,node_operator toneBlue
class node_raw,node_pulp,node_machine,node_rewinder,node_lab toneAmber
class node_labels,node_finished,node_orders,node_dispatch,node_store toneMint
class node_dashboard,node_reports,node_utilities,node_etp,node_electricity,node_admin toneRose
class node_security,node_data,node_sync,node_supabase toneIndigo
```

## Components

### Access and app shell

- [ERP routes](https://github.com/sahebpaper/saheb-paper/blob/main/src/App.tsx): `src/App.tsx`
- [Login and sessions](https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/auth/AuthContext.tsx): `src/modules/auth/AuthContext.tsx`
- [Role route guard](https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/auth/ProtectedRoute.tsx): `src/modules/auth/ProtectedRoute.tsx`
- [ERP shell](https://github.com/sahebpaper/saheb-paper/blob/main/src/components/Layout.tsx): `src/components/Layout.tsx`

### Mill operations

- [Raw material inward](https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/raw-material/RawMaterialView.tsx): `src/modules/raw-material/RawMaterialView.tsx`
- [Pulp mill batches](https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/pulp-mill/PulpMillView.tsx): `src/modules/pulp-mill/PulpMillView.tsx`
- [Machine production](https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/machine/MachineView.tsx): `src/modules/machine/MachineView.tsx`
- [Rewinder conversion](https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/rewinder/RewinderView.tsx): `src/modules/rewinder/RewinderView.tsx`
- [QC laboratory](https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/lab/LabView.tsx): `src/modules/lab/LabView.tsx`

### Inventory and dispatch

- [Label studio](https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/label-studio/LabelStudioView.tsx): `src/modules/label-studio/LabelStudioView.tsx`
- [Finished stock](https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/finish-stock/FinishStockView.tsx): `src/modules/finish-stock/FinishStockView.tsx`
- [Customer orders](https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/orders/OrdersView.tsx): `src/modules/orders/OrdersView.tsx`
- [Dispatch challans](https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/dispatch/DispatchView.tsx): `src/modules/dispatch/DispatchView.tsx`
- [Spare parts store](https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/store/StoreView.tsx): `src/modules/store/StoreView.tsx`

### Utilities and oversight

- [Dashboard analytics](https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/dashboard/DashboardView.tsx): `src/modules/dashboard/DashboardView.tsx`
- [Management reports](https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/reports/ReportsView.tsx): `src/modules/reports/ReportsView.tsx`
- [Utilities telemetry](https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/boiler/BoilerView.tsx): `src/modules/boiler/BoilerView.tsx`
- [ETP operations](https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/etp/EtpView.tsx): `src/modules/etp/EtpView.tsx`
- [Electricity logs](https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/electricity/ElectricityView.tsx): `src/modules/electricity/ElectricityView.tsx`
- [Administration](https://github.com/sahebpaper/saheb-paper/blob/main/src/modules/admin/AdminMasters.tsx): `src/modules/admin/AdminMasters.tsx`

### Shared data services

- [PIN security](https://github.com/sahebpaper/saheb-paper/blob/main/src/lib/security.ts): `src/lib/security.ts`
- [Operational records](https://github.com/sahebpaper/saheb-paper/blob/main/src/data/index.ts): `src/data/index.ts`
- [Cloud synchronization](https://github.com/sahebpaper/saheb-paper/blob/main/src/lib/supabaseSync.ts): `src/lib/supabaseSync.ts`
- [Supabase](https://github.com/sahebpaper/saheb-paper/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`

### Other components

- **Mill user**

## Connections

- Mill user → ERP routes: uses
- ERP routes → Login and sessions: provides context (evidence: `src/App.tsx`)
- ERP routes → Role route guard: routes through (evidence: `src/App.tsx`)
- ERP routes → ERP shell: wraps screens (evidence: `src/App.tsx`)
- Login and sessions → Operational records: loads users (evidence: `src/modules/auth/AuthContext.tsx`)
- Login and sessions → PIN security: verifies PIN (evidence: `src/modules/auth/AuthContext.tsx`)
- Operational records → PIN security: uses PIN helpers (evidence: `src/data/index.ts`)
- Operational records → Cloud synchronization: pushes changes (evidence: `src/data/index.ts`)
- Cloud synchronization → Supabase: uses client (evidence: `src/lib/supabaseSync.ts`)
- Raw material inward → Pulp mill batches: feeds traceability
- Pulp mill batches → Machine production: batch to rolls
- Machine production → Rewinder conversion: parent rolls
- Rewinder conversion → QC laboratory: reels for testing
- Rewinder conversion → Label studio: generates QR tags
- QC laboratory → Finished stock: grades stock
- Finished stock → Dispatch challans: allocates stock
- Customer orders → Dispatch challans: fulfills orders
- Spare parts store → Administration: supports oversight
- Dashboard analytics → Management reports: analytics capability
- Mill user → Utilities telemetry: logs shifts
- Mill user → ETP operations: logs compliance
- Mill user → Electricity logs: logs readings
