|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +Berta is a file-based CMS (no database required for content storage). It has three distinct sub-applications that are developed and built independently: |
| 8 | + |
| 9 | +1. **`_api_app/`** — Laravel 12 API backend (PHP 8.2+) |
| 10 | +2. **`editor/`** — Angular 20 admin editor (TypeScript) |
| 11 | +3. **`engine/`** — Legacy PHP rendering engine with Gulp-built assets |
| 12 | + |
| 13 | +## Development Commands |
| 14 | + |
| 15 | +### Laravel API (`_api_app/`) |
| 16 | +```bash |
| 17 | +cd _api_app |
| 18 | +composer install |
| 19 | +php artisan test --compact # Run all tests |
| 20 | +php artisan test --compact --filter=TestName # Run specific test |
| 21 | +vendor/bin/pint --dirty # Format changed PHP files |
| 22 | +npm run dev # Vite dev server |
| 23 | +npm run build # Build assets |
| 24 | +``` |
| 25 | + |
| 26 | +### Angular Editor (`editor/`) |
| 27 | +```bash |
| 28 | +cd editor |
| 29 | +npm install |
| 30 | +npm run dev # Watch mode (outputs to engine/dist) |
| 31 | +npm run build # Production build (outputs to engine/dist) |
| 32 | +npm test # Karma/Jasmine unit tests |
| 33 | +``` |
| 34 | + |
| 35 | +### Legacy Engine Assets (root) |
| 36 | +```bash |
| 37 | +npm install |
| 38 | +npm run dev # Gulp watch (compiles Sass for themes/templates) |
| 39 | +npm run build # Gulp production build |
| 40 | +``` |
| 41 | + |
| 42 | +## Architecture |
| 43 | + |
| 44 | +### How the Parts Connect |
| 45 | + |
| 46 | +- The **Angular editor** (`editor/`) compiles into `engine/dist/` — the legacy PHP engine serves these compiled assets to the browser. |
| 47 | +- The **Laravel API** (`_api_app/`) exposes REST endpoints consumed by the Angular editor for CMS operations (site settings, sections, media, shop). |
| 48 | +- The **legacy PHP engine** (`engine/`) handles frontend rendering of sites using file-based XML storage. It reads `.xml` files directly from the user's site directory. |
| 49 | +- The Angular editor's **Twig templates** are bundled at build time via `editor/copy-twig-templates.mjs` and `editor/bundle-twig-templates.js` (prebuild step), then rendered client-side using the `twig` npm package. |
| 50 | + |
| 51 | +### Key Directories |
| 52 | + |
| 53 | +| Path | Purpose | |
| 54 | +|------|---------| |
| 55 | +| `_api_app/app/Sites/` | Site/section/entry management domain | |
| 56 | +| `_api_app/app/Shop/` | E-commerce plugin | |
| 57 | +| `_api_app/app/Plugins/` | Plugin system | |
| 58 | +| `_api_app/app/Configuration/` | App configuration classes | |
| 59 | +| `editor/src/` | Angular source (components, state, services) | |
| 60 | +| `engine/_classes/` | Legacy PHP classes for site rendering | |
| 61 | +| `engine/_lib/berta/` | CSS/JS assets bundled by Gulp | |
| 62 | +| `_themes/` | Site themes (capetown, jaipur, kyoto, madrid, etc.) | |
| 63 | +| `_templates/` | Email/system templates with SCSS | |
| 64 | +| `_plugin_shop/` | Shop plugin PHP files | |
| 65 | + |
| 66 | +### State Management (Angular) |
| 67 | + |
| 68 | +The editor uses **NGXS** for state management. State files live in `editor/src/app/**/state/` alongside their actions. |
| 69 | + |
| 70 | +### Authentication |
| 71 | + |
| 72 | +Laravel Sanctum handles API auth. JWT tokens (Firebase JWT) are used for certain operations. |
| 73 | + |
| 74 | +## Laravel API Guidelines |
| 75 | + |
| 76 | +See `_api_app/CLAUDE.md` for detailed Laravel/PHP conventions, Pest testing rules, and Laravel Boost MCP tool usage. Those guidelines apply whenever working inside `_api_app/`. |
0 commit comments