# shubhamshubham66/textile_manufacturing_platform architecture

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

- Interactive diagram: https://gitdiagram.com/shubhamshubham66/textile_manufacturing_platform
- Repository: https://github.com/shubhamshubham66/textile_manufacturing_platform

## Overview

Everest Textile Mills is a web platform for managing textile-factory operations. The implemented workflow runs from role-aware sign-in to order, yarn, and production screens, whose API requests are served by FastAPI and persisted through SQLAlchemy models. Production tracks machine assignments, status, output, and idle-loss costs. The README also describes quality, dispatch, finance, reporting, buyer, and AI capabilities; several are planned rather than present in the sampled implementation. Connections for those capabilities are documented, not verified in source.

Main entry points: [`backend/app/models.py`](https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/backend/app/models.py) (Factory data models), [`frontend/src/lib/api.js`](https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/frontend/src/lib/api.js) (API client), [`backend/app/database.py`](https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/backend/app/database.py) (Database sessions), [`frontend/src/pages/AppShell.jsx`](https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/frontend/src/pages/AppShell.jsx) (Role-based shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app_entry["App routing<br/>[App.jsx]"]
  node_auth_ui["Session and login<br/>[AuthContext.jsx]"]
  node_shell["Role-based shell<br/>[AppShell.jsx]"]
  node_api_client["API client<br/>[api.js]"]
end

subgraph group_operations["Factory operations"]
  node_orders_ui["Orders screen<br/>[Orders.jsx]"]
  node_yarn_ui["Yarn screens<br/>[YarnStore.jsx]"]
  node_purchase_ui["Purchase screen<br/>[Purchase.jsx]"]
  node_machines_ui["Machine screen<br/>[Machines.jsx]"]
  node_production_ui["Production screen<br/>[Production.jsx]"]
end

subgraph group_platform["API and platform"]
  node_api_app["FastAPI entry<br/>[main.py]"]
  node_auth_api["Authentication API<br/>[auth.py]"]
  node_orders_api["Orders API<br/>[orders.py]"]
  node_yarn_api["Yarn API<br/>[yarn.py]"]
  node_production_api["Production API<br/>[production.py]"]
  node_access["Token and access checks<br/>[deps.py]"]
  node_rbac["Role permissions<br/>[rbac.py]"]
  node_security["JWT and passwords<br/>[security.py]"]
  node_models["Factory data models<br/>[models.py]"]
  node_database[("Database sessions<br/>[database.py]")]
  node_config["Runtime settings<br/>[config.py]"]
  node_production_service["Production calculations<br/>[production.py]"]
end

subgraph group_planned["Documented capabilities"]
  node_quality["Quality inspection"]
  node_dispatch["Dispatch and invoices"]
  node_finance["Payments and wages"]
  node_reports["Owner reports"]
  node_buyer["Buyer order portal"]
  node_ai_ui["AI assistant UI<br/>[ChatBubble.jsx]"]
  node_ai_backend["Chatbot endpoint"]
end

node_staff(("Factory users"))
node_dify["Dify service"]

node_staff -->|"uses"| node_app_entry
node_app_entry -->|"reads session"| node_auth_ui
node_app_entry -->|"routes signed-in users"| node_shell
node_auth_ui -->|"requests auth"| node_api_client
node_shell -->|"selects page"| node_orders_ui
node_shell -->|"selects page"| node_yarn_ui
node_shell -->|"selects page"| node_purchase_ui
node_shell -->|"selects page"| node_machines_ui
node_shell -->|"selects page"| node_production_ui
node_orders_ui -->|"requests data"| node_api_client
node_yarn_ui -->|"requests data"| node_api_client
node_purchase_ui -->|"requests data"| node_api_client
node_machines_ui -->|"requests data"| node_api_client
node_production_ui -->|"requests data"| node_api_client
node_api_client -->|"calls /api"| node_api_app
node_api_app -->|"registers router"| node_auth_api
node_api_app -->|"registers router"| node_orders_api
node_api_app -->|"registers router"| node_yarn_api
node_api_app -->|"registers router"| node_production_api
node_auth_api -->|"verifies and signs"| node_security
node_auth_api -->|"builds role menu"| node_rbac
node_auth_api -->|"opens session"| node_database
node_auth_api -->|"queries users"| node_models
node_access -->|"decodes token"| node_security
node_access -->|"checks permissions"| node_rbac
node_access -->|"opens session"| node_database
node_access -->|"loads user"| node_models
node_orders_api -->|"uses sessions"| node_database
node_orders_api -->|"queries models"| node_models
node_yarn_api -->|"uses sessions"| node_database
node_yarn_api -->|"queries models"| node_models
node_production_api -->|"uses sessions"| node_database
node_production_api -->|"reads and writes"| node_models
node_production_api -->|"calculates durations"| node_production_service
node_models -->|"uses declarative base"| node_database
node_database -->|"reads database URL"| node_config
node_quality -.->|"records inspection data"| node_models
node_dispatch -.->|"documents dispatch data"| node_models
node_finance -.->|"documents finance data"| node_models
node_reports -.->|"documents reporting data"| node_models
node_buyer -.->|"tracks orders"| node_orders_api
node_ai_ui -.->|"sends chat"| node_ai_backend
node_ai_backend -.->|"calls API"| node_dify

click node_app_entry "https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/frontend/src/App.jsx"
click node_auth_ui "https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/frontend/src/auth/AuthContext.jsx"
click node_shell "https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/frontend/src/pages/AppShell.jsx"
click node_api_client "https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/frontend/src/lib/api.js"
click node_orders_ui "https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/frontend/src/pages/app/Orders.jsx"
click node_yarn_ui "https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/frontend/src/pages/app/YarnStore.jsx"
click node_purchase_ui "https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/frontend/src/pages/app/Purchase.jsx"
click node_machines_ui "https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/frontend/src/pages/app/Machines.jsx"
click node_production_ui "https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/frontend/src/pages/app/Production.jsx"
click node_api_app "https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/backend/app/main.py"
click node_auth_api "https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/backend/app/routers/auth.py"
click node_orders_api "https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/backend/app/routers/orders.py"
click node_yarn_api "https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/backend/app/routers/yarn.py"
click node_production_api "https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/backend/app/routers/production.py"
click node_access "https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/backend/app/deps.py"
click node_rbac "https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/backend/app/rbac.py"
click node_security "https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/backend/app/security.py"
click node_models "https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/backend/app/models.py"
click node_database "https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/backend/app/database.py"
click node_config "https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/backend/app/config.py"
click node_production_service "https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/backend/app/services/production.py"
click node_quality "https://github.com/shubhamshubham66/textile_manufacturing_platform/tree/main/backend/app/routers"
click node_dispatch "https://github.com/shubhamshubham66/textile_manufacturing_platform/tree/main/backend/app/routers"
click node_finance "https://github.com/shubhamshubham66/textile_manufacturing_platform/tree/main/backend/app/routers"
click node_reports "https://github.com/shubhamshubham66/textile_manufacturing_platform/tree/main/backend/app/routers"
click node_buyer "https://github.com/shubhamshubham66/textile_manufacturing_platform/tree/main/backend/app/routers"
click node_ai_ui "https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/frontend/src/components/ChatBubble.jsx"
click node_ai_backend "https://github.com/shubhamshubham66/textile_manufacturing_platform/tree/main/backend/app"

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_entry,node_auth_ui,node_shell,node_api_client,node_staff toneBlue
class node_orders_ui,node_yarn_ui,node_purchase_ui,node_machines_ui,node_production_ui toneAmber
class node_api_app,node_auth_api,node_orders_api,node_yarn_api,node_production_api,node_access,node_rbac,node_security,node_models,node_database,node_config,node_production_service toneMint
class node_quality,node_dispatch,node_finance,node_reports,node_buyer,node_ai_ui,node_ai_backend toneRose
class node_dify toneIndigo
```

## Components

### Web application

- [App routing](https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Session and login](https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/frontend/src/auth/AuthContext.jsx): `frontend/src/auth/AuthContext.jsx`
- [Role-based shell](https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/frontend/src/pages/AppShell.jsx): `frontend/src/pages/AppShell.jsx`
- [API client](https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/frontend/src/lib/api.js): `frontend/src/lib/api.js`

### Factory operations

- [Orders screen](https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/frontend/src/pages/app/Orders.jsx): `frontend/src/pages/app/Orders.jsx`
- [Yarn screens](https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/frontend/src/pages/app/YarnStore.jsx): `frontend/src/pages/app/YarnStore.jsx`
- [Purchase screen](https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/frontend/src/pages/app/Purchase.jsx): `frontend/src/pages/app/Purchase.jsx`
- [Machine screen](https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/frontend/src/pages/app/Machines.jsx): `frontend/src/pages/app/Machines.jsx`
- [Production screen](https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/frontend/src/pages/app/Production.jsx): `frontend/src/pages/app/Production.jsx`

### API and platform

- [FastAPI entry](https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication API](https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/backend/app/routers/auth.py): `backend/app/routers/auth.py`
- [Orders API](https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/backend/app/routers/orders.py): `backend/app/routers/orders.py`
- [Yarn API](https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/backend/app/routers/yarn.py): `backend/app/routers/yarn.py`
- [Production API](https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/backend/app/routers/production.py): `backend/app/routers/production.py`
- [Token and access checks](https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/backend/app/deps.py): `backend/app/deps.py`
- [Role permissions](https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/backend/app/rbac.py): `backend/app/rbac.py`
- [JWT and passwords](https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/backend/app/security.py): `backend/app/security.py`
- [Factory data models](https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/backend/app/models.py): `backend/app/models.py`
- [Database sessions](https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/backend/app/database.py): `backend/app/database.py`
- [Runtime settings](https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/backend/app/config.py): `backend/app/config.py`
- [Production calculations](https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/backend/app/services/production.py): `backend/app/services/production.py`

### Documented capabilities

- [Quality inspection](https://github.com/shubhamshubham66/textile_manufacturing_platform/tree/main/backend/app/routers): `backend/app/routers`
- [Dispatch and invoices](https://github.com/shubhamshubham66/textile_manufacturing_platform/tree/main/backend/app/routers): `backend/app/routers`
- [Payments and wages](https://github.com/shubhamshubham66/textile_manufacturing_platform/tree/main/backend/app/routers): `backend/app/routers`
- [Owner reports](https://github.com/shubhamshubham66/textile_manufacturing_platform/tree/main/backend/app/routers): `backend/app/routers`
- [Buyer order portal](https://github.com/shubhamshubham66/textile_manufacturing_platform/tree/main/backend/app/routers): `backend/app/routers`
- [AI assistant UI](https://github.com/shubhamshubham66/textile_manufacturing_platform/blob/main/frontend/src/components/ChatBubble.jsx): `frontend/src/components/ChatBubble.jsx`
- [Chatbot endpoint](https://github.com/shubhamshubham66/textile_manufacturing_platform/tree/main/backend/app): `backend/app`

### Other components

- **Factory users**
- **Dify service**

## Connections

- Factory users → App routing: uses (evidence: `frontend/src/App.jsx`)
- App routing → Session and login: reads session (evidence: `frontend/src/App.jsx`)
- App routing → Role-based shell: routes signed-in users (evidence: `frontend/src/App.jsx`)
- Session and login → API client: requests auth (evidence: `frontend/src/auth/AuthContext.jsx`)
- Role-based shell → Orders screen: selects page (evidence: `frontend/src/pages/AppShell.jsx`)
- Role-based shell → Yarn screens: selects page (evidence: `frontend/src/pages/AppShell.jsx`)
- Role-based shell → Purchase screen: selects page (evidence: `frontend/src/pages/AppShell.jsx`)
- Role-based shell → Machine screen: selects page (evidence: `frontend/src/pages/AppShell.jsx`)
- Role-based shell → Production screen: selects page (evidence: `frontend/src/pages/AppShell.jsx`)
- Orders screen → API client: requests data (evidence: `frontend/src/pages/app/Orders.jsx`)
- Yarn screens → API client: requests data (evidence: `frontend/src/pages/app/YarnStore.jsx`)
- Purchase screen → API client: requests data (evidence: `frontend/src/pages/app/Purchase.jsx`)
- Machine screen → API client: requests data (evidence: `frontend/src/pages/app/Machines.jsx`)
- Production screen → API client: requests data (evidence: `frontend/src/pages/app/Production.jsx`)
- API client → FastAPI entry: calls /api (evidence: `README.md`)
- FastAPI entry → Authentication API: registers router (evidence: `backend/app/main.py`)
- FastAPI entry → Orders API: registers router (evidence: `backend/app/main.py`)
- FastAPI entry → Yarn API: registers router (evidence: `backend/app/main.py`)
- FastAPI entry → Production API: registers router (evidence: `backend/app/main.py`)
- Authentication API → JWT and passwords: verifies and signs (evidence: `backend/app/routers/auth.py`)
- Authentication API → Role permissions: builds role menu (evidence: `backend/app/routers/auth.py`)
- Authentication API → Database sessions: opens session (evidence: `backend/app/routers/auth.py`)
- Authentication API → Factory data models: queries users (evidence: `backend/app/routers/auth.py`)
- Token and access checks → JWT and passwords: decodes token (evidence: `backend/app/deps.py`)
- Token and access checks → Role permissions: checks permissions (evidence: `backend/app/deps.py`)
- Token and access checks → Database sessions: opens session (evidence: `backend/app/deps.py`)
- Token and access checks → Factory data models: loads user (evidence: `backend/app/deps.py`)
- Orders API → Database sessions: uses sessions (evidence: `backend/app/routers/orders.py`)
- Orders API → Factory data models: queries models (evidence: `backend/app/routers/orders.py`)
- Yarn API → Database sessions: uses sessions (evidence: `backend/app/routers/yarn.py`)
- Yarn API → Factory data models: queries models (evidence: `backend/app/routers/yarn.py`)
- Production API → Database sessions: uses sessions (evidence: `backend/app/routers/production.py`)
- Production API → Factory data models: reads and writes (evidence: `backend/app/routers/production.py`)
- Production API → Production calculations: calculates durations (evidence: `backend/app/routers/production.py`)
- Factory data models → Database sessions: uses declarative base (evidence: `backend/app/models.py`)
- Database sessions → Runtime settings: reads database URL (evidence: `backend/app/database.py`)
- Quality inspection → Factory data models: records inspection data (evidence: `README.md`)
- Dispatch and invoices → Factory data models: documents dispatch data (evidence: `README.md`)
- Payments and wages → Factory data models: documents finance data (evidence: `README.md`)
- Owner reports → Factory data models: documents reporting data (evidence: `README.md`)
- Buyer order portal → Orders API: tracks orders (evidence: `README.md`)
- AI assistant UI → Chatbot endpoint: sends chat (evidence: `README.md`)
- Chatbot endpoint → Dify service: calls API (evidence: `README.md`)
