# gowthamabi/garment-fabric-cutting-mern architecture

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

- Interactive diagram: https://gitdiagram.com/gowthamabi/garment-fabric-cutting-mern
- Repository: https://github.com/gowthamabi/garment-fabric-cutting-mern

## Overview

UG SaaS is a multi-tenant manufacturing and retail ERP, with an integrated accounting and SaaS administration layer. Users authenticate into company workspaces, then work through department or ERP screens; requests pass through API routes and controllers to tenant-scoped operational records and posting logic. The principal operational workflow covers purchasing and inward receipt, production and stock movement, sales/dispatch, and finance/reporting. The README also documents approvals, automation, workforce, bank reconciliation, and tenant backup capabilities. Some subsystems are represented by documented capabilities and tree paths; their internal calls are not shown.

Main entry points: [`client/src/api.js`](https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/client/src/api.js) (API client), [`server/src/erp/departmentRoutes.js`](https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/erp/departmentRoutes.js) (Department API), [`server/src/erp/models.js`](https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/erp/models.js) (ERP records), [`server/src/models/Company.js`](https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/models/Company.js) (Company workspace)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_client["ERP client<br/>[App.jsx]"]
  node_routes["Page routing<br/>[AppRoutes.jsx]"]
  node_departments["Department workspace<br/>[Departments.jsx]"]
  node_api["API client<br/>[api.js]"]
end

subgraph group_operations["Manufacturing operations"]
  node_purchasing["Purchase orders"]
  node_inward["Goods receipt"]
  node_fabric["Fabric cutting"]
  node_production["Production control"]
  node_outward["Dispatch and sales"]
  node_delivery["Delivery workflow"]
end

subgraph group_erp["Integrated ERP"]
  node_erpworkspace["ERP workspace<br/>[ErpWorkspace.jsx]"]
  node_departmentroutes["Department API"]
  node_posting["Document posting<br/>[engine.js]"]
  node_erpmodels[("ERP records<br/>[models.js]")]
  node_erpfeatures["Finance and controls"]
  node_reports["ERP reporting<br/>[reports.js]"]
end

subgraph group_platform["Tenant platform"]
  node_tenant[("Tenant database<br/>[tenantDatabase.js]")]
  node_company[("Company workspace<br/>[Company.js]")]
  node_access["Access administration<br/>[access.routes.js]"]
  node_saas["Plans and onboarding<br/>[saasController.js]"]
end

subgraph group_automation["Billing automation"]
  node_automation["Payment automation<br/>[routes.js]"]
  node_worker["Automation worker<br/>[worker.js]"]
  node_billing[("Billing records<br/>[models.js]")]
end

node_user(("Company user"))
node_external(("Payment provider"))

node_user -->|"uses"| node_client
node_client -->|"renders"| node_routes
node_routes -->|"routes to"| node_departments
node_departments -->|"requests data"| node_api
node_erpworkspace -.->|"requests data"| node_api
node_api -.->|"calls API"| node_purchasing
node_api -.->|"calls API"| node_inward
node_api -.->|"calls API"| node_fabric
node_api -.->|"calls API"| node_production
node_api -.->|"calls API"| node_outward
node_api -.->|"calls API"| node_delivery
node_api -.->|"calls API"| node_departmentroutes
node_departmentroutes -.->|"uses rules"| node_posting
node_departmentroutes -->|"writes records"| node_erpmodels
node_posting -.->|"plans documents"| node_erpmodels
node_erpworkspace -->|"offers"| node_erpfeatures
node_erpfeatures -.->|"reports through"| node_reports
node_erpmodels -->|"resolves database"| node_tenant
node_company -->|"uses tenant model"| node_tenant
node_access -->|"reads company"| node_company
node_access -.->|"resolves models"| node_tenant
node_saas -.->|"provisions workspace"| node_company
node_saas -->|"settles subscription"| node_billing
node_automation -->|"reads billing"| node_billing
node_automation -.->|"verifies payment"| node_external
node_worker -.->|"processes jobs"| node_billing

