# CLAUDE.md This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. ## Project An ERP / work-management system (*toiminnanohjausjärjestelmä*) for a small (5–10 person) Finnish media/marketing company. Stack: Laravel 13, Livewire 4 (single-file components), Flux UI 2 free edition, Tailwind 4, Vite 8, Pest, Larastan. Domain code lives in modules under `app/Modules` (so far `Shared` and `Customers`); `/` is still a temporary Livewire demo page (`resources/views/pages/⚡home.blade.php`, layout `resources/views/layouts/app.blade.php`). There is no login yet, so module pages sit behind `auth` and are reachable only in tests (`actingAs`). - **The specification is `määrittely.txt`** (Finnish). It defines users/roles, customer jobs (*asiakastyö*) and their fields and enums, time tracking, expenses, Kanban tasks, the service unit → service → work task hierarchy, and billing-material export. It ends with Claude's open questions and a proposed phased plan. Read it before designing any domain feature. - **Language rule:** code (identifiers, tables, columns, enum keys) is in English; the specification and the UI are in Finnish. Keep UI strings in translation files from the start. - **Build in phases, not all at once.** Proposed order: (1) auth, users and roles, lightweight customers, customer jobs, mobile quick intake, time entries; (2) expenses, service units and pricing, billing export; (3) tasks, Kanban, workflow templates; (4) subcontractors, reports, notifications, billing software API. - **Access control is central.** Roles: admin (*pääkäyttäjä*), management (*johto*), employee (*työntekijä*), intern (*harjoittelija*), subcontractor (*alihankkija*). Employees and interns see only the jobs assigned to them and never see money amounts. Interns have an end date after which they can't log in, plus a supervisor. Subcontractors see only their assigned jobs. - **UI targets:** logged-in users only (no public pages besides login). It must work on phones (new-job intake, time entry) and on FullHD desktops. ## Architecture (modular monolith) Read `docs/architecture.md` (Finnish) before adding or changing domain code. `app/Modules/Customers` is the reference module to copy. - Each business area is a module `app/Modules//` with four layers: `Domain`, `Application`, `Infrastructure`, `Presentation`. Create only the folders and modules a feature needs. - **Domain** is plain PHP: entities, value objects, enums, exceptions extending `Shared\Domain\Exceptions\DomainException`, and repository interfaces in `Domain/Contracts`. No `Illuminate`, `Livewire`, Eloquent or facades. - **Application** holds one use case per class (`execute()`), `final readonly` DTOs, and query contracts that return DTOs. It never touches Eloquent, `Illuminate\Database`, facades or HTTP. Wrap writes in `Shared\Application\Contracts\TransactionManager` and publish events through `EventDispatcher` (dispatched after commit). - **Infrastructure** has Eloquent models named `…Model`, repository and query implementations, and the module's service provider (bindings, routes, `Livewire::addNamespace`), which is registered in `bootstrap/providers.php`. Migrations and factories stay in `database/`. - **Presentation** is Livewire SFC pages in `Presentation/Livewire` (`::page`), Livewire Form objects for input validation, and `Presentation/Routes/web.php`. Pages call use cases and query contracts, and turn domain exceptions into field errors with translated messages. - Modules talk only through another module's Application contracts or events, never its Infrastructure or Eloquent models. - `tests/Unit/ArchitectureTest.php` enforces these rules for every module. Domain and Application files declare `strict_types=1`. Test domain rules and use cases in `tests/Unit` without Laravel (fakes in `tests/Fakes`), and repositories and pages in `tests/Feature`. - When writing PHP through a bash heredoc, `\\` can collapse to `\`, and `"App\Modules\{$x}"` then stops interpolating. Write PHP files with the Write tool. ## Accessibility (WCAG 2.2 AA, EN 301 549) Accessibility is a contractual acceptance criterion. It covers the whole UI: navigation, forms, tables, reports, notifications, dialogs, login, and every business process. Every new or changed view must meet these rules: - Use Flux components first; they ship with correct roles, focus handling and keyboard support. Every form control goes in `flux:field` with a `flux:label` and a `flux:error` (or uses the shorthand `label` prop). Placeholder text is not a label. - Never convey meaning by colour alone. Statuses, priorities (e.g. *kiire* = red), errors and warnings always also have visible text or an icon with text. - Announce dynamic changes: put status text in `role="status"` / `aria-live="polite"` (errors: `role="alert"`), or use Flux toast. Keep button names stable instead of putting changing state in them. - Make everything work with the keyboard alone, with a visible focus indicator and no focus traps. Use `flux:modal` for dialogs, so focus moves in and returns. - The layout (`resources/views/layouts/app.blade.php`) provides a skip link and a `
` landmark. Keep them, and add `