# lurkerwin22/erp architecture

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

## Overview

Anypli ERP is a Laravel web application for managing sales, purchasing, inventory, customer debts, quotes, and business reporting, with an ERP-focused AI assistant. The main workflow is a user submitting an operation through the web interface; controllers validate and process it, update business records and stock where applicable, then render a result. The AI branch stores conversation history and routes messages to an agent. Sampled controller excerpts support several links; other modules are included from the README and tree, so their internal wiring is not inferred.

Main entry points: [`routes/web.php`](https://github.com/lurkerwin22/erp/blob/main/routes/web.php) (Web routes), [`app/Models`](https://github.com/lurkerwin22/erp/tree/main/app/Models) (Business records), [`app/Services/Ai/Services/AiAgentService.php`](https://github.com/lurkerwin22/erp/blob/main/app/Services/Ai/Services/AiAgentService.php) (AI agent), [`app/Http/Controllers/SaleController.php`](https://github.com/lurkerwin22/erp/blob/main/app/Http/Controllers/SaleController.php) (Sales and invoices)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_routes["Web routes<br/>[web.php]"]
  node_views["Blade screens"]
  node_frontend["Browser interactions<br/>[app.js]"]
end

subgraph group_operations["ERP operations"]
  node_sales["Sales and invoices<br/>[SaleController.php]"]
  node_purchases["Purchasing"]
  node_quotes["Quotes"]
  node_inventory["Stock management"]
  node_catalog["Products and categories"]
  node_customers["Customer management"]
  node_suppliers["Supplier management"]
  node_debts["Debt management<br/>[DebtController.php]"]
end

subgraph group_insights["Reporting and AI"]
  node_dashboard["Dashboard"]
  node_reports["Report API"]
  node_ai_ui["AI assistant endpoint"]
  node_conversation["Conversation service"]
  node_agent["AI agent<br/>[AiAgentService.php]"]
  node_intent["Intent routing<br/>[IntentRouter.php]"]
  node_tool_registry["Tool registry<br/>[ToolRegistry.php]"]
  node_ai_tools["ERP query tools"]
end

subgraph group_identity["Access and records"]
  node_models["Business records"]
  node_database[("Application database<br/>[database.php]")]
  node_auth["Authentication and roles"]
  node_role_middleware["Role enforcement<br/>[RoleMiddleware.php]"]
end

node_user(("ERP user"))
node_llm{{"LLM service"}}

node_user -->|"submits requests"| node_routes
node_routes -->|"dispatches"| node_sales
node_routes -->|"dispatches"| node_purchases
node_routes -->|"dispatches"| node_quotes
node_routes -->|"dispatches"| node_inventory
node_routes -->|"dispatches"| node_catalog
node_routes -->|"dispatches"| node_customers
node_routes -->|"dispatches"| node_suppliers
node_routes -->|"dispatches"| node_debts
node_routes -->|"dispatches"| node_dashboard
node_routes -->|"dispatches"| node_reports
node_routes -->|"dispatches"| node_ai_ui
node_routes -->|"dispatches"| node_auth
node_user -->|"uses interactions"| node_frontend
node_sales -->|"reads and updates"| node_models
node_purchases -->|"reads and updates"| node_models
node_quotes -->|"reads and updates"| node_models
node_models -->|"persists records"| node_database
node_sales -->|"renders screens"| node_views
node_purchases -->|"renders screens"| node_views
node_quotes -->|"renders screens"| node_views
node_ai_ui -->|"stores messages"| node_conversation
node_ai_ui -->|"sends context"| node_agent
node_conversation -->|"reads and writes"| node_models
node_agent -->|"routes intent"| node_intent
node_agent -->|"dispatches tools"| node_tool_registry
node_tool_registry -->|"selects tool"| node_ai_tools
node_ai_tools -->|"queries ERP data"| node_models
node_agent -.->|"requests completion"| node_llm
node_reports -->|"executes report tools"| node_ai_tools
node_auth -->|"checks access"| node_role_middleware
node_role_middleware -->|"guards routes"| node_routes

click node_routes "https://github.com/lurkerwin22/erp/blob/main/routes/web.php"
click node_views "https://github.com/lurkerwin22/erp/tree/main/resources/views"
click node_frontend "https://github.com/lurkerwin22/erp/blob/main/resources/js/app.js"
click node_sales "https://github.com/lurkerwin22/erp/blob/main/app/Http/Controllers/SaleController.php"
click node_purchases "https://github.com/lurkerwin22/erp/blob/main/app/Http/Controllers/PurchaseController.php"
click node_quotes "https://github.com/lurkerwin22/erp/blob/main/app/Http/Controllers/QuoteController.php"
click node_inventory "https://github.com/lurkerwin22/erp/blob/main/app/Http/Controllers/StockController.php"
click node_catalog "https://github.com/lurkerwin22/erp/blob/main/app/Http/Controllers/ProductController.php"
click node_customers "https://github.com/lurkerwin22/erp/blob/main/app/Http/Controllers/CustomerController.php"
click node_suppliers "https://github.com/lurkerwin22/erp/blob/main/app/Http/Controllers/SupplierController.php"
click node_debts "https://github.com/lurkerwin22/erp/blob/main/app/Http/Controllers/DebtController.php"
click node_dashboard "https://github.com/lurkerwin22/erp/blob/main/app/Http/Controllers/DashboardController.php"
click node_reports "https://github.com/lurkerwin22/erp/blob/main/app/Http/Controllers/Api/ReportController.php"
click node_ai_ui "https://github.com/lurkerwin22/erp/blob/main/app/Http/Controllers/Ai/AiAssistantController.php"
click node_conversation "https://github.com/lurkerwin22/erp/blob/main/app/Services/Ai/AiConversationService.php"
click node_agent "https://github.com/lurkerwin22/erp/blob/main/app/Services/Ai/Services/AiAgentService.php"
click node_intent "https://github.com/lurkerwin22/erp/blob/main/app/Services/Ai/Services/IntentRouter.php"
click node_tool_registry "https://github.com/lurkerwin22/erp/blob/main/app/Services/Ai/Services/ToolRegistry.php"
click node_ai_tools "https://github.com/lurkerwin22/erp/tree/main/app/Services/Ai/Tools"
click node_models "https://github.com/lurkerwin22/erp/tree/main/app/Models"
click node_database "https://github.com/lurkerwin22/erp/blob/main/config/database.php"
click node_auth "https://github.com/lurkerwin22/erp/blob/main/app/Http/Controllers/SessionController.php"
click node_role_middleware "https://github.com/lurkerwin22/erp/blob/main/app/Http/Middleware/RoleMiddleware.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_routes,node_views,node_frontend,node_user toneBlue
class node_sales,node_purchases,node_quotes,node_inventory,node_catalog,node_customers,node_suppliers,node_debts toneAmber
class node_dashboard,node_reports,node_ai_ui,node_conversation,node_agent,node_intent,node_tool_registry,node_ai_tools toneMint
class node_models,node_database,node_auth,node_role_middleware toneRose
class node_llm toneIndigo
```

## Components

### Web experience

- [Web routes](https://github.com/lurkerwin22/erp/blob/main/routes/web.php): `routes/web.php`
- [Blade screens](https://github.com/lurkerwin22/erp/tree/main/resources/views): `resources/views`
- [Browser interactions](https://github.com/lurkerwin22/erp/blob/main/resources/js/app.js): `resources/js/app.js`

### ERP operations

- [Sales and invoices](https://github.com/lurkerwin22/erp/blob/main/app/Http/Controllers/SaleController.php): `app/Http/Controllers/SaleController.php`
- [Purchasing](https://github.com/lurkerwin22/erp/blob/main/app/Http/Controllers/PurchaseController.php): `app/Http/Controllers/PurchaseController.php`
- [Quotes](https://github.com/lurkerwin22/erp/blob/main/app/Http/Controllers/QuoteController.php): `app/Http/Controllers/QuoteController.php`
- [Stock management](https://github.com/lurkerwin22/erp/blob/main/app/Http/Controllers/StockController.php): `app/Http/Controllers/StockController.php`
- [Products and categories](https://github.com/lurkerwin22/erp/blob/main/app/Http/Controllers/ProductController.php): `app/Http/Controllers/ProductController.php`
- [Customer management](https://github.com/lurkerwin22/erp/blob/main/app/Http/Controllers/CustomerController.php): `app/Http/Controllers/CustomerController.php`
- [Supplier management](https://github.com/lurkerwin22/erp/blob/main/app/Http/Controllers/SupplierController.php): `app/Http/Controllers/SupplierController.php`
- [Debt management](https://github.com/lurkerwin22/erp/blob/main/app/Http/Controllers/DebtController.php): `app/Http/Controllers/DebtController.php`

### Reporting and AI

- [Dashboard](https://github.com/lurkerwin22/erp/blob/main/app/Http/Controllers/DashboardController.php): `app/Http/Controllers/DashboardController.php`
- [Report API](https://github.com/lurkerwin22/erp/blob/main/app/Http/Controllers/Api/ReportController.php): `app/Http/Controllers/Api/ReportController.php`
- [AI assistant endpoint](https://github.com/lurkerwin22/erp/blob/main/app/Http/Controllers/Ai/AiAssistantController.php): `app/Http/Controllers/Ai/AiAssistantController.php`
- [Conversation service](https://github.com/lurkerwin22/erp/blob/main/app/Services/Ai/AiConversationService.php): `app/Services/Ai/AiConversationService.php`
- [AI agent](https://github.com/lurkerwin22/erp/blob/main/app/Services/Ai/Services/AiAgentService.php): `app/Services/Ai/Services/AiAgentService.php`
- [Intent routing](https://github.com/lurkerwin22/erp/blob/main/app/Services/Ai/Services/IntentRouter.php): `app/Services/Ai/Services/IntentRouter.php`
- [Tool registry](https://github.com/lurkerwin22/erp/blob/main/app/Services/Ai/Services/ToolRegistry.php): `app/Services/Ai/Services/ToolRegistry.php`
- [ERP query tools](https://github.com/lurkerwin22/erp/tree/main/app/Services/Ai/Tools): `app/Services/Ai/Tools`

### Access and records

- [Business records](https://github.com/lurkerwin22/erp/tree/main/app/Models): `app/Models`
- [Application database](https://github.com/lurkerwin22/erp/blob/main/config/database.php): `config/database.php`
- [Authentication and roles](https://github.com/lurkerwin22/erp/blob/main/app/Http/Controllers/SessionController.php): `app/Http/Controllers/SessionController.php`
- [Role enforcement](https://github.com/lurkerwin22/erp/blob/main/app/Http/Middleware/RoleMiddleware.php): `app/Http/Middleware/RoleMiddleware.php`

### Other components

- **ERP user**
- **LLM service**

## Connections

- ERP user → Web routes: submits requests
- Web routes → Sales and invoices: dispatches
- Web routes → Purchasing: dispatches
- Web routes → Quotes: dispatches
- Web routes → Stock management: dispatches
- Web routes → Products and categories: dispatches
- Web routes → Customer management: dispatches
- Web routes → Supplier management: dispatches
- Web routes → Debt management: dispatches
- Web routes → Dashboard: dispatches
- Web routes → Report API: dispatches
- Web routes → AI assistant endpoint: dispatches
- Web routes → Authentication and roles: dispatches
- ERP user → Browser interactions: uses interactions
- Sales and invoices → Business records: reads and updates
- Purchasing → Business records: reads and updates
- Quotes → Business records: reads and updates
- Business records → Application database: persists records
- Sales and invoices → Blade screens: renders screens
- Purchasing → Blade screens: renders screens
- Quotes → Blade screens: renders screens
- AI assistant endpoint → Conversation service: stores messages
- AI assistant endpoint → AI agent: sends context
- Conversation service → Business records: reads and writes
- AI agent → Intent routing: routes intent
- AI agent → Tool registry: dispatches tools
- Tool registry → ERP query tools: selects tool
- ERP query tools → Business records: queries ERP data
- AI agent → LLM service: requests completion
- Report API → ERP query tools: executes report tools
- Authentication and roles → Role enforcement: checks access
- Role enforcement → Web routes: guards routes
