# ahmednoaman602/multidukkan architecture

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

- Interactive diagram: https://gitdiagram.com/ahmednoaman602/multidukkan
- Repository: https://github.com/ahmednoaman602/multidukkan

## Overview

MultiDukkan is a Laravel REST backend for multi-tenant retail inventory, sales, purchasing, and finance; its React client is a separate product. The documented request path is API route to validation and controller, then business service and model, with resources shaping selected responses. The graph emphasizes sales, stock, purchasing, ledger-based balances, reporting, audit, and AI alongside tenant-aware API handling. Some subsystems are included from README capabilities and the tree rather than sampled implementation; their internal wiring is omitted where the excerpts do not establish it.

Main entry points: [`routes/api.php`](https://github.com/ahmednoaman602/multidukkan/blob/main/routes/api.php) (API routes), [`app/Services/OrderService.php`](https://github.com/ahmednoaman602/multidukkan/blob/main/app/Services/OrderService.php) (Order service), [`app/Http/Controllers/Api/V1/ReportController.php`](https://github.com/ahmednoaman602/multidukkan/blob/main/app/Http/Controllers/Api/V1/ReportController.php) (Reports API), [`app/Services/LedgerService.php`](https://github.com/ahmednoaman602/multidukkan/blob/main/app/Services/LedgerService.php) (Ledger service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API boundary"]
  node_api_routes["API routes<br/>[api.php]"]
  node_api_bootstrap["Laravel bootstrap<br/>[app.php]"]
  node_order_controller["Orders API"]
  node_product_controller["Products API"]
  node_inventory_controller["Inventory API"]
  node_purchasing_controller["Purchasing API"]
  node_ai_controller["AI API<br/>[AIController.php]"]
end

subgraph group_operations["Retail operations"]
  node_order_service["Order service<br/>[OrderService.php]"]
  node_inventory_service["Inventory service"]
  node_purchase_service["Purchase service"]
  node_inventory_state[("Stock records<br/>[Inventory.php]")]
  node_order_records[("Order records<br/>[Order.php]")]
end

subgraph group_finance["Finance and insight"]
  node_ledger_service["Ledger service<br/>[LedgerService.php]"]
  node_ledger_records[("Ledger entries<br/>[LedgerEntry.php]")]
  node_payment_service["Payment service<br/>[PaymentService.php]"]
  node_report_controller["Reports API"]
  node_expense_service["Expense service<br/>[ExpenseService.php]"]
  node_audit_controller["Audit API"]
  node_ai_service["AI service<br/>[AIService.php]"]
end

subgraph group_platform["Tenant platform"]
  node_tenant_scope["Tenant model scope<br/>[ScopedToTenant.php]"]
  node_auth_controller["Authentication API<br/>[AuthController.php]"]
  node_locale_middleware["Locale and timezone<br/>[SetLocale.php]"]
end

node_retail_user(("Retail user"))
node_llm_provider{{"LLM provider"}}
node_mysql[("MySQL database")]

node_retail_user -->|"sends requests"| node_api_bootstrap
node_api_bootstrap -->|"loads API routes"| node_api_routes
node_api_routes -->|"dispatches"| node_order_controller
node_api_routes -->|"dispatches"| node_product_controller
node_api_routes -->|"dispatches"| node_inventory_controller
node_api_routes -->|"dispatches"| node_purchasing_controller
node_api_routes -->|"dispatches"| node_ai_controller
node_api_routes -->|"dispatches"| node_report_controller
node_api_routes -->|"dispatches"| node_audit_controller
node_api_routes -->|"dispatches"| node_auth_controller
node_api_bootstrap -->|"applies middleware"| node_locale_middleware
node_order_controller -->|"delegates"| node_order_service
node_inventory_controller -->|"delegates"| node_inventory_service
node_purchasing_controller -->|"delegates"| node_purchase_service
node_order_service -->|"reads balance"| node_ledger_service
node_order_service -->|"creates orders"| node_order_records
node_order_service -->|"adjusts stock"| node_inventory_service
node_inventory_service -->|"updates stock"| node_inventory_state
node_purchase_service -->|"records payments"| node_ledger_service
node_ledger_service -->|"appends entries"| node_ledger_records
node_payment_service -->|"records payments"| node_ledger_service
node_report_controller -->|"gets expense totals"| node_expense_service
node_report_controller -->|"reads sales"| node_order_records
node_report_controller -->|"queries data"| node_mysql
node_audit_controller -->|"queries event history"| node_mysql
node_ai_controller -->|"delegates"| node_ai_service
node_ai_service -.->|"requests generation"| node_llm_provider
node_tenant_scope -->|"scopes model queries"| node_mysql
node_auth_controller -->|"reads user data"| node_mysql

click node_api_routes "https://github.com/ahmednoaman602/multidukkan/blob/main/routes/api.php"
click node_api_bootstrap "https://github.com/ahmednoaman602/multidukkan/blob/main/bootstrap/app.php"
click node_order_controller "https://github.com/ahmednoaman602/multidukkan/blob/main/app/Http/Controllers/Api/V1/OrderController.php"
click node_product_controller "https://github.com/ahmednoaman602/multidukkan/blob/main/app/Http/Controllers/Api/V1/ProductController.php"
click node_inventory_controller "https://github.com/ahmednoaman602/multidukkan/blob/main/app/Http/Controllers/Api/V1/InventoryController.php"
click node_purchasing_controller "https://github.com/ahmednoaman602/multidukkan/blob/main/app/Http/Controllers/Api/V1/PurchaseOrderController.php"
click node_ai_controller "https://github.com/ahmednoaman602/multidukkan/blob/main/app/Http/Controllers/Api/V1/AIController.php"
click node_order_service "https://github.com/ahmednoaman602/multidukkan/blob/main/app/Services/OrderService.php"
click node_inventory_service "https://github.com/ahmednoaman602/multidukkan/blob/main/app/Services/InventoryService.php"
click node_purchase_service "https://github.com/ahmednoaman602/multidukkan/blob/main/app/Services/PurchaseOrderService.php"
click node_inventory_state "https://github.com/ahmednoaman602/multidukkan/blob/main/app/Models/Inventory.php"
click node_order_records "https://github.com/ahmednoaman602/multidukkan/blob/main/app/Models/Order.php"
click node_ledger_service "https://github.com/ahmednoaman602/multidukkan/blob/main/app/Services/LedgerService.php"
click node_ledger_records "https://github.com/ahmednoaman602/multidukkan/blob/main/app/Models/LedgerEntry.php"
click node_payment_service "https://github.com/ahmednoaman602/multidukkan/blob/main/app/Services/PaymentService.php"
click node_report_controller "https://github.com/ahmednoaman602/multidukkan/blob/main/app/Http/Controllers/Api/V1/ReportController.php"
click node_expense_service "https://github.com/ahmednoaman602/multidukkan/blob/main/app/Services/ExpenseService.php"
click node_audit_controller "https://github.com/ahmednoaman602/multidukkan/blob/main/app/Http/Controllers/Api/V1/AuditLogController.php"
click node_ai_service "https://github.com/ahmednoaman602/multidukkan/blob/main/app/Services/AI/AIService.php"
click node_tenant_scope "https://github.com/ahmednoaman602/multidukkan/blob/main/app/Models/Concerns/ScopedToTenant.php"
click node_auth_controller "https://github.com/ahmednoaman602/multidukkan/blob/main/app/Http/Controllers/Api/V1/AuthController.php"
click node_locale_middleware "https://github.com/ahmednoaman602/multidukkan/blob/main/app/Http/Middleware/SetLocale.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_api_routes,node_api_bootstrap,node_order_controller,node_product_controller,node_inventory_controller,node_purchasing_controller,node_ai_controller,node_retail_user toneBlue
class node_order_service,node_inventory_service,node_purchase_service,node_inventory_state,node_order_records,node_mysql toneAmber
class node_ledger_service,node_ledger_records,node_payment_service,node_report_controller,node_expense_service,node_audit_controller,node_ai_service toneMint
class node_tenant_scope,node_auth_controller,node_locale_middleware toneRose
class node_llm_provider toneIndigo
```

## Components

### API boundary

- [API routes](https://github.com/ahmednoaman602/multidukkan/blob/main/routes/api.php): `routes/api.php`
- [Laravel bootstrap](https://github.com/ahmednoaman602/multidukkan/blob/main/bootstrap/app.php): `bootstrap/app.php`
- [Orders API](https://github.com/ahmednoaman602/multidukkan/blob/main/app/Http/Controllers/Api/V1/OrderController.php): `app/Http/Controllers/Api/V1/OrderController.php`
- [Products API](https://github.com/ahmednoaman602/multidukkan/blob/main/app/Http/Controllers/Api/V1/ProductController.php): `app/Http/Controllers/Api/V1/ProductController.php`
- [Inventory API](https://github.com/ahmednoaman602/multidukkan/blob/main/app/Http/Controllers/Api/V1/InventoryController.php): `app/Http/Controllers/Api/V1/InventoryController.php`
- [Purchasing API](https://github.com/ahmednoaman602/multidukkan/blob/main/app/Http/Controllers/Api/V1/PurchaseOrderController.php): `app/Http/Controllers/Api/V1/PurchaseOrderController.php`
- [AI API](https://github.com/ahmednoaman602/multidukkan/blob/main/app/Http/Controllers/Api/V1/AIController.php): `app/Http/Controllers/Api/V1/AIController.php`

### Retail operations

- [Order service](https://github.com/ahmednoaman602/multidukkan/blob/main/app/Services/OrderService.php): `app/Services/OrderService.php`
- [Inventory service](https://github.com/ahmednoaman602/multidukkan/blob/main/app/Services/InventoryService.php): `app/Services/InventoryService.php`
- [Purchase service](https://github.com/ahmednoaman602/multidukkan/blob/main/app/Services/PurchaseOrderService.php): `app/Services/PurchaseOrderService.php`
- [Stock records](https://github.com/ahmednoaman602/multidukkan/blob/main/app/Models/Inventory.php): `app/Models/Inventory.php`
- [Order records](https://github.com/ahmednoaman602/multidukkan/blob/main/app/Models/Order.php): `app/Models/Order.php`

### Finance and insight

- [Ledger service](https://github.com/ahmednoaman602/multidukkan/blob/main/app/Services/LedgerService.php): `app/Services/LedgerService.php`
- [Ledger entries](https://github.com/ahmednoaman602/multidukkan/blob/main/app/Models/LedgerEntry.php): `app/Models/LedgerEntry.php`
- [Payment service](https://github.com/ahmednoaman602/multidukkan/blob/main/app/Services/PaymentService.php): `app/Services/PaymentService.php`
- [Reports API](https://github.com/ahmednoaman602/multidukkan/blob/main/app/Http/Controllers/Api/V1/ReportController.php): `app/Http/Controllers/Api/V1/ReportController.php`
- [Expense service](https://github.com/ahmednoaman602/multidukkan/blob/main/app/Services/ExpenseService.php): `app/Services/ExpenseService.php`
- [Audit API](https://github.com/ahmednoaman602/multidukkan/blob/main/app/Http/Controllers/Api/V1/AuditLogController.php): `app/Http/Controllers/Api/V1/AuditLogController.php`
- [AI service](https://github.com/ahmednoaman602/multidukkan/blob/main/app/Services/AI/AIService.php): `app/Services/AI/AIService.php`

### Tenant platform

- [Tenant model scope](https://github.com/ahmednoaman602/multidukkan/blob/main/app/Models/Concerns/ScopedToTenant.php): `app/Models/Concerns/ScopedToTenant.php`
- [Authentication API](https://github.com/ahmednoaman602/multidukkan/blob/main/app/Http/Controllers/Api/V1/AuthController.php): `app/Http/Controllers/Api/V1/AuthController.php`
- [Locale and timezone](https://github.com/ahmednoaman602/multidukkan/blob/main/app/Http/Middleware/SetLocale.php): `app/Http/Middleware/SetLocale.php`

### Other components

- **Retail user**
- **LLM provider**
- **MySQL database**

## Connections

- Retail user → Laravel bootstrap: sends requests
- Laravel bootstrap → API routes: loads API routes
- API routes → Orders API: dispatches
- API routes → Products API: dispatches
- API routes → Inventory API: dispatches
- API routes → Purchasing API: dispatches
- API routes → AI API: dispatches
- API routes → Reports API: dispatches
- API routes → Audit API: dispatches
- API routes → Authentication API: dispatches
- Laravel bootstrap → Locale and timezone: applies middleware
- Orders API → Order service: delegates
- Inventory API → Inventory service: delegates
- Purchasing API → Purchase service: delegates
- Order service → Ledger service: reads balance
- Order service → Order records: creates orders
- Order service → Inventory service: adjusts stock
- Inventory service → Stock records: updates stock
- Purchase service → Ledger service: records payments
- Ledger service → Ledger entries: appends entries
- Payment service → Ledger service: records payments
- Reports API → Expense service: gets expense totals
- Reports API → Order records: reads sales
- Reports API → MySQL database: queries data
- Audit API → MySQL database: queries event history
- AI API → AI service: delegates
- AI service → LLM provider: requests generation
- Tenant model scope → MySQL database: scopes model queries
- Authentication API → MySQL database: reads user data
