# CRIUS COMPRESSOR — Agent Guide

Laravel 12 · Bilingual ID/EN · Tailwind + Alpine.js — SQLite (default)

---

## Dev Commands

| Task | Command |
|------|---------|
| Start everything | `composer dev` — runs Vite + artisan serve + queue:listen via `concurrently` |
| Fresh DB + seed | `php artisan migrate:fresh --seed` |
| Build frontend | `npm run build` |
| Run tests | `php artisan test` (uses in-memory SQLite) |
| Code style | `vendor/bin/pint` |
| Generate sitemap | `php artisan sitemap:generate` |

**Admin login:** `/admin/login` — `admin@crius.com` / `password123`

---

## Bilingual Pattern (ID/EN)

No spatie package. Uses `_id`/`_en` suffix columns in every relevant table.

| Helper | Returns |
|--------|---------|
| `locale_field('name')` | `'name_id'` or `'name_en'` |
| `setting('key')` | Global site_settings value |
| `active_locale()` | `'id'` or `'en'` |
| `is_locale_en()` | `bool` |
| `image_url($path)` | Proper asset/storage URL |

Middleware `SetLocale` reads URL segment (`/en`) or falls back to session/locale.

---

## Architecture

### Routes
- **Frontend:** `routes/web.php` — all inside `SetLocale` middleware group (except `lang.switch`)
- **Admin:** `routes/admin.php` — prefix `admin/`, all inside `AdminAuth` middleware (except `login`)
- Frontend routes already defined; controllers already query DB

### Admin CRUD naming quirks
| Route URI | Controller |
|-----------|------------|
| `products/{id}/specs` | `ProductSpecController` (shallow, index/store/destroy only) |
| `products/{id}/images` | `ProductImageController` (shallow, index/store/destroy only) |
| `products/{id}/highlights` | `ProductHighlightController` (shallow, index/store/destroy only) |
| `blog-posts` | `BlogPostController` |
| `blog-categories` | `BlogCategoryController` |
| `career-applications` | `CareerApplicationController` (index/show/destroy only) |
| `contact-messages` | `ContactMessageController` (index/show/destroy only) |
| `settings/{group}/edit` + `settings/{group}` | `SiteSettingController` |

### Models
- Every model has scopes: `active()`, `ordered()`
- `Product::getGroupedSpecsAttribute` groups specs by `spec_group` (Performance|Technical|Physical|Electrical)
- `Product::getWhatsappLinkAttribute` auto-generates WA link

### Design System
- Reference: `crius-design-system-blue.html` (repo root)
- Tailwind colors under `crius-*` (navy, blue, blue-light, accent, etc.)
- Fonts: Archivo Black (display), Montserrat (body), Syne (mono), Syncopate (accent)

### Site Settings
- Table `site_settings`: key-value with `type` (text|textarea|image|boolean|json|color) and `group`
- Groups: general, homepage, about, contact, seo, integrations
- Access: `setting('key')` helper globally

### Uploads
- `intervention/image-laravel` IS installed (in composer.json)
- Disk: `public`, dirs: products, blog, team, brands, services, general (config in `config/crius.php`)

### Key tables dropped
- `team_members` — removed via migration `2026_05_19_054541_drop_team_members_table.php`. Do NOT create TeamMember references.

### Remaining gaps
- No application-specific tests exist (only PHPUnit boilerplate)
- No spatie/sitemap (own `GenerateSitemap` command exists)

---

## Agent Conventions

1. **Admin CRUD:** controller → `routes/admin.php` (AdminAuth group) → view in `resources/views/admin/{resource}/` using `admin.blade.php` layout + `crius-*` Tailwind tokens
2. **Frontend views:** use `app.blade.php` layout (navbar, footer, floating WA button built in)
3. **Language test:** check for both `locale_field('field')` pattern and direct `name_id`/`name_en` access
4. **Test setup:** Config clears before test suite — `@php artisan config:clear --ansi @no_additional_args`
