# chaymaakhab/erp-distribution architecture

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

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

## Overview

ERP-Distribution pairs a React ERP workspace with a standalone Laravel REST API. The visible UI presents a dashboard and operational areas including orders, inventory, finance, and deliveries; the API exposes authentication, order, and offline-sync handling. A separate Express API-server workspace is also present, but the excerpts do not establish how it relates to the Laravel service or whether the ERP UI calls either API. Edges reflect only shown routing, imports, and model calls; unsampled functionality is represented only where the tree or README supports it.

Main entry points: [`BACK-END/routes/api.php`](https://github.com/chaymaakhab/erp-distribution/blob/main/BACK-END/routes/api.php) (API routes), [`FRONT-END/artifacts/api-server/src/routes/index.ts`](https://github.com/chaymaakhab/erp-distribution/blob/main/FRONT-END/artifacts/api-server/src/routes/index.ts) (API route registry), [`BACK-END/app/Http/Controllers/Api/v1/SyncController.php`](https://github.com/chaymaakhab/erp-distribution/blob/main/BACK-END/app/Http/Controllers/Api/v1/SyncController.php) (Offline sync), [`FRONT-END/artifacts/api-server/src/app.ts`](https://github.com/chaymaakhab/erp-distribution/blob/main/FRONT-END/artifacts/api-server/src/app.ts) (Express app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["ERP workspace"]
  node_erp["ERP interface<br/>[App.tsx]"]
  node_ui_boot["UI entry<br/>[main.tsx]"]
end

subgraph group_laravel["Laravel API"]
  node_api_routes["API routes<br/>[api.php]"]
  node_laravel_boot["Laravel routing setup<br/>[app.php]"]
end

subgraph group_express["Express API"]
  node_express_app["Express app<br/>[app.ts]"]
  node_express_routes["API route registry<br/>[index.ts]"]
  node_express_auth["Auth routes<br/>[auth.ts]"]
  node_express_records["Record routes<br/>[records.ts]"]
  node_express_health["Health route<br/>[health.ts]"]
  node_logger["Request logging<br/>[logger.ts]"]
end

subgraph group_domain["API domain"]
  node_auth["Identity and roles<br/>[AuthController.php]"]
  node_orders["Order operations"]
  node_sync["Offline sync<br/>[SyncController.php]"]
  node_order_model[("Order records<br/>[Order.php]")]
  node_customer_model[("Customer records<br/>[Customer.php]")]
  node_sync_log[("Sync idempotency log<br/>[SyncLog.php]")]
  node_user_model[("User accounts<br/>[User.php]")]
  node_product_model[("Product records<br/>[Product.php]")]
  node_role_model[("Role records<br/>[Role.php]")]
end

node_user(("ERP user"))

node_user -->|"uses"| node_erp
node_ui_boot -->|"renders"| node_erp
node_laravel_boot -->|"registers"| node_api_routes
node_api_routes -->|"routes to"| node_auth
node_api_routes -->|"routes to"| node_orders
node_api_routes -->|"routes to"| node_sync
node_orders -->|"reads and writes"| node_order_model
node_sync -->|"finds or creates"| node_customer_model
node_sync -->|"creates"| node_order_model
node_sync -->|"checks and logs"| node_sync_log
node_express_app -->|"mounts"| node_express_routes
node_express_app -->|"configures"| node_logger
node_express_routes -->|"registers"| node_express_auth
node_express_routes -->|"registers"| node_express_records
node_express_routes -->|"registers"| node_express_health

click node_erp "https://github.com/chaymaakhab/erp-distribution/blob/main/FRONT-END/artifacts/distribution-erp/src/App.tsx"
click node_ui_boot "https://github.com/chaymaakhab/erp-distribution/blob/main/FRONT-END/artifacts/distribution-erp/src/main.tsx"
click node_api_routes "https://github.com/chaymaakhab/erp-distribution/blob/main/BACK-END/routes/api.php"
click node_auth "https://github.com/chaymaakhab/erp-distribution/blob/main/BACK-END/app/Http/Controllers/Api/v1/AuthController.php"
click node_orders "https://github.com/chaymaakhab/erp-distribution/blob/main/BACK-END/app/Http/Controllers/Api/v1/OrderController.php"
click node_sync "https://github.com/chaymaakhab/erp-distribution/blob/main/BACK-END/app/Http/Controllers/Api/v1/SyncController.php"
click node_order_model "https://github.com/chaymaakhab/erp-distribution/blob/main/BACK-END/app/Models/Order.php"
click node_customer_model "https://github.com/chaymaakhab/erp-distribution/blob/main/BACK-END/app/Models/Customer.php"
click node_sync_log "https://github.com/chaymaakhab/erp-distribution/blob/main/BACK-END/app/Models/SyncLog.php"
click node_user_model "https://github.com/chaymaakhab/erp-distribution/blob/main/BACK-END/app/Models/User.php"
click node_product_model "https://github.com/chaymaakhab/erp-distribution/blob/main/BACK-END/app/Models/Product.php"
click node_role_model "https://github.com/chaymaakhab/erp-distribution/blob/main/BACK-END/app/Models/Role.php"
click node_laravel_boot "https://github.com/chaymaakhab/erp-distribution/blob/main/BACK-END/bootstrap/app.php"
click node_express_app "https://github.com/chaymaakhab/erp-distribution/blob/main/FRONT-END/artifacts/api-server/src/app.ts"
click node_express_routes "https://github.com/chaymaakhab/erp-distribution/blob/main/FRONT-END/artifacts/api-server/src/routes/index.ts"
click node_express_auth "https://github.com/chaymaakhab/erp-distribution/blob/main/FRONT-END/artifacts/api-server/src/routes/auth.ts"
click node_express_records "https://github.com/chaymaakhab/erp-distribution/blob/main/FRONT-END/artifacts/api-server/src/routes/records.ts"
click node_express_health "https://github.com/chaymaakhab/erp-distribution/blob/main/FRONT-END/artifacts/api-server/src/routes/health.ts"
click node_logger "https://github.com/chaymaakhab/erp-distribution/blob/main/FRONT-END/artifacts/api-server/src/lib/logger.ts"

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_erp,node_ui_boot,node_user toneBlue
class node_api_routes,node_laravel_boot toneAmber
class node_express_app,node_express_routes,node_express_auth,node_express_records,node_express_health,node_logger toneMint
class node_auth,node_orders,node_sync,node_order_model,node_customer_model,node_sync_log,node_user_model,node_product_model,node_role_model toneRose
```

## Components

### ERP workspace

- [ERP interface](https://github.com/chaymaakhab/erp-distribution/blob/main/FRONT-END/artifacts/distribution-erp/src/App.tsx): `FRONT-END/artifacts/distribution-erp/src/App.tsx`
- [UI entry](https://github.com/chaymaakhab/erp-distribution/blob/main/FRONT-END/artifacts/distribution-erp/src/main.tsx): `FRONT-END/artifacts/distribution-erp/src/main.tsx`

### Laravel API

- [API routes](https://github.com/chaymaakhab/erp-distribution/blob/main/BACK-END/routes/api.php): `BACK-END/routes/api.php`
- [Laravel routing setup](https://github.com/chaymaakhab/erp-distribution/blob/main/BACK-END/bootstrap/app.php): `BACK-END/bootstrap/app.php`

### Express API

- [Express app](https://github.com/chaymaakhab/erp-distribution/blob/main/FRONT-END/artifacts/api-server/src/app.ts): `FRONT-END/artifacts/api-server/src/app.ts`
- [API route registry](https://github.com/chaymaakhab/erp-distribution/blob/main/FRONT-END/artifacts/api-server/src/routes/index.ts): `FRONT-END/artifacts/api-server/src/routes/index.ts`
- [Auth routes](https://github.com/chaymaakhab/erp-distribution/blob/main/FRONT-END/artifacts/api-server/src/routes/auth.ts): `FRONT-END/artifacts/api-server/src/routes/auth.ts`
- [Record routes](https://github.com/chaymaakhab/erp-distribution/blob/main/FRONT-END/artifacts/api-server/src/routes/records.ts): `FRONT-END/artifacts/api-server/src/routes/records.ts`
- [Health route](https://github.com/chaymaakhab/erp-distribution/blob/main/FRONT-END/artifacts/api-server/src/routes/health.ts): `FRONT-END/artifacts/api-server/src/routes/health.ts`
- [Request logging](https://github.com/chaymaakhab/erp-distribution/blob/main/FRONT-END/artifacts/api-server/src/lib/logger.ts): `FRONT-END/artifacts/api-server/src/lib/logger.ts`

### API domain

- [Identity and roles](https://github.com/chaymaakhab/erp-distribution/blob/main/BACK-END/app/Http/Controllers/Api/v1/AuthController.php): `BACK-END/app/Http/Controllers/Api/v1/AuthController.php`
- [Order operations](https://github.com/chaymaakhab/erp-distribution/blob/main/BACK-END/app/Http/Controllers/Api/v1/OrderController.php): `BACK-END/app/Http/Controllers/Api/v1/OrderController.php`
- [Offline sync](https://github.com/chaymaakhab/erp-distribution/blob/main/BACK-END/app/Http/Controllers/Api/v1/SyncController.php): `BACK-END/app/Http/Controllers/Api/v1/SyncController.php`
- [Order records](https://github.com/chaymaakhab/erp-distribution/blob/main/BACK-END/app/Models/Order.php): `BACK-END/app/Models/Order.php`
- [Customer records](https://github.com/chaymaakhab/erp-distribution/blob/main/BACK-END/app/Models/Customer.php): `BACK-END/app/Models/Customer.php`
- [Sync idempotency log](https://github.com/chaymaakhab/erp-distribution/blob/main/BACK-END/app/Models/SyncLog.php): `BACK-END/app/Models/SyncLog.php`
- [User accounts](https://github.com/chaymaakhab/erp-distribution/blob/main/BACK-END/app/Models/User.php): `BACK-END/app/Models/User.php`
- [Product records](https://github.com/chaymaakhab/erp-distribution/blob/main/BACK-END/app/Models/Product.php): `BACK-END/app/Models/Product.php`
- [Role records](https://github.com/chaymaakhab/erp-distribution/blob/main/BACK-END/app/Models/Role.php): `BACK-END/app/Models/Role.php`

### Other components

- **ERP user**

## Connections

- ERP user → ERP interface: uses
- UI entry → ERP interface: renders (evidence: `FRONT-END/artifacts/distribution-erp/src/main.tsx`)
- Laravel routing setup → API routes: registers (evidence: `BACK-END/bootstrap/app.php`)
- API routes → Identity and roles: routes to (evidence: `BACK-END/routes/api.php`)
- API routes → Order operations: routes to (evidence: `BACK-END/routes/api.php`)
- API routes → Offline sync: routes to (evidence: `BACK-END/routes/api.php`)
- Order operations → Order records: reads and writes (evidence: `BACK-END/app/Http/Controllers/Api/v1/OrderController.php`)
- Offline sync → Customer records: finds or creates (evidence: `BACK-END/app/Http/Controllers/Api/v1/SyncController.php`)
- Offline sync → Order records: creates (evidence: `BACK-END/app/Http/Controllers/Api/v1/SyncController.php`)
- Offline sync → Sync idempotency log: checks and logs (evidence: `BACK-END/app/Http/Controllers/Api/v1/SyncController.php`)
- Express app → API route registry: mounts (evidence: `FRONT-END/artifacts/api-server/src/app.ts`)
- Express app → Request logging: configures (evidence: `FRONT-END/artifacts/api-server/src/app.ts`)
- API route registry → Auth routes: registers (evidence: `FRONT-END/artifacts/api-server/src/routes/index.ts`)
- API route registry → Record routes: registers (evidence: `FRONT-END/artifacts/api-server/src/routes/index.ts`)
- API route registry → Health route: registers (evidence: `FRONT-END/artifacts/api-server/src/routes/index.ts`)