click node_client "https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/client/src/App.jsx"
click node_routes "https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/client/src/routes/AppRoutes.jsx"
click node_departments "https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/client/src/pages/erp/Departments.jsx"
click node_api "https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/client/src/api.js"
click node_purchasing "https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/controllers/purchaseOrderController.js"
click node_inward "https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/controllers/inwardController.js"
click node_fabric "https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/controllers/fabricCuttingController.js"
click node_production "https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/controllers/productionController.js"
click node_outward "https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/controllers/outwardController.js"
click node_delivery "https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/controllers/deliveryController.js"
click node_erpworkspace "https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/client/src/pages/erp/ErpWorkspace.jsx"
click node_departmentroutes "https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/erp/departmentRoutes.js"
click node_posting "https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/erp/engine.js"
click node_erpmodels "https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/erp/models.js"
click node_erpfeatures "https://github.com/gowthamabi/garment-fabric-cutting-mern/tree/main/server/src/erp"
click node_reports "https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/erp/reports.js"
click node_tenant "https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/config/tenantDatabase.js"
click node_company "https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/models/Company.js"
click node_access "https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/routes/access.routes.js"
click node_saas "https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/controllers/saasController.js"
click node_automation "https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/automation/routes.js"
click node_worker "https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/automation/worker.js"
click node_billing "https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/automation/models.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_client,node_routes,node_departments,node_api,node_user toneBlue
class node_purchasing,node_inward,node_fabric,node_production,node_outward,node_delivery toneAmber
class node_erpworkspace,node_departmentroutes,node_posting,node_erpmodels,node_erpfeatures,node_reports toneMint
class node_tenant,node_company,node_access,node_saas toneRose
class node_automation,node_worker,node_billing,node_external toneIndigo
```

## Components

### User experience

- [ERP client](https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Page routing](https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/client/src/routes/AppRoutes.jsx): `client/src/routes/AppRoutes.jsx`
- [Department workspace](https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/client/src/pages/erp/Departments.jsx): `client/src/pages/erp/Departments.jsx`
- [API client](https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/client/src/api.js): `client/src/api.js`

### Manufacturing operations

- [Purchase orders](https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/controllers/purchaseOrderController.js): `server/src/controllers/purchaseOrderController.js`
- [Goods receipt](https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/controllers/inwardController.js): `server/src/controllers/inwardController.js`
- [Fabric cutting](https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/controllers/fabricCuttingController.js): `server/src/controllers/fabricCuttingController.js`
- [Production control](https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/controllers/productionController.js): `server/src/controllers/productionController.js`
- [Dispatch and sales](https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/controllers/outwardController.js): `server/src/controllers/outwardController.js`
- [Delivery workflow](https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/controllers/deliveryController.js): `server/src/controllers/deliveryController.js`

### Integrated ERP

- [ERP workspace](https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/client/src/pages/erp/ErpWorkspace.jsx): `client/src/pages/erp/ErpWorkspace.jsx`
- [Department API](https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/erp/departmentRoutes.js): `server/src/erp/departmentRoutes.js`
- [Document posting](https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/erp/engine.js): `server/src/erp/engine.js`
- [ERP records](https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/erp/models.js): `server/src/erp/models.js`
- [Finance and controls](https://github.com/gowthamabi/garment-fabric-cutting-mern/tree/main/server/src/erp): `server/src/erp`
- [ERP reporting](https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/erp/reports.js): `server/src/erp/reports.js`

### Tenant platform

- [Tenant database](https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/config/tenantDatabase.js): `server/src/config/tenantDatabase.js`
- [Company workspace](https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/models/Company.js): `server/src/models/Company.js`
- [Access administration](https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/routes/access.routes.js): `server/src/routes/access.routes.js`
- [Plans and onboarding](https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/controllers/saasController.js): `server/src/controllers/saasController.js`

### Billing automation

- [Payment automation](https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/automation/routes.js): `server/src/automation/routes.js`
- [Automation worker](https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/automation/worker.js): `server/src/automation/worker.js`
- [Billing records](https://github.com/gowthamabi/garment-fabric-cutting-mern/blob/main/server/src/automation/models.js): `server/src/automation/models.js`

### Other components

- **Company user**
- **Payment provider**

## Connections

- Company user → ERP client: uses (evidence: `client/src/App.jsx`)
- ERP client → Page routing: renders (evidence: `client/src/App.jsx`)
- Page routing → Department workspace: routes to (evidence: `client/src/routes/AppRoutes.jsx`)
- Department workspace → API client: requests data (evidence: `client/src/pages/erp/Departments.jsx`)
- ERP workspace → API client: requests data
- API client → Purchase orders: calls API
- API client → Goods receipt: calls API
- API client → Fabric cutting: calls API
- API client → Production control: calls API
- API client → Dispatch and sales: calls API
- API client → Delivery workflow: calls API
- API client → Department API: calls API
- Department API → Document posting: uses rules
- Department API → ERP records: writes records (evidence: `server/src/erp/departmentRoutes.js`)
- Document posting → ERP records: plans documents
- ERP workspace → Finance and controls: offers
- Finance and controls → ERP reporting: reports through (evidence: `server/src/erp/routes.js`)
- ERP records → Tenant database: resolves database (evidence: `server/src/erp/models.js`)
- Company workspace → Tenant database: uses tenant model (evidence: `server/src/models/Company.js`)
- Access administration → Company workspace: reads company (evidence: `server/src/routes/access.routes.js`)
- Access administration → Tenant database: resolves models
- Plans and onboarding → Company workspace: provisions workspace (evidence: `server/src/controllers/saasController.js`)
- Plans and onboarding → Billing records: settles subscription (evidence: `server/src/controllers/saasController.js`)
- Payment automation → Billing records: reads billing (evidence: `server/src/automation/routes.js`)
- Payment automation → Payment provider: verifies payment
- Automation worker → Billing records: processes jobs
