# arunkumar262004/erp architecture

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

- Interactive diagram: https://gitdiagram.com/arunkumar262004/erp
- Repository: https://github.com/arunkumar262004/erp

## Overview

This is a garment-manufacturing ERP: staff sign in to a React SPA, work across CRM, accounts, purchasing, inventory, production, and delivery, and review operational dashboards and reports. The SPA calls a Laravel API backed by MySQL. Production stages are tracked individually; the API can create delivery records when quality-check work is marked delivered. The README documents the main capabilities, while sampled source verifies dashboard aggregation, frontend routing, API configuration, and this production-to-delivery behavior; unsampled module internals are represented at directory level.

Main entry points: [`backend/routes/api.php`](https://github.com/arunkumar262004/erp/blob/main/backend/routes/api.php) (Laravel API), [`frontend/src/App.tsx`](https://github.com/arunkumar262004/erp/blob/main/frontend/src/App.tsx) (ERP workspace), [`frontend/src/api/client.ts`](https://github.com/arunkumar262004/erp/blob/main/frontend/src/api/client.ts) (API client), [`backend/app/Events/QuotationApproved.php`](https://github.com/arunkumar262004/erp/blob/main/backend/app/Events/QuotationApproved.php) (Approval event)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["ERP frontend"]
  node_spa["ERP workspace<br/>[App.tsx]"]
  node_auth["Session and access<br/>[AuthContext.tsx]"]
  node_api_client["API client<br/>[client.ts]"]
  node_dashboard_ui["Dashboard view<br/>[DashboardPage.tsx]"]
  node_crm_ui["CRM workspace"]
  node_accounts_ui["Accounts workspace"]
  node_production_ui["Production workspace"]
  node_purchase_ui["Purchase workspace"]
  node_delivery_ui["Delivery tracking"]
  node_reports_ui["Reports view<br/>[ReportsPage.tsx]"]
end

subgraph group_commercial["Customer and accounts"]
  node_contacts["Contacts<br/>[Contact.php]"]
  node_crm["Leads and tasks<br/>[Lead.php]"]
  node_accounts["Quotations and billing<br/>[Quotation.php]"]
end

subgraph group_operations["Manufacturing operations"]
  node_inventory["Products and materials<br/>[RawMaterial.php]"]
  node_purchasing["Suppliers and orders<br/>[PurchaseOrder.php]"]
  node_production["Production stages"]
  node_delivery["Dispatch records<br/>[Delivery.php]"]
end

subgraph group_backend["API and reporting"]
  node_api["Laravel API<br/>[api.php]"]
  node_dashboard["Dashboard aggregation"]
  node_reports["Module reports"]
  node_database[("MySQL data<br/>[database.php]")]
end

subgraph group_integrations["Notifications"]
  node_quotation_event["Approval event"]
  node_webhook_job["Webhook dispatch<br/>[SendN8nWebhook.php]"]
  node_email["Approval email"]
end

node_staff(("ERP staff"))
node_n8n(("n8n service"))

node_staff -->|"uses"| node_spa
node_spa -->|"protects routes"| node_auth
node_spa -->|"routes to"| node_dashboard_ui
node_spa -->|"routes to"| node_crm_ui
node_spa -->|"routes to"| node_accounts_ui
node_spa -->|"routes to"| node_production_ui
node_spa -->|"routes to"| node_purchase_ui
node_spa -->|"routes to"| node_delivery_ui
node_spa -->|"routes to"| node_reports_ui
node_auth -->|"uses"| node_api_client
node_dashboard_ui -->|"loads dashboard"| node_api_client
node_api_client -->|"requests API"| node_api
node_api -->|"routes dashboard"| node_dashboard
node_api -->|"routes reports"| node_reports
node_dashboard -->|"aggregates data"| node_database
node_reports -.->|"queries reports"| node_database
node_crm_ui -->|"uses API"| node_api_client
node_accounts_ui -.->|"uses API"| node_api_client
node_production_ui -.->|"uses API"| node_api_client
node_purchase_ui -.->|"uses API"| node_api_client
node_delivery_ui -.->|"uses API"| node_api_client
node_reports_ui -.->|"uses API"| node_api_client
node_api -.->|"manages records"| node_contacts
node_api -.->|"manages pipeline"| node_crm
node_api -.->|"manages billing"| node_accounts
node_api -.->|"manages stock"| node_inventory
node_api -.->|"manages purchasing"| node_purchasing
node_api -.->|"manages orders"| node_production
node_api -.->|"manages dispatch"| node_delivery
node_production -->|"has deliveries"| node_delivery
node_api -->|"raises approval"| node_quotation_event
node_quotation_event -->|"dispatches webhook"| node_webhook_job
node_webhook_job -->|"sends webhook"| node_n8n
node_quotation_event -.->|"notifies approval"| node_email

click node_spa "https://github.com/arunkumar262004/erp/blob/main/frontend/src/App.tsx"
click node_auth "https://github.com/arunkumar262004/erp/blob/main/frontend/src/auth/AuthContext.tsx"
click node_api_client "https://github.com/arunkumar262004/erp/blob/main/frontend/src/api/client.ts"
click node_dashboard_ui "https://github.com/arunkumar262004/erp/blob/main/frontend/src/pages/DashboardPage.tsx"
click node_crm_ui "https://github.com/arunkumar262004/erp/tree/main/frontend/src/pages/crm"
click node_accounts_ui "https://github.com/arunkumar262004/erp/tree/main/frontend/src/pages/accounts"
click node_production_ui "https://github.com/arunkumar262004/erp/tree/main/frontend/src/pages/production"
click node_purchase_ui "https://github.com/arunkumar262004/erp/tree/main/frontend/src/pages/purchase"
click node_delivery_ui "https://github.com/arunkumar262004/erp/tree/main/frontend/src/pages/delivery"
click node_reports_ui "https://github.com/arunkumar262004/erp/blob/main/frontend/src/pages/ReportsPage.tsx"
click node_contacts "https://github.com/arunkumar262004/erp/blob/main/backend/app/Models/Contact.php"
click node_crm "https://github.com/arunkumar262004/erp/blob/main/backend/app/Models/Lead.php"
click node_accounts "https://github.com/arunkumar262004/erp/blob/main/backend/app/Models/Quotation.php"
click node_inventory "https://github.com/arunkumar262004/erp/blob/main/backend/app/Models/RawMaterial.php"
click node_purchasing "https://github.com/arunkumar262004/erp/blob/main/backend/app/Models/PurchaseOrder.php"
click node_production "https://github.com/arunkumar262004/erp/blob/main/backend/app/Models/ProductionOrder.php"
click node_delivery "https://github.com/arunkumar262004/erp/blob/main/backend/app/Models/Delivery.php"
click node_api "https://github.com/arunkumar262004/erp/blob/main/backend/routes/api.php"
click node_dashboard "https://github.com/arunkumar262004/erp/blob/main/backend/app/Http/Controllers/Api/DashboardController.php"
click node_reports "https://github.com/arunkumar262004/erp/blob/main/backend/app/Http/Controllers/Api/ReportController.php"
click node_database "https://github.com/arunkumar262004/erp/blob/main/backend/config/database.php"
click node_quotation_event "https://github.com/arunkumar262004/erp/blob/main/backend/app/Events/QuotationApproved.php"
click node_webhook_job "https://github.com/arunkumar262004/erp/blob/main/backend/app/Jobs/SendN8nWebhook.php"
click node_email "https://github.com/arunkumar262004/erp/blob/main/backend/app/Mail/QuotationApprovedMail.php"

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_spa,node_auth,node_api_client,node_dashboard_ui,node_crm_ui,node_accounts_ui,node_production_ui,node_purchase_ui,node_delivery_ui,node_reports_ui toneBlue
class node_contacts,node_crm,node_accounts toneAmber
class node_inventory,node_purchasing,node_production,node_delivery toneMint
class node_api,node_dashboard,node_reports,node_database toneRose
class node_quotation_event,node_webhook_job,node_email,node_staff,node_n8n toneIndigo
```

## Components

### ERP frontend

- [ERP workspace](https://github.com/arunkumar262004/erp/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Session and access](https://github.com/arunkumar262004/erp/blob/main/frontend/src/auth/AuthContext.tsx): `frontend/src/auth/AuthContext.tsx`
- [API client](https://github.com/arunkumar262004/erp/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [Dashboard view](https://github.com/arunkumar262004/erp/blob/main/frontend/src/pages/DashboardPage.tsx): `frontend/src/pages/DashboardPage.tsx`
- [CRM workspace](https://github.com/arunkumar262004/erp/tree/main/frontend/src/pages/crm): `frontend/src/pages/crm`
- [Accounts workspace](https://github.com/arunkumar262004/erp/tree/main/frontend/src/pages/accounts): `frontend/src/pages/accounts`
- [Production workspace](https://github.com/arunkumar262004/erp/tree/main/frontend/src/pages/production): `frontend/src/pages/production`
- [Purchase workspace](https://github.com/arunkumar262004/erp/tree/main/frontend/src/pages/purchase): `frontend/src/pages/purchase`
- [Delivery tracking](https://github.com/arunkumar262004/erp/tree/main/frontend/src/pages/delivery): `frontend/src/pages/delivery`
- [Reports view](https://github.com/arunkumar262004/erp/blob/main/frontend/src/pages/ReportsPage.tsx): `frontend/src/pages/ReportsPage.tsx`

### Customer and accounts

- [Contacts](https://github.com/arunkumar262004/erp/blob/main/backend/app/Models/Contact.php): `backend/app/Models/Contact.php`
- [Leads and tasks](https://github.com/arunkumar262004/erp/blob/main/backend/app/Models/Lead.php): `backend/app/Models/Lead.php`
- [Quotations and billing](https://github.com/arunkumar262004/erp/blob/main/backend/app/Models/Quotation.php): `backend/app/Models/Quotation.php`

### Manufacturing operations

- [Products and materials](https://github.com/arunkumar262004/erp/blob/main/backend/app/Models/RawMaterial.php): `backend/app/Models/RawMaterial.php`
- [Suppliers and orders](https://github.com/arunkumar262004/erp/blob/main/backend/app/Models/PurchaseOrder.php): `backend/app/Models/PurchaseOrder.php`
- [Production stages](https://github.com/arunkumar262004/erp/blob/main/backend/app/Models/ProductionOrder.php): `backend/app/Models/ProductionOrder.php`
- [Dispatch records](https://github.com/arunkumar262004/erp/blob/main/backend/app/Models/Delivery.php): `backend/app/Models/Delivery.php`

### API and reporting

- [Laravel API](https://github.com/arunkumar262004/erp/blob/main/backend/routes/api.php): `backend/routes/api.php`
- [Dashboard aggregation](https://github.com/arunkumar262004/erp/blob/main/backend/app/Http/Controllers/Api/DashboardController.php): `backend/app/Http/Controllers/Api/DashboardController.php`
- [Module reports](https://github.com/arunkumar262004/erp/blob/main/backend/app/Http/Controllers/Api/ReportController.php): `backend/app/Http/Controllers/Api/ReportController.php`
- [MySQL data](https://github.com/arunkumar262004/erp/blob/main/backend/config/database.php): `backend/config/database.php`

### Notifications

- [Approval event](https://github.com/arunkumar262004/erp/blob/main/backend/app/Events/QuotationApproved.php): `backend/app/Events/QuotationApproved.php`
- [Webhook dispatch](https://github.com/arunkumar262004/erp/blob/main/backend/app/Jobs/SendN8nWebhook.php): `backend/app/Jobs/SendN8nWebhook.php`
- [Approval email](https://github.com/arunkumar262004/erp/blob/main/backend/app/Mail/QuotationApprovedMail.php): `backend/app/Mail/QuotationApprovedMail.php`

### Other components

- **ERP staff**
- **n8n service**

## Connections

- ERP staff → ERP workspace: uses
- ERP workspace → Session and access: protects routes (evidence: `frontend/src/App.tsx`)
- ERP workspace → Dashboard view: routes to (evidence: `frontend/src/App.tsx`)
- ERP workspace → CRM workspace: routes to (evidence: `frontend/src/App.tsx`)
- ERP workspace → Accounts workspace: routes to (evidence: `frontend/src/App.tsx`)
- ERP workspace → Production workspace: routes to (evidence: `frontend/src/App.tsx`)
- ERP workspace → Purchase workspace: routes to (evidence: `frontend/src/App.tsx`)
- ERP workspace → Delivery tracking: routes to (evidence: `frontend/src/App.tsx`)
- ERP workspace → Reports view: routes to (evidence: `frontend/src/App.tsx`)
- Session and access → API client: uses (evidence: `frontend/src/auth/AuthContext.tsx`)
- Dashboard view → API client: loads dashboard
- API client → Laravel API: requests API (evidence: `frontend/src/api/client.ts`)
- Laravel API → Dashboard aggregation: routes dashboard (evidence: `backend/routes/api.php`)
- Laravel API → Module reports: routes reports (evidence: `backend/routes/api.php`)
- Dashboard aggregation → MySQL data: aggregates data (evidence: `backend/app/Http/Controllers/Api/DashboardController.php`)
- Module reports → MySQL data: queries reports
- CRM workspace → API client: uses API (evidence: `frontend/src/pages/crm/CrmTasksPage.tsx`)
- Accounts workspace → API client: uses API
- Production workspace → API client: uses API
- Purchase workspace → API client: uses API
- Delivery tracking → API client: uses API
- Reports view → API client: uses API
- Laravel API → Contacts: manages records
- Laravel API → Leads and tasks: manages pipeline
- Laravel API → Quotations and billing: manages billing
- Laravel API → Products and materials: manages stock
- Laravel API → Suppliers and orders: manages purchasing
- Laravel API → Production stages: manages orders
- Laravel API → Dispatch records: manages dispatch
- Production stages → Dispatch records: has deliveries (evidence: `backend/app/Models/ProductionOrder.php`)
- Laravel API → Approval event: raises approval
- Approval event → Webhook dispatch: dispatches webhook (evidence: `backend/app/Listeners/SendQuotationApprovedWebhook.php`)
- Webhook dispatch → n8n service: sends webhook (evidence: `backend/app/Jobs/SendN8nWebhook.php`)
- Approval event → Approval email: notifies approval
