# esdurgadevi/rawmaterial architecture

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

- Interactive diagram: https://gitdiagram.com/esdurgadevi/rawmaterial
- Repository: https://github.com/esdurgadevi/rawmaterial

## Overview

This is a cotton and waste operations management application with a React admin interface and Express API. Users maintain reference masters, record cotton purchasing and inward lots, test and move lots, and issue/final-invoice cotton; separate workflows manage waste entry, packing, sales, and invoicing. A second admin area records spinning-process QC. The backend follows routed, authenticated controller/service/model layers over Sequelize. The graph captures documented routing and sampled service calls; links from the frontend to its HTTP API are omitted because the relevant request wiring was not shown.

Main entry points: [`backend/models/index.js`](https://github.com/esdurgadevi/rawmaterial/blob/main/backend/models/index.js) (Sequelize models), [`backend/app.js`](https://github.com/esdurgadevi/rawmaterial/blob/main/backend/app.js) (Express API), [`frontend/src/routes.jsx`](https://github.com/esdurgadevi/rawmaterial/blob/main/frontend/src/routes.jsx) (Admin navigation), [`backend/controllers/admin1/transaction-cotton`](https://github.com/esdurgadevi/rawmaterial/tree/main/backend/controllers/admin1/transaction-cotton) (Cotton transaction API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_front["Admin interface"]
  node_ui_routes["Admin navigation<br/>[routes.jsx]"]
  node_masters_ui["Master records<br/>[Supplier.jsx]"]
  node_cotton_ui["Cotton workflow screens"]
  node_waste_ui["Waste workflow screens<br/>[WasteEntryPage.jsx]"]
  node_qc_ui["QC screens<br/>[QCEntry.jsx]"]
end

subgraph group_api["API and access"]
  node_api_app["Express API<br/>[app.js]"]
  node_auth["Authentication<br/>[authService.js]"]
  node_auth_guard["Token protection<br/>[authMiddleware.js]"]
  node_masters_api["Master data API"]
  node_cotton_api["Cotton transaction API"]
  node_waste_api["Waste transaction API"]
  node_qc_api["QC transaction API"]
  node_masters_service["Master services"]
  node_db_models["Sequelize models<br/>[index.js]"]
  node_database[("SQL database<br/>[db.js]")]
  node_login_controller["Auth endpoints<br/>[authController.js]"]
end

subgraph group_cotton["Cotton operations"]
  node_cotton_service["Cotton services"]
  node_lot_testing["Lot test results"]
  node_final_invoice["Final invoicing"]
end

subgraph group_waste["Waste operations"]
  node_waste_service["Waste services"]
  node_waste_sales["Waste sales orders"]
end

subgraph group_qc["Spinning quality"]
  node_qc_service["QC services"]
  node_qc_entry["QC entry"]
end

node_staff(("Admin user"))

node_staff -->|"uses"| node_ui_routes
node_ui_routes -->|"routes to"| node_masters_ui
node_ui_routes -->|"routes to"| node_cotton_ui
node_ui_routes -->|"routes to"| node_waste_ui
node_ui_routes -->|"routes to"| node_qc_ui
node_staff -.->|"authenticates"| node_login_controller
node_api_app -->|"mounts auth"| node_login_controller
node_api_app -->|"mounts routes"| node_masters_api
node_api_app -->|"mounts routes"| node_cotton_api
node_api_app -->|"mounts routes"| node_waste_api
node_api_app -->|"mounts routes"| node_qc_api
node_masters_api -->|"protects routes"| node_auth_guard
node_cotton_api -->|"protects routes"| node_auth_guard
node_qc_api -->|"protects routes"| node_auth_guard
node_auth_guard -->|"verifies token"| node_auth
node_login_controller -->|"delegates to"| node_auth
node_masters_api -.->|"delegates to"| node_masters_service
node_cotton_api -->|"delegates to"| node_cotton_service
node_waste_api -->|"delegates to"| node_waste_service
node_qc_api -->|"delegates to"| node_qc_service
node_cotton_api -.->|"handles"| node_lot_testing
node_cotton_api -->|"handles"| node_final_invoice
node_waste_api -->|"handles"| node_waste_sales
node_qc_api -.->|"handles"| node_qc_entry
node_auth -->|"queries users"| node_db_models
node_cotton_service -->|"uses models"| node_db_models
node_waste_service -->|"uses models"| node_db_models
node_qc_service -->|"uses models"| node_db_models
node_masters_service -->|"uses models"| node_db_models
node_db_models -->|"initializes models"| node_database
node_lot_testing -->|"delegates to"| node_cotton_service
node_final_invoice -->|"delegates to"| node_cotton_service
node_waste_sales -->|"delegates to"| node_waste_service
node_qc_entry -->|"delegates to"| node_qc_service

click node_ui_routes "https://github.com/esdurgadevi/rawmaterial/blob/main/frontend/src/routes.jsx"
click node_masters_ui "https://github.com/esdurgadevi/rawmaterial/blob/main/frontend/src/pages/admin/Supplier.jsx"
click node_cotton_ui "https://github.com/esdurgadevi/rawmaterial/blob/main/frontend/src/pages/admin/InwardEntryManagement.jsx"
click node_waste_ui "https://github.com/esdurgadevi/rawmaterial/blob/main/frontend/src/pages/admin/WasteEntryPage.jsx"
click node_qc_ui "https://github.com/esdurgadevi/rawmaterial/blob/main/frontend/src/pages/admin2/QCEntry.jsx"
click node_api_app "https://github.com/esdurgadevi/rawmaterial/blob/main/backend/app.js"
click node_auth "https://github.com/esdurgadevi/rawmaterial/blob/main/backend/services/auth/authService.js"
click node_auth_guard "https://github.com/esdurgadevi/rawmaterial/blob/main/backend/middlewares/authMiddleware.js"
click node_masters_api "https://github.com/esdurgadevi/rawmaterial/tree/main/backend/controllers/admin1/master"
click node_cotton_api "https://github.com/esdurgadevi/rawmaterial/tree/main/backend/controllers/admin1/transaction-cotton"
click node_waste_api "https://github.com/esdurgadevi/rawmaterial/tree/main/backend/controllers/admin1/transaction-waste"
click node_qc_api "https://github.com/esdurgadevi/rawmaterial/tree/main/backend/controllers/admin2/transaction-qc"
click node_masters_service "https://github.com/esdurgadevi/rawmaterial/tree/main/backend/services/admin1/master"
click node_cotton_service "https://github.com/esdurgadevi/rawmaterial/tree/main/backend/services/admin1/transaction-cotton"
click node_waste_service "https://github.com/esdurgadevi/rawmaterial/tree/main/backend/services/admin1/transaction-waste"
click node_qc_service "https://github.com/esdurgadevi/rawmaterial/tree/main/backend/services/admin2/transaction-qc"
click node_db_models "https://github.com/esdurgadevi/rawmaterial/blob/main/backend/models/index.js"
click node_database "https://github.com/esdurgadevi/rawmaterial/blob/main/backend/config/db.js"
click node_login_controller "https://github.com/esdurgadevi/rawmaterial/blob/main/backend/controllers/auth/authController.js"
click node_lot_testing "https://github.com/esdurgadevi/rawmaterial/blob/main/backend/controllers/admin1/transaction-cotton/lotTestResultController.js"
click node_final_invoice "https://github.com/esdurgadevi/rawmaterial/blob/main/backend/controllers/admin1/transaction-cotton/finalInvoiceController.js"
click node_waste_sales "https://github.com/esdurgadevi/rawmaterial/blob/main/backend/controllers/admin1/transaction-waste/salesOrderController.js"
click node_qc_entry "https://github.com/esdurgadevi/rawmaterial/blob/main/backend/controllers/admin2/transaction-qc/qcEntryController.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_ui_routes,node_masters_ui,node_cotton_ui,node_waste_ui,node_qc_ui,node_staff toneBlue
class node_api_app,node_auth,node_auth_guard,node_masters_api,node_cotton_api,node_waste_api,node_qc_api,node_masters_service,node_db_models,node_database,node_login_controller toneAmber
class node_cotton_service,node_lot_testing,node_final_invoice toneMint
class node_waste_service,node_waste_sales toneRose
class node_qc_service,node_qc_entry toneIndigo
```

## Components

### Admin interface

- [Admin navigation](https://github.com/esdurgadevi/rawmaterial/blob/main/frontend/src/routes.jsx): `frontend/src/routes.jsx`
- [Master records](https://github.com/esdurgadevi/rawmaterial/blob/main/frontend/src/pages/admin/Supplier.jsx): `frontend/src/pages/admin/Supplier.jsx`
- [Cotton workflow screens](https://github.com/esdurgadevi/rawmaterial/blob/main/frontend/src/pages/admin/InwardEntryManagement.jsx): `frontend/src/pages/admin/InwardEntryManagement.jsx`
- [Waste workflow screens](https://github.com/esdurgadevi/rawmaterial/blob/main/frontend/src/pages/admin/WasteEntryPage.jsx): `frontend/src/pages/admin/WasteEntryPage.jsx`
- [QC screens](https://github.com/esdurgadevi/rawmaterial/blob/main/frontend/src/pages/admin2/QCEntry.jsx): `frontend/src/pages/admin2/QCEntry.jsx`

### API and access

- [Express API](https://github.com/esdurgadevi/rawmaterial/blob/main/backend/app.js): `backend/app.js`
- [Authentication](https://github.com/esdurgadevi/rawmaterial/blob/main/backend/services/auth/authService.js): `backend/services/auth/authService.js`
- [Token protection](https://github.com/esdurgadevi/rawmaterial/blob/main/backend/middlewares/authMiddleware.js): `backend/middlewares/authMiddleware.js`
- [Master data API](https://github.com/esdurgadevi/rawmaterial/tree/main/backend/controllers/admin1/master): `backend/controllers/admin1/master`
- [Cotton transaction API](https://github.com/esdurgadevi/rawmaterial/tree/main/backend/controllers/admin1/transaction-cotton): `backend/controllers/admin1/transaction-cotton`
- [Waste transaction API](https://github.com/esdurgadevi/rawmaterial/tree/main/backend/controllers/admin1/transaction-waste): `backend/controllers/admin1/transaction-waste`
- [QC transaction API](https://github.com/esdurgadevi/rawmaterial/tree/main/backend/controllers/admin2/transaction-qc): `backend/controllers/admin2/transaction-qc`
- [Master services](https://github.com/esdurgadevi/rawmaterial/tree/main/backend/services/admin1/master): `backend/services/admin1/master`
- [Sequelize models](https://github.com/esdurgadevi/rawmaterial/blob/main/backend/models/index.js): `backend/models/index.js`
- [SQL database](https://github.com/esdurgadevi/rawmaterial/blob/main/backend/config/db.js): `backend/config/db.js`
- [Auth endpoints](https://github.com/esdurgadevi/rawmaterial/blob/main/backend/controllers/auth/authController.js): `backend/controllers/auth/authController.js`

### Cotton operations

- [Cotton services](https://github.com/esdurgadevi/rawmaterial/tree/main/backend/services/admin1/transaction-cotton): `backend/services/admin1/transaction-cotton`
- [Lot test results](https://github.com/esdurgadevi/rawmaterial/blob/main/backend/controllers/admin1/transaction-cotton/lotTestResultController.js): `backend/controllers/admin1/transaction-cotton/lotTestResultController.js`
- [Final invoicing](https://github.com/esdurgadevi/rawmaterial/blob/main/backend/controllers/admin1/transaction-cotton/finalInvoiceController.js): `backend/controllers/admin1/transaction-cotton/finalInvoiceController.js`

### Waste operations

- [Waste services](https://github.com/esdurgadevi/rawmaterial/tree/main/backend/services/admin1/transaction-waste): `backend/services/admin1/transaction-waste`
- [Waste sales orders](https://github.com/esdurgadevi/rawmaterial/blob/main/backend/controllers/admin1/transaction-waste/salesOrderController.js): `backend/controllers/admin1/transaction-waste/salesOrderController.js`

### Spinning quality

- [QC services](https://github.com/esdurgadevi/rawmaterial/tree/main/backend/services/admin2/transaction-qc): `backend/services/admin2/transaction-qc`
- [QC entry](https://github.com/esdurgadevi/rawmaterial/blob/main/backend/controllers/admin2/transaction-qc/qcEntryController.js): `backend/controllers/admin2/transaction-qc/qcEntryController.js`

### Other components

- **Admin user**

## Connections

- Admin user → Admin navigation: uses (evidence: `frontend/src/routes.jsx`)
- Admin navigation → Master records: routes to (evidence: `frontend/src/routes.jsx`)
- Admin navigation → Cotton workflow screens: routes to (evidence: `frontend/src/routes.jsx`)
- Admin navigation → Waste workflow screens: routes to (evidence: `frontend/src/routes.jsx`)
- Admin navigation → QC screens: routes to (evidence: `frontend/src/routes.jsx`)
- Admin user → Auth endpoints: authenticates
- Express API → Auth endpoints: mounts auth (evidence: `backend/app.js`)
- Express API → Master data API: mounts routes (evidence: `backend/app.js`)
- Express API → Cotton transaction API: mounts routes (evidence: `backend/app.js`)
- Express API → Waste transaction API: mounts routes (evidence: `backend/app.js`)
- Express API → QC transaction API: mounts routes (evidence: `backend/app.js`)
- Master data API → Token protection: protects routes (evidence: `backend/routes/admin1/master/stationRoutes.js`)
- Cotton transaction API → Token protection: protects routes (evidence: `backend/routes/admin1/transaction-cotton/lotTestResultRoutes.js`)
- QC transaction API → Token protection: protects routes (evidence: `backend/routes/admin2/transaction-qc/qcEntryRoutes.js`)
- Token protection → Authentication: verifies token (evidence: `backend/middlewares/authMiddleware.js`)
- Auth endpoints → Authentication: delegates to (evidence: `backend/controllers/auth/authController.js`)
- Master data API → Master services: delegates to (evidence: `backend/controllers/admin1/master/companyBrokerController.js`)
- Cotton transaction API → Cotton services: delegates to (evidence: `backend/controllers/admin1/transaction-cotton/finalInvoiceController.js`)
- Waste transaction API → Waste services: delegates to (evidence: `backend/controllers/admin1/transaction-waste/salesOrderController.js`)
- QC transaction API → QC services: delegates to (evidence: `backend/controllers/admin2/transaction-qc/qcEntryController.js`)
- Cotton transaction API → Lot test results: handles
- Cotton transaction API → Final invoicing: handles (evidence: `backend/controllers/admin1/transaction-cotton/finalInvoiceController.js`)
- Waste transaction API → Waste sales orders: handles (evidence: `backend/controllers/admin1/transaction-waste/salesOrderController.js`)
- QC transaction API → QC entry: handles
- Authentication → Sequelize models: queries users (evidence: `backend/services/auth/authService.js`)
- Cotton services → Sequelize models: uses models (evidence: `backend/services/admin1/transaction-cotton/inwardLotService.js`)
- Waste services → Sequelize models: uses models (evidence: `backend/services/admin1/transaction-waste/salesOrderService.js`)
- QC services → Sequelize models: uses models (evidence: `backend/services/admin2/transaction-qc/qcEntryService.js`)
- Master services → Sequelize models: uses models (evidence: `backend/services/admin1/master/supplierService.js`)
- Sequelize models → SQL database: initializes models (evidence: `backend/models/index.js`)
- Lot test results → Cotton services: delegates to (evidence: `backend/controllers/admin1/transaction-cotton/lotTestResultController.js`)
- Final invoicing → Cotton services: delegates to (evidence: `backend/controllers/admin1/transaction-cotton/finalInvoiceController.js`)
- Waste sales orders → Waste services: delegates to (evidence: `backend/controllers/admin1/transaction-waste/salesOrderController.js`)
- QC entry → QC services: delegates to (evidence: `backend/controllers/admin2/transaction-qc/qcEntryController.js`)
