> ## Documentation Index
> Fetch the complete documentation index at: https://docs.erp.arukz.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How ARUKZ ERP is built

> ARUKZ ERP is one Laravel 13 and Filament 5 application with about 50 plugins, serving every company from one MySQL database separated by company.

ARUKZ ERP is a single Laravel 13 application with a Filament 5 admin panel, built on the open-source Aureus ERP by Webkul. Every business area is a plugin: 28 come from Aureus ERP (`plugins/webkul/*`) and 21 are ARUKZ's own (`plugins/arukz/*`). One running copy and one MySQL database serve every customer company, and each business row carries a `company_id` that keeps companies apart.

## The stack

| Layer | Technology | What it does |
| - | - | - |
| Language | PHP 8.4 in the images (8.3 or later) | Runs everything |
| Framework | Laravel 13 | Routing, Eloquent, queues, scheduler, Sanctum API tokens |
| Admin UI | Filament 5 with Livewire 4 | Forms, tables and dashboards written in PHP, interactive without hand-written JavaScript |
| Permissions | Spatie Permission with Filament Shield | Roles and one permission per screen action |
| CSS | Tailwind CSS 4, built by Vite | The panel theme and the public pages |
| Database | MySQL 8 | One database for all companies |
| Tests | Pest 4 | Feature tests for tenancy, billing, isolation and each module |
| Runtime | nginx, PHP-FPM, a queue worker and the scheduler under Supervisor | One container image, or separate pods on Kubernetes |

> [!NOTE]
>
> Older notes in the repository (the root `README.md`, `AGENTS.md` and parts of `docs/`) still say Laravel 11 and Filament 4. The code runs Laravel 13 and Filament 5, as `composer.json` says. Filament 3 or 4 examples from the web usually do not work as they are; see [Build a custom plugin](https://docs.erp.arukz.com/developers/custom-plugin.md) for the class names that changed.

## The folders that matter

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
app/                       ARUKZ's SaaS layer: sign-up, tenants, plans, invoices, middleware
bootstrap/providers.php    every plugin's service provider, listed by hand
config/saas.php            SaaS switches: company paths, subdomains, reserved names
plugins/webkul/<module>/   Aureus ERP: sales, purchases, inventories, accounts, employees, ...
plugins/arukz/<module>/    ARUKZ: quality, payroll, gst-returns, tds, subcontracting, ai, ...
resources/views/landing/   the public website
routes/                    public routes; plugins register their own
tests/Feature/             Pest tests (Saas/, Arukz/, Dashboards/)
docker/                    the production image (production/) and the Kubernetes image (k8s/)
infra/                     Terraform for Hetzner and Kubernetes manifests
book/                      the developer book this section is drawn from
```

## Panels and addresses

| Panel | Address | Who signs in |
| - | - | - |
| Admin | `/<company>/admin` (and `/admin`) | Everyone who works in the ERP: ARUKZ platform staff, each company's admins and its employees |
| Customer portal | `/customer` | A company's own customers, to see their quotations and orders |

There is no panel per company. Every company uses the same panel and sees different rows. With company paths on (`SAAS_PATH_ROUTING`, on by default), the first path segment names the company and becomes the base URL, so every route, redirect and Livewire call stays under `/<company>/`. The segments `admin`, `customer`, `api`, `build`, `storage`, `filament` and `livewire` are reserved and never name a company, which is why the REST API stays at `/admin/api/v1`.

## What happens on one request

```mermaid theme={"theme":{"light":"github-light","dark":"github-dark"}}
sequenceDiagram
    participant B as Browser
    participant M as Middleware
    participant F as Filament page
    participant DB as MySQL
    B->>M: GET /acme/admin/sale/orders/quotations
    M->>M: Signed in and active?
    M->>M: Company from the address; user allowed in it?
    M->>M: Subscription active? Otherwise the locked page (402)
    M->>M: Module switched on for this company? Otherwise 403
    M->>F: Render the list
    F->>F: Does the role have view_any on quotations?
    F->>DB: SELECT ... WHERE company_id IN (user's companies) AND owner rule
    DB-->>F: This company's quotations only
    F-->>B: HTML, kept live by Livewire
```

Two query scopes do the separation:

* **`CompanyScope`**, added by the `BelongsToCompany` trait, filters every query to the user's active companies and fills in `company_id` on create.
* **`OwnershipScope`** narrows further by the user's record visibility: `global` (everything in their companies), `group` (their teams' records) or `individual` (only their own).

> [!WARNING]
>
> Both scopes switch themselves off in console commands and queue jobs, where there is no signed-in user. Code that runs there must filter by `company_id` itself.

## Caches

Production keeps four caches warm: config, routes and events (`php artisan optimize`), Filament components and icons (`php artisan filament:optimize`), compiled Blade views, and PHP opcache with timestamp checks off. After a code change, rebuild the caches **and** reload PHP-FPM, or PHP keeps running the old code. A changed `.env` also does nothing until `optimize` runs again. See [Operations](https://docs.erp.arukz.com/developers/operations.md).

## Licence

ARUKZ ERP is proprietary software of ARUKZ DIGITAL. It is built on [Aureus ERP](https://github.com/aureuserp/aureuserp) by Webkul Software, distributed under the MIT License; Webkul's licence is kept in `LICENSE` and applies to their code under `plugins/webkul/` and the application shell. `NOTICE.md` lists the other credits.

## Read next

> [card] [Data model](https://docs.erp.arukz.com/developers/data-model.md)
>
> Partners, products, companies and the header-and-lines pattern every document follows.

> [card] [Plugins](https://docs.erp.arukz.com/developers/plugins.md)
>
> What each plugin does and how plugins depend on each other.

> [card] [Self-hosting with Docker](https://docs.erp.arukz.com/developers/self-hosting-docker.md)
>
> Run a copy in one container, with the install steps for a new database.

> [card] [Testing](https://docs.erp.arukz.com/developers/testing.md)
>
> Run the Pest suites safely.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.