# chaymaakhab/distribution-erp2 architecture

> Architecture diagram of the GitHub repository chaymaakhab/distribution-erp2, 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/chaymaakhab/distribution-erp2
- Repository: https://github.com/chaymaakhab/distribution-erp2

## Overview

ERP-Distribution combines a React workspace with a Laravel REST API for staff operations and a customer portal. The documented customer journey spans catalog browsing, account access, ordering, order history, and invoices; staff-facing areas cover administration, inventory, delivery, purchasing, and finance. Laravel routes dispatch API requests to controllers, which read or update Eloquent-backed domain data. The sampled frontend shell contains illustrative rows, so its direct operational connection to the API is not established; that integration is shown as unverified. Other frontend feature links follow the repository’s module layout, not inspected call sites.

Main entry points: [`BACK-END/routes/api.php`](https://github.com/chaymaakhab/distribution-erp2/blob/main/BACK-END/routes/api.php) (API routes), [`BACK-END/app/Models`](https://github.com/chaymaakhab/distribution-erp2/tree/main/BACK-END/app/Models) (ERP domain models), [`FRONT-END/artifacts/distribution-erp/src/customer/CustomerApp.tsx`](https://github.com/chaymaakhab/distribution-erp2/blob/main/FRONT-END/artifacts/distribution-erp/src/customer/CustomerApp.tsx) (Customer app), [`FRONT-END/artifacts/distribution-erp/src/staff/StaffApp.tsx`](https://github.com/chaymaakhab/distribution-erp2/blob/main/FRONT-END/artifacts/distribution-erp/src/staff/StaffApp.tsx) (Staff app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_customer["Customer portal"]
  node_customer_app["Customer app<br/>[CustomerApp.tsx]"]
  node_customer_catalog["Catalog and cart<br/>[Catalog.tsx]"]
  node_customer_orders["Customer orders<br/>[Orders.tsx]"]
  node_customer_invoices["Customer invoices<br/>[Invoices.tsx]"]
  node_customer_api["Customer API client<br/>[api.ts]"]
end

subgraph group_staff["Staff workspace"]
  node_staff_app["Staff app<br/>[StaffApp.tsx]"]
  node_staff_auth["Staff access<br/>[auth.tsx]"]
  node_staff_ops["Operations modules"]
  node_staff_reports["Dashboards and reports<br/>[ReportsPage.tsx]"]
  node_staff_api["Staff API client<br/>[api.ts]"]
  node_demo_shell["ERP shell demo<br/>[App.tsx]"]
end

subgraph group_api["API service"]
  node_api_routes["API routes<br/>[api.php]"]
  node_customer_auth["Customer access<br/>[AuthController.php]"]
  node_customer_catalog_api["Catalog endpoints"]
  node_customer_order_api["Customer order endpoints"]
  node_customer_invoice_api["Invoice endpoints"]
  node_customer_account_api["Account endpoints"]
  node_staff_auth_api["Staff authentication<br/>[AuthController.php]"]
  node_admin_dashboard["Admin dashboard API"]
  node_sync_api["Offline sync API<br/>[SyncController.php]"]
end

subgraph group_domain["ERP domain data"]
  node_models["ERP domain models"]
  node_database[("Relational database<br/>[database.php]")]
end

node_customer_actor(("Customer"))
node_staff_actor(("Staff user"))

node_customer_actor -->|"uses"| node_customer_app
node_customer_app -.->|"navigates"| node_customer_catalog
node_customer_app -.->|"navigates"| node_customer_orders
node_customer_app -.->|"navigates"| node_customer_invoices
node_customer_catalog -.->|"requests data"| node_customer_api
node_customer_orders -.->|"requests data"| node_customer_api
node_customer_invoices -.->|"requests data"| node_customer_api
node_customer_api -.->|"calls API"| node_api_routes
node_staff_actor -->|"uses"| node_staff_app
node_staff_app -.->|"provides access"| node_staff_auth
node_staff_app -.->|"navigates"| node_staff_ops
node_staff_app -.->|"navigates"| node_staff_reports
node_staff_ops -.->|"requests data"| node_staff_api
node_staff_reports -.->|"requests data"| node_staff_api
node_staff_api -.->|"calls API"| node_api_routes
node_demo_shell -.->|"presents demo"| node_staff_actor
node_api_routes -->|"routes to"| node_customer_auth
node_api_routes -->|"routes to"| node_customer_catalog_api
node_api_routes -->|"routes to"| node_customer_order_api
node_api_routes -->|"routes to"| node_customer_invoice_api
node_api_routes -->|"routes to"| node_customer_account_api
node_api_routes -->|"routes to"| node_staff_auth_api
node_api_routes -->|"routes to"| node_admin_dashboard
node_api_routes -->|"routes to"| node_sync_api
node_customer_auth -->|"reads customer"| node_models
node_customer_catalog_api -->|"reads catalog"| node_models
node_customer_order_api -->|"reads and writes"| node_models
node_customer_invoice_api -->|"reads invoices"| node_models
node_customer_account_api -->|"reads customer"| node_models
node_staff_auth_api -->|"reads user"| node_models
node_admin_dashboard -->|"queries metrics"| node_models
node_sync_api -->|"records sync"| node_models
node_models -.->|"persists data"| node_database

click node_customer_app "https://github.com/chaymaakhab/distribution-erp2/blob/main/FRONT-END/artifacts/distribution-erp/src/customer/CustomerApp.tsx"
click node_customer_catalog "https://github.com/chaymaakhab/distribution-erp2/blob/main/FRONT-END/artifacts/distribution-erp/src/customer/pages/Catalog.tsx"
click node_customer_orders "https://github.com/chaymaakhab/distribution-erp2/blob/main/FRONT-END/artifacts/distribution-erp/src/customer/pages/Orders.tsx"
click node_customer_invoices "https://github.com/chaymaakhab/distribution-erp2/blob/main/FRONT-END/artifacts/distribution-erp/src/customer/pages/Invoices.tsx"
click node_customer_api "https://github.com/chaymaakhab/distribution-erp2/blob/main/FRONT-END/artifacts/distribution-erp/src/customer/api.ts"
click node_staff_app "https://github.com/chaymaakhab/distribution-erp2/blob/main/FRONT-END/artifacts/distribution-erp/src/staff/StaffApp.tsx"
click node_staff_auth "https://github.com/chaymaakhab/distribution-erp2/blob/main/FRONT-END/artifacts/distribution-erp/src/staff/auth.tsx"
click node_staff_ops "https://github.com/chaymaakhab/distribution-erp2/tree/main/FRONT-END/artifacts/distribution-erp/src/staff/pages"
click node_staff_reports "https://github.com/chaymaakhab/distribution-erp2/blob/main/FRONT-END/artifacts/distribution-erp/src/staff/pages/ReportsPage.tsx"
click node_staff_api "https://github.com/chaymaakhab/distribution-erp2/blob/main/FRONT-END/artifacts/distribution-erp/src/staff/api.ts"
click node_demo_shell "https://github.com/chaymaakhab/distribution-erp2/blob/main/FRONT-END/artifacts/distribution-erp/src/App.tsx"
click node_api_routes "https://github.com/chaymaakhab/distribution-erp2/blob/main/BACK-END/routes/api.php"
click node_customer_auth "https://github.com/chaymaakhab/distribution-erp2/blob/main/BACK-END/app/Http/Controllers/Api/v1/Customer/AuthController.php"
click node_customer_catalog_api "https://github.com/chaymaakhab/distribution-erp2/blob/main/BACK-END/app/Http/Controllers/Api/v1/Customer/CatalogController.php"
click node_customer_order_api "https://github.com/chaymaakhab/distribution-erp2/blob/main/BACK-END/app/Http/Controllers/Api/v1/Customer/OrderController.php"
click node_customer_invoice_api "https://github.com/chaymaakhab/distribution-erp2/blob/main/BACK-END/app/Http/Controllers/Api/v1/Customer/InvoiceController.php"
click node_customer_account_api "https://github.com/chaymaakhab/distribution-erp2/blob/main/BACK-END/app/Http/Controllers/Api/v1/Customer/AccountController.php"
click node_staff_auth_api "https://github.com/chaymaakhab/distribution-erp2/blob/main/BACK-END/app/Http/Controllers/Api/v1/AuthController.php"
click node_admin_dashboard "https://github.com/chaymaakhab/distribution-erp2/blob/main/BACK-END/app/Http/Controllers/Api/v1/Admin/DashboardController.php"
click node_sync_api "https://github.com/chaymaakhab/distribution-erp2/blob/main/BACK-END/app/Http/Controllers/Api/v1/SyncController.php"
click node_models "https://github.com/chaymaakhab/distribution-erp2/tree/main/BACK-END/app/Models"
click node_database "https://github.com/chaymaakhab/distribution-erp2/blob/main/BACK-END/config/database.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_customer_app,node_customer_catalog,node_customer_orders,node_customer_invoices,node_customer_api,node_staff_actor toneBlue
class node_staff_app,node_staff_auth,node_staff_ops,node_staff_reports,node_staff_api,node_demo_shell toneAmber
class node_api_routes,node_customer_auth,node_customer_catalog_api,node_customer_order_api,node_customer_invoice_api,node_customer_account_api,node_staff_auth_api,node_admin_dashboard,node_sync_api toneMint
class node_models,node_database toneRose
class node_customer_actor toneIndigo
```

## Components

### Customer portal

- [Customer app](https://github.com/chaymaakhab/distribution-erp2/blob/main/FRONT-END/artifacts/distribution-erp/src/customer/CustomerApp.tsx): `FRONT-END/artifacts/distribution-erp/src/customer/CustomerApp.tsx`
- [Catalog and cart](https://github.com/chaymaakhab/distribution-erp2/blob/main/FRONT-END/artifacts/distribution-erp/src/customer/pages/Catalog.tsx): `FRONT-END/artifacts/distribution-erp/src/customer/pages/Catalog.tsx`
- [Customer orders](https://github.com/chaymaakhab/distribution-erp2/blob/main/FRONT-END/artifacts/distribution-erp/src/customer/pages/Orders.tsx): `FRONT-END/artifacts/distribution-erp/src/customer/pages/Orders.tsx`
- [Customer invoices](https://github.com/chaymaakhab/distribution-erp2/blob/main/FRONT-END/artifacts/distribution-erp/src/customer/pages/Invoices.tsx): `FRONT-END/artifacts/distribution-erp/src/customer/pages/Invoices.tsx`
- [Customer API client](https://github.com/chaymaakhab/distribution-erp2/blob/main/FRONT-END/artifacts/distribution-erp/src/customer/api.ts): `FRONT-END/artifacts/distribution-erp/src/customer/api.ts`

### Staff workspace

- [Staff app](https://github.com/chaymaakhab/distribution-erp2/blob/main/FRONT-END/artifacts/distribution-erp/src/staff/StaffApp.tsx): `FRONT-END/artifacts/distribution-erp/src/staff/StaffApp.tsx`
- [Staff access](https://github.com/chaymaakhab/distribution-erp2/blob/main/FRONT-END/artifacts/distribution-erp/src/staff/auth.tsx): `FRONT-END/artifacts/distribution-erp/src/staff/auth.tsx`
- [Operations modules](https://github.com/chaymaakhab/distribution-erp2/tree/main/FRONT-END/artifacts/distribution-erp/src/staff/pages): `FRONT-END/artifacts/distribution-erp/src/staff/pages`
- [Dashboards and reports](https://github.com/chaymaakhab/distribution-erp2/blob/main/FRONT-END/artifacts/distribution-erp/src/staff/pages/ReportsPage.tsx): `FRONT-END/artifacts/distribution-erp/src/staff/pages/ReportsPage.tsx`
- [Staff API client](https://github.com/chaymaakhab/distribution-erp2/blob/main/FRONT-END/artifacts/distribution-erp/src/staff/api.ts): `FRONT-END/artifacts/distribution-erp/src/staff/api.ts`
- [ERP shell demo](https://github.com/chaymaakhab/distribution-erp2/blob/main/FRONT-END/artifacts/distribution-erp/src/App.tsx): `FRONT-END/artifacts/distribution-erp/src/App.tsx`

### API service

- [API routes](https://github.com/chaymaakhab/distribution-erp2/blob/main/BACK-END/routes/api.php): `BACK-END/routes/api.php`
- [Customer access](https://github.com/chaymaakhab/distribution-erp2/blob/main/BACK-END/app/Http/Controllers/Api/v1/Customer/AuthController.php): `BACK-END/app/Http/Controllers/Api/v1/Customer/AuthController.php`
- [Catalog endpoints](https://github.com/chaymaakhab/distribution-erp2/blob/main/BACK-END/app/Http/Controllers/Api/v1/Customer/CatalogController.php): `BACK-END/app/Http/Controllers/Api/v1/Customer/CatalogController.php`
- [Customer order endpoints](https://github.com/chaymaakhab/distribution-erp2/blob/main/BACK-END/app/Http/Controllers/Api/v1/Customer/OrderController.php): `BACK-END/app/Http/Controllers/Api/v1/Customer/OrderController.php`
- [Invoice endpoints](https://github.com/chaymaakhab/distribution-erp2/blob/main/BACK-END/app/Http/Controllers/Api/v1/Customer/InvoiceController.php): `BACK-END/app/Http/Controllers/Api/v1/Customer/InvoiceController.php`
- [Account endpoints](https://github.com/chaymaakhab/distribution-erp2/blob/main/BACK-END/app/Http/Controllers/Api/v1/Customer/AccountController.php): `BACK-END/app/Http/Controllers/Api/v1/Customer/AccountController.php`
- [Staff authentication](https://github.com/chaymaakhab/distribution-erp2/blob/main/BACK-END/app/Http/Controllers/Api/v1/AuthController.php): `BACK-END/app/Http/Controllers/Api/v1/AuthController.php`
- [Admin dashboard API](https://github.com/chaymaakhab/distribution-erp2/blob/main/BACK-END/app/Http/Controllers/Api/v1/Admin/DashboardController.php): `BACK-END/app/Http/Controllers/Api/v1/Admin/DashboardController.php`
- [Offline sync API](https://github.com/chaymaakhab/distribution-erp2/blob/main/BACK-END/app/Http/Controllers/Api/v1/SyncController.php): `BACK-END/app/Http/Controllers/Api/v1/SyncController.php`

### ERP domain data

- [ERP domain models](https://github.com/chaymaakhab/distribution-erp2/tree/main/BACK-END/app/Models): `BACK-END/app/Models`
- [Relational database](https://github.com/chaymaakhab/distribution-erp2/blob/main/BACK-END/config/database.php): `BACK-END/config/database.php`

### Other components

- **Customer**
- **Staff user**

## Connections

- Customer → Customer app: uses (evidence: `README.md`)
- Customer app → Catalog and cart: navigates
- Customer app → Customer orders: navigates
- Customer app → Customer invoices: navigates
- Catalog and cart → Customer API client: requests data
- Customer orders → Customer API client: requests data
- Customer invoices → Customer API client: requests data
- Customer API client → API routes: calls API
- Staff user → Staff app: uses (evidence: `README.md`)
- Staff app → Staff access: provides access
- Staff app → Operations modules: navigates
- Staff app → Dashboards and reports: navigates
- Operations modules → Staff API client: requests data (evidence: `FRONT-END/artifacts/distribution-erp/src/staff/pages/ClientsCrm.tsx`)
- Dashboards and reports → Staff API client: requests data
- Staff API client → API routes: calls API
- ERP shell demo → Staff user: presents demo
- API routes → Customer access: routes to (evidence: `BACK-END/routes/api.php`)
- API routes → Catalog endpoints: routes to (evidence: `BACK-END/routes/api.php`)
- API routes → Customer order endpoints: routes to (evidence: `BACK-END/routes/api.php`)
- API routes → Invoice endpoints: routes to (evidence: `BACK-END/routes/api.php`)
- API routes → Account endpoints: routes to (evidence: `BACK-END/routes/api.php`)
- API routes → Staff authentication: routes to (evidence: `BACK-END/routes/api.php`)
- API routes → Admin dashboard API: routes to (evidence: `BACK-END/routes/api.php`)
- API routes → Offline sync API: routes to (evidence: `BACK-END/routes/api.php`)
- Customer access → ERP domain models: reads customer (evidence: `BACK-END/app/Http/Controllers/Api/v1/Customer/AuthController.php`)
- Catalog endpoints → ERP domain models: reads catalog (evidence: `BACK-END/app/Http/Controllers/Api/v1/Customer/CatalogController.php`)
- Customer order endpoints → ERP domain models: reads and writes (evidence: `BACK-END/app/Http/Controllers/Api/v1/Customer/OrderController.php`)
- Invoice endpoints → ERP domain models: reads invoices (evidence: `BACK-END/app/Http/Controllers/Api/v1/Customer/InvoiceController.php`)
- Account endpoints → ERP domain models: reads customer (evidence: `BACK-END/app/Http/Controllers/Api/v1/Customer/AccountController.php`)
- Staff authentication → ERP domain models: reads user (evidence: `BACK-END/app/Http/Controllers/Api/v1/AuthController.php`)
- Admin dashboard API → ERP domain models: queries metrics (evidence: `BACK-END/app/Http/Controllers/Api/v1/Admin/DashboardController.php`)
- Offline sync API → ERP domain models: records sync (evidence: `BACK-END/app/Http/Controllers/Api/v1/SyncController.php`)
- ERP domain models → Relational database: persists data
