# abbasmuazam6-create/suitflow-api architecture

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

- Interactive diagram: https://gitdiagram.com/abbasmuazam6-create/suitflow-api
- Repository: https://github.com/abbasmuazam6-create/suitflow-api

## Overview

SuitFlow is a multi-business backend for suit businesses that trade or manufacture, with a separate platform-admin dashboard. The main workflow is a mobile/API request entering a versioned route, passing through tenant and feature controls, and reaching domain services for business operations such as production and stock. Platform administrators manage businesses and their users through web controllers. The graph preserves documented sales, purchasing, accounts, and reporting capabilities, but their exact service-to-service flows are not shown in the supplied excerpts; those relationships are therefore omitted. Some broader links rely on the SOURCE INDEX or README rather than inspected implementation.

Main entry points: [`routes/api/modules.php`](https://github.com/abbasmuazam6-create/suitflow-api/blob/main/routes/api/modules.php) (API routes), [`app/Services/StockService.php`](https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Services/StockService.php) (Stock management), [`app/Services/ProductionService.php`](https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Services/ProductionService.php) (Production workflow), [`app/Http/Controllers/Platform/BusinessController.php`](https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Http/Controllers/Platform/BusinessController.php) (Business dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Request entry"]
  node_api_routes["API routes<br/>[modules.php]"]
  node_web_routes["Web routes<br/>[web.php]"]
end

subgraph group_tenant["Tenant and access"]
  node_tenant_context["Tenant context<br/>[TenantContext.php]"]
  node_business_scope["Tenant scoping"]
  node_features["Feature controls<br/>[Features.php]"]
  node_permissions["Permissions<br/>[Permissions.php]"]
  node_auth_service["Authentication<br/>[AuthService.php]"]
  node_user_api["User API<br/>[UserController.php]"]
  node_user_model[("User identity<br/>[User.php]")]
  node_business_model[("Business tenant<br/>[Business.php]")]
end

subgraph group_operations["Business operations"]
  node_production_api["Production API"]
  node_production["Production workflow"]
  node_stock_api["Stock API"]
  node_stock["Stock management<br/>[StockService.php]"]
  node_sales_purchasing["Sales and purchasing"]
  node_accounts_reports["Accounts and reports"]
end

subgraph group_platform["Platform administration"]
  node_business_admin_api["Business API"]
  node_business_web["Business dashboard"]
  node_platform_users["Platform user admin<br/>[UserController.php]"]
  node_business_service["Business service"]
  node_platform_user_service["Platform user service"]
end

node_mobile(("Mobile app"))
node_platform_admin(("Platform admin"))
node_mysql[("MySQL")]

node_mobile -->|"calls API"| node_api_routes
node_api_routes -->|"routes to"| node_production_api
node_api_routes -->|"routes to"| node_stock_api
node_api_routes -->|"routes to"| node_sales_purchasing
node_api_routes -.->|"routes to"| node_accounts_reports
node_production_api -->|"delegates to"| node_production
node_stock_api -->|"delegates to"| node_stock
node_production -->|"updates stock"| node_stock
node_production -.->|"uses tenant models"| node_business_scope
node_stock -.->|"uses tenant models"| node_business_scope
node_stock -->|"checks options"| node_features
node_stock -.->|"reads and writes"| node_mysql
node_production -.->|"reads and writes"| node_mysql
node_tenant_context -->|"loads tenant"| node_business_model
node_tenant_context -->|"checks options"| node_features
node_auth_service -->|"finds user"| node_user_model
node_web_routes -->|"routes to"| node_business_web
node_web_routes -->|"routes to"| node_platform_users
node_platform_admin -.->|"uses dashboard"| node_web_routes
node_business_web -->|"delegates to"| node_business_service
node_platform_users -->|"delegates to"| node_platform_user_service
node_business_service -->|"manages"| node_business_model
node_platform_user_service -->|"manages"| node_user_model
node_business_web -.->|"reads and writes"| node_mysql

click node_api_routes "https://github.com/abbasmuazam6-create/suitflow-api/blob/main/routes/api/modules.php"
click node_web_routes "https://github.com/abbasmuazam6-create/suitflow-api/blob/main/routes/web.php"
click node_tenant_context "https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Support/Tenancy/TenantContext.php"
click node_business_scope "https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Models/Concerns/BelongsToBusiness.php"
click node_features "https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Support/Features.php"
click node_permissions "https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Support/Access/Permissions.php"
click node_auth_service "https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Services/AuthService.php"
click node_business_admin_api "https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Http/Controllers/Api/V1/Admin/BusinessController.php"
click node_user_api "https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Http/Controllers/Api/V1/UserController.php"
click node_production_api "https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Http/Controllers/Api/V1/ProductionBatchController.php"
click node_production "https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Services/ProductionService.php"
click node_stock_api "https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Http/Controllers/Api/V1/StockItemController.php"
click node_stock "https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Services/StockService.php"
click node_sales_purchasing "https://github.com/abbasmuazam6-create/suitflow-api/tree/main/app/Http/Controllers/Api/V1"
click node_accounts_reports "https://github.com/abbasmuazam6-create/suitflow-api/tree/main/app/Http/Controllers/Api/V1"
click node_business_web "https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Http/Controllers/Platform/BusinessController.php"
click node_platform_users "https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Http/Controllers/Platform/UserController.php"
click node_business_service "https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Services/BusinessService.php"
click node_platform_user_service "https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Services/PlatformUserService.php"
click node_user_model "https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Models/User.php"
click node_business_model "https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Models/Business.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_web_routes toneBlue
class node_tenant_context,node_business_scope,node_features,node_permissions,node_auth_service,node_user_api,node_user_model,node_business_model,node_mysql toneAmber
class node_production_api,node_production,node_stock_api,node_stock,node_sales_purchasing,node_accounts_reports toneMint
class node_business_admin_api,node_business_web,node_platform_users,node_business_service,node_platform_user_service toneRose
class node_mobile,node_platform_admin toneIndigo
```

## Components

### Request entry

- [API routes](https://github.com/abbasmuazam6-create/suitflow-api/blob/main/routes/api/modules.php): `routes/api/modules.php`
- [Web routes](https://github.com/abbasmuazam6-create/suitflow-api/blob/main/routes/web.php): `routes/web.php`

### Tenant and access

- [Tenant context](https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Support/Tenancy/TenantContext.php): `app/Support/Tenancy/TenantContext.php`
- [Tenant scoping](https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Models/Concerns/BelongsToBusiness.php): `app/Models/Concerns/BelongsToBusiness.php`
- [Feature controls](https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Support/Features.php): `app/Support/Features.php`
- [Permissions](https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Support/Access/Permissions.php): `app/Support/Access/Permissions.php`
- [Authentication](https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Services/AuthService.php): `app/Services/AuthService.php`
- [User API](https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Http/Controllers/Api/V1/UserController.php): `app/Http/Controllers/Api/V1/UserController.php`
- [User identity](https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Models/User.php): `app/Models/User.php`
- [Business tenant](https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Models/Business.php): `app/Models/Business.php`

### Business operations

- [Production API](https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Http/Controllers/Api/V1/ProductionBatchController.php): `app/Http/Controllers/Api/V1/ProductionBatchController.php`
- [Production workflow](https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Services/ProductionService.php): `app/Services/ProductionService.php`
- [Stock API](https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Http/Controllers/Api/V1/StockItemController.php): `app/Http/Controllers/Api/V1/StockItemController.php`
- [Stock management](https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Services/StockService.php): `app/Services/StockService.php`
- [Sales and purchasing](https://github.com/abbasmuazam6-create/suitflow-api/tree/main/app/Http/Controllers/Api/V1): `app/Http/Controllers/Api/V1`
- [Accounts and reports](https://github.com/abbasmuazam6-create/suitflow-api/tree/main/app/Http/Controllers/Api/V1): `app/Http/Controllers/Api/V1`

### Platform administration

- [Business API](https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Http/Controllers/Api/V1/Admin/BusinessController.php): `app/Http/Controllers/Api/V1/Admin/BusinessController.php`
- [Business dashboard](https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Http/Controllers/Platform/BusinessController.php): `app/Http/Controllers/Platform/BusinessController.php`
- [Platform user admin](https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Http/Controllers/Platform/UserController.php): `app/Http/Controllers/Platform/UserController.php`
- [Business service](https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Services/BusinessService.php): `app/Services/BusinessService.php`
- [Platform user service](https://github.com/abbasmuazam6-create/suitflow-api/blob/main/app/Services/PlatformUserService.php): `app/Services/PlatformUserService.php`

### Other components

- **Mobile app**
- **Platform admin**
- **MySQL**

## Connections

- Mobile app → API routes: calls API (evidence: `README.md`)
- API routes → Production API: routes to (evidence: `routes/api/modules.php`)
- API routes → Stock API: routes to (evidence: `routes/api/modules.php`)
- API routes → Sales and purchasing: routes to (evidence: `routes/api/modules.php`)
- API routes → Accounts and reports: routes to (evidence: `routes/api/modules.php`)
- Production API → Production workflow: delegates to (evidence: `app/Http/Controllers/Api/V1/ProductionBatchController.php`)
- Stock API → Stock management: delegates to (evidence: `app/Http/Controllers/Api/V1/StockItemController.php`)
- Production workflow → Stock management: updates stock (evidence: `app/Services/ProductionService.php`)
- Production workflow → Tenant scoping: uses tenant models
- Stock management → Tenant scoping: uses tenant models
- Stock management → Feature controls: checks options (evidence: `app/Services/StockService.php`)
- Stock management → MySQL: reads and writes
- Production workflow → MySQL: reads and writes
- Tenant context → Business tenant: loads tenant (evidence: `app/Support/Tenancy/TenantContext.php`)
- Tenant context → Feature controls: checks options (evidence: `app/Support/Tenancy/TenantContext.php`)
- Authentication → User identity: finds user (evidence: `app/Services/AuthService.php`)
- Web routes → Business dashboard: routes to (evidence: `routes/web.php`)
- Web routes → Platform user admin: routes to (evidence: `routes/web.php`)
- Platform admin → Web routes: uses dashboard
- Business dashboard → Business service: delegates to (evidence: `app/Http/Controllers/Platform/BusinessController.php`)
- Platform user admin → Platform user service: delegates to (evidence: `app/Http/Controllers/Platform/UserController.php`)
- Business service → Business tenant: manages (evidence: `app/Services/BusinessService.php`)
- Platform user service → User identity: manages (evidence: `app/Http/Controllers/Platform/UserController.php`)
- Business dashboard → MySQL: reads and writes
