CLAUDE.md: localization now describes core's locale middleware, $currentLocale/$altLocales and storefront.* Language Lines (there are no lang/ files or SetLocale); the stack is Lunar 1.5, Postgres, Meilisearch, Caddy, no Turbo; the design-reference section pointed at files nobody has, and the component checklist was out of date. CACHING-TRANSITION.md: records the 2026-11-06 changes (no Turbo, JSON islands and writes, one bb_state cookie, prefetch instead of prerender), a status table per task, the A4/A9 rework, and sources that the team can actually reach. README: known issues found while writing the boboko plugin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
330 lines
18 KiB
Markdown
330 lines
18 KiB
Markdown
# Caching transition: context and first tasks (for Claude)
|
||
|
||
> **Temporary roadmap.** Delete this file once the caching transition is
|
||
> done; it's only needed while the work is in progress.
|
||
|
||
Written 2026-11-02 from a planning session in `boboko-research`, updated the
|
||
same day with the team's decisions. Read this before working on the tasks
|
||
below. Front-end conventions are still in [CLAUDE.md](CLAUDE.md), and that
|
||
file wins on style, Greek register, localization and performance rules.
|
||
|
||
Source documents (outside this repo, read-only for context):
|
||
- The research repo (`lexx/research` on code.radical-elements.com), `products/boboko/`:
|
||
- `caching-islands.md`: the target design (partly superseded, see "Changed on 2026-11-06")
|
||
- `tech-platform.md`: the platform plan
|
||
- `manifesto.md`: the principles decisions are checked against
|
||
- `tasks.md` (the full task list and **source of truth for task ids**) and `team-discussion.md`
|
||
(open items D7, D10) were written in the same planning session but aren't in the research
|
||
repo. Ask the team for them.
|
||
|
||
The rules that come out of this work are written up as skills in the **`boboko` Claude Code
|
||
plugin** (re-skills marketplace): `cacheable-pages` above all, plus `storefront-frontend`,
|
||
`storefront-performance` and `storefront-translations`.
|
||
|
||
Every task is also a card on the Planka board (3dealer.gr → Development,
|
||
label **Transition**). The task id (A1, W1…) is in each card's description.
|
||
|
||
**boboko-core is paused** (the backend developer is on leave). Only do the
|
||
tasks below that don't need core. A0 waits until core work resumes.
|
||
|
||
## Where we're going
|
||
|
||
**Every catalogue page becomes the same HTML for every visitor**, cached
|
||
(probably as static files Caddy serves without PHP). Anything personal (cart,
|
||
login state, wishlist, CSRF token) comes from **one small "islands" request**
|
||
that runs only when the visitor has a state cookie, and is answered with
|
||
**JSON** that Stimulus applies to elements already in the page.
|
||
|
||
- Cacheable routes (home, category, product, `/products`, FAQ, legal pages)
|
||
will run **without a session**: no cookies, no CSRF token, no `auth()`, no
|
||
flash, no `old()`, no `$errors`.
|
||
- Session routes (cart, checkout, account, login, contact, islands, writes)
|
||
stay in `web`.
|
||
- Writes (add to cart, wishlist toggle, review) are normal forms enhanced with
|
||
`fetch`, answered with JSON. New markup (e.g. a new review) is cloned from a
|
||
Blade-rendered `<template>` of the same component.
|
||
|
||
**Changed on 2026-11-06 (these replace the matching 2026-11-02 decisions below):**
|
||
- **No Turbo at all**: no Drive, Frames or Streams. Islands and writes answer with
|
||
**JSON**; Stimulus applies it as text and attributes on existing targets. New
|
||
markup comes from a Blade `<template>` of the same component, filled with
|
||
`textContent`, the same pattern as the Meilisearch search cards. Existing Turbo
|
||
code (listing/search Frames, the review Streams from A4) gets replaced.
|
||
- **One hint cookie, `bb_state=1`** (has a cart, a login or a wishlist item), with
|
||
no count in it. One `GET /{locale}/islands` when it's present, nothing otherwise.
|
||
- **Speculation Rules: `prefetch`, not `prerender`.** Prerender runs every analytics,
|
||
pixel and consent script on pages nobody may see. Revisit only once pages are
|
||
cached and the pilot shows analytics stay correct.
|
||
- **Where the standard storefront template lives** (core or starter) is decided once
|
||
3dealer is ready.
|
||
|
||
**Decided (2026-11-02):**
|
||
- ~~Turbo Streams for islands and writes~~ (replaced: JSON, see above); the cart
|
||
badge starts as a fixed-size placeholder.
|
||
- Laravel 13 (core C0, then A0 here), once core work resumes.
|
||
- **Page cache: static files** served by Caddy (later tasks P1–P3).
|
||
- **No Turbo Drive** (now: no Turbo at all). A normal multi-page site plus
|
||
Speculation Rules, View Transitions and back/forward cache (A7–A9 here).
|
||
- **Caddy** replaces nginx (W1, the last task in this file).
|
||
- **Search and filters will run in the browser against Meilisearch** through
|
||
Caddy on a subdomain, with the card as one Blade component reused through a
|
||
`<template>` (Meilisearch track M1–M6, not in this list).
|
||
- **URLs become id + slug** (`/el/products/123-blue-vase`), core C7 first,
|
||
then A10 here (not in this file).
|
||
- `view:cache` was commented out by mistake (A6).
|
||
|
||
## Where 3dealer is today (personal state found in catalogue pages)
|
||
|
||
| What | Where | Handled by |
|
||
|---|---|---|
|
||
| `auth()->check()` branching (4 places) | `resources/views/components/header.blade.php` | **A2** |
|
||
| Cart badge count | header, `data-cart-count-target="badge"`; primed from the drawer's server-rendered count | **A1** (placeholder), core C2/C3 (content) |
|
||
| Cart drawer body rendered on every page | `@include('checkout::drawer')` in `layouts/app.blade.php` (view lives in boboko-core) | core C3, **not here** |
|
||
| Wishlist heart state | `components/wishlist-button.blade.php` calls `WishlistService::has()` | **A3** (target only), core C3 (state) |
|
||
| Review flash, `old()`, `$errors`, `mergeJustSubmittedReview` | `product/show.blade.php`, `components/review-form.blade.php`, `ProductController` | **A4** |
|
||
| `@csrf` in forms + `<meta name="csrf-token">` | add-to-cart (core), wishlist, review, newsletter, layout | Later (CS1 in core, CS2 here, after Laravel 13 and core C2). **Leave as is** |
|
||
| Stoic staff embed (`@auth('staff')`) | `layouts/app.blade.php` | Core C2 (via islands), **not here**. Stoic itself may be dropped later |
|
||
|
||
Other facts worth knowing:
|
||
- Turbo is installed, but **Drive is off** (`window.Turbo.session.drive = false`
|
||
in `resources/js/app.js`). Frames drive the listing, search and sort. **The
|
||
direction is no Turbo at all**: don't add to it; Frames go away with the
|
||
Meilisearch track, and `@hotwired/turbo` is removed once nothing uses it.
|
||
- Catalogue data comes from Meilisearch via boboko-core's `ProductService`.
|
||
Listings use query-string filters. Don't change that in these tasks; the
|
||
browser-side rewrite is the M track.
|
||
- Product reviews have **no moderation**: they go live immediately. The index
|
||
update is async, which is why `mergeJustSubmittedReview` exists.
|
||
- URLs use numeric ids (`/products/{id}`). Don't change routes in these
|
||
tasks; that's A10, after core C7.
|
||
|
||
## Rules for this work
|
||
|
||
- **3dealer only.** Don't edit `vendor/boboko/core` or `../boboko-core`. If a
|
||
task turns out to need a core change, stop and write down what's needed
|
||
instead (core tasks are planned separately in `tasks.md`).
|
||
- **The site must keep working exactly as today** after each task. These
|
||
tasks prepare the page; they don't switch on caching.
|
||
- Only the tasks in this file (A1–A9, W1; A0 once core resumes). The other
|
||
decided work (page cache, Meilisearch in the browser, URLs) needs core
|
||
first and has its own tasks and order.
|
||
- Follow the `{locale}` controller rule in CLAUDE.md (`$locale` is the first
|
||
parameter).
|
||
- UI strings: reuse existing `storefront.*` keys where possible. New keys are
|
||
DB-backed Language Lines (the `storefront-translations` skill), never `lang/`
|
||
files, and they must reach core's seeder (`boboko:translations:pull`).
|
||
|
||
## Status (2026-11-06)
|
||
|
||
| Task | Status |
|
||
|---|---|
|
||
| A0 Laravel 13 | Waiting for core C0 |
|
||
| A1 Cart badge placeholder | Done (`6948c13`) |
|
||
| A2 Header without login checks | Done (`702609d`) |
|
||
| A3 Stable island targets | Done (`4fc7880`) |
|
||
| A4 Reviews without a redirect | Done with Turbo Streams (`f0a1b92`). **Rework to JSON** (see A4 below) |
|
||
| A5 Personal-state test | Not started |
|
||
| A6 `view:cache` in deploy | Done (`1ff55ac`) |
|
||
| A7 View Transitions | Done (`bad5a7d`) |
|
||
| A8 Back/forward cache | No commit yet |
|
||
| A9 Speculation Rules | Done with `prerender` (`c1acc00`). **Switch to `prefetch`** (see A9 below) |
|
||
| W1 Caddy | Done (`6d88d53`) |
|
||
|
||
## Tasks to work on now
|
||
|
||
### A0. Laravel 13 (S, waits for core C0: skip for now)
|
||
|
||
**Only once boboko-core has a tagged release that allows `laravel/framework
|
||
^13`.** Until then, skip it and do the others.
|
||
|
||
- Bump `laravel/framework` to `^13.0` and update `boboko/core` to that
|
||
release. Lunar stays on 1.5.0.
|
||
- Go through the Laravel 13 upgrade guide for app code (config, middleware in
|
||
`bootstrap/app.php`, anything deprecated), and note what changed around
|
||
CSRF (the `Sec-Fetch-Site` origin check) for later tasks CS1/CS2.
|
||
- Click through: home, category, product, search, cart drawer, checkout with
|
||
Stripe test mode, account, login/logout, the admin panel.
|
||
- **Done when:** `composer.lock` is on Laravel 13, the tests pass, and the
|
||
click-through shows nothing broken.
|
||
|
||
### A1. Cart badge as a fixed-size placeholder (S)
|
||
|
||
- The badge in `components/header.blade.php` (`data-cart-count-target="badge"`)
|
||
is `absolute` inside the button, so its appearance probably doesn't shift
|
||
the layout. **Verify** on mobile and desktop widths (CLS: no movement of the
|
||
header or icons when the count appears or changes, including 1 → 2 digits).
|
||
- Give it a stable `id` (e.g. `cart-badge`) so a Turbo Stream can target it.
|
||
- Keep `cart-count-controller.js` working as today (it listens for
|
||
`bbk-cart:updated`).
|
||
- **Rule to record in a comment:** no island may change the size of its
|
||
container.
|
||
- **Done when:** a stable id exists, behaviour is unchanged, and no layout
|
||
shift is measurable.
|
||
|
||
### A2. Header links that don't depend on login (S)
|
||
|
||
- The account icon always links to `route('account')`. The `auth` middleware
|
||
already redirects guests to login (`redirectGuestsTo` in
|
||
`bootstrap/app.php`).
|
||
- The wishlist icon always links to `route('wishlist')`. Make
|
||
`WishlistController::guest` redirect logged-in users to `account.wishlist`.
|
||
- One neutral aria-label for the account link (`storefront.nav.account`)
|
||
instead of switching to the login label.
|
||
- Both the desktop and mobile parts of the header (≈ lines 50–62 and 175–189).
|
||
- **Done when:** `header.blade.php` contains no `auth()` call, and guests and
|
||
logged-in users still end up on the right pages.
|
||
|
||
### A3. Stable island targets in the markup (S)
|
||
|
||
- `x-wishlist-button`: add `data-wishlist-product="{{ $productId }}"` on the
|
||
form root. **Keep** the current server-side `aria-pressed` state for now
|
||
(core will move it to islands later).
|
||
- The account link: a stable `id` (e.g. `header-account-link`) on both the
|
||
desktop and mobile versions, or one shared attribute selector.
|
||
- `<meta name="csrf-token">` in the layout: a stable `id` (e.g. `csrf-token`).
|
||
- **Done when:** each personal element has a stable selector, with no visible
|
||
change.
|
||
|
||
### A4. Review submission without a redirect (M)
|
||
|
||
Today `ProductController::storeReview` validates, creates a `ProductReview`,
|
||
calls `searchableSync()`, and redirects to `?tab=reviews#product-tabs` with
|
||
`withErrors`/`withInput` or a `reviewSubmitted` + `justSubmittedReview` flash.
|
||
|
||
Change it to (**updated 2026-11-06: JSON, no Turbo**; the first version used
|
||
Turbo Streams and needs reworking):
|
||
- A Stimulus controller that submits the form with `fetch` and
|
||
`Accept: application/json`. Remove `data-turbo="true"` and the stream views
|
||
(`product/streams/`).
|
||
- **Success:** a JSON response (the review, display-ready, plus count and
|
||
average). The controller clones a Blade-rendered `<template>` of the same
|
||
review component, fills its slots with `textContent`, prepends it to the
|
||
list, updates the count and average, and swaps the form for the thank-you.
|
||
- **Validation errors:** 422 with `{ "errors": { … } }` (what
|
||
`$request->validate()` already returns for a JSON request), filled into the
|
||
form's existing error slots, with `aria-invalid`. No session `old()`/`$errors`.
|
||
- Remove `session('reviewSubmitted')` from `product/show.blade.php`,
|
||
`old()`/`$errors` from `review-form.blade.php`, and
|
||
`mergeJustSubmittedReview` and the `justSubmittedReview` flash from the
|
||
controller.
|
||
- Keep `searchableSync()`.
|
||
- **No-JS fallback:** a plain POST may still redirect back to the product
|
||
page. That fallback may lose inline errors, which is acceptable.
|
||
- Accessibility: announce the result in a live region, and move focus to the
|
||
thank-you message or the first invalid field.
|
||
- Leave the `?tab=reviews` query parameter alone for now, but note it: it's a
|
||
query-string variant of the product page, which matters once pages are
|
||
cached.
|
||
- **Done when:** a submitted review appears immediately without a page load,
|
||
errors show inline, and nothing on the product page reads the session.
|
||
|
||
### A5. Test for personal state on catalogue pages (S)
|
||
|
||
- A feature test (in this repo's existing `tests/` setup) that renders home, a
|
||
category, a product, `/products`, FAQ and the legal pages **as a guest**, and
|
||
asserts the HTML has no per-visitor content.
|
||
- Start with assertions that pass after A2–A4 (no `auth()`-dependent markup,
|
||
no review flash/old input), and **mark the rest as expected failures/skipped
|
||
with a reason**: the drawer cart body and wishlist state (core C3), the CSRF
|
||
token (CS1/CS2), and the Stoic staff embed (core C2).
|
||
- It will need seeded catalogue data, or Meilisearch mocked through
|
||
`ProductService`. Check how the app can be booted in tests first, and say
|
||
so if that's harder than an S.
|
||
- **Done when:** the test runs in CI/locally, passes for what's done, and lists
|
||
what's still missing.
|
||
|
||
### A6. Turn `view:cache` back on in the deploy (S)
|
||
|
||
- In `Envoy.blade.php` (`artisan_optimize` task), uncomment the `view:cache`
|
||
line and give it the same `< /dev/null` as its neighbours.
|
||
- First run `php artisan view:cache` locally (in the app container). It
|
||
compiles **every** view, vendor ones included, so a broken view that is
|
||
never rendered would now fail the deploy. Fix or remove any that fail.
|
||
- **Done when:** `view:cache` runs cleanly locally and is in the deploy.
|
||
|
||
### A7. Cross-document View Transitions (S)
|
||
|
||
- Add `@view-transition { navigation: auto; }` to the CSS, inside
|
||
`@media (prefers-reduced-motion: no-preference)` so it's off for visitors
|
||
who ask for less motion.
|
||
- Check in Chrome that the header, the cart drawer and the cookie banner
|
||
don't flash or jump during a transition. If the default cross-fade looks
|
||
wrong on some element, give it a `view-transition-name` or exclude it;
|
||
keep it minimal.
|
||
- Browsers without support just navigate normally. Turbo Frame listing
|
||
updates aren't document navigations, so they're unaffected.
|
||
- **Done when:** page changes cross-fade in Chrome, nothing else changes
|
||
visibly, and reduced-motion turns it off.
|
||
|
||
### A8. Back/forward cache eligibility (S)
|
||
|
||
- In Chrome DevTools → Application → Back/forward cache, run the test on
|
||
home, a category, a product and `/products`, as a guest and logged in.
|
||
- Fix every blocker it reports that lives in 3dealer: `unload` listeners
|
||
(ours or a third-party script's), `Cache-Control: no-store` on catalogue
|
||
pages, open connections. Use `pagehide` instead of `unload` where something
|
||
needs to run on leave.
|
||
- Known gap, **not here**: a restored page shows the cart as it was. Core's
|
||
C2 refreshes on `pageshow` with `event.persisted`. Just note it.
|
||
- Write down any blocker that only core or a vendor script can fix.
|
||
- **Done when:** the DevTools test reports "restored from back/forward cache"
|
||
on those pages, or each remaining blocker is listed with its owner.
|
||
|
||
### A9. Speculation Rules (S)
|
||
|
||
> **Updated 2026-11-06:** use `prefetch`, not `prerender` (see "Changed on
|
||
> 2026-11-06"). The rest of this task stands; once Turbo Frames are gone, the
|
||
> Frame-link exclusions can go too.
|
||
|
||
- In the layout, a `<script type="speculationrules">` with `prerender`,
|
||
`eagerness: "moderate"` (hover or press), for same-origin links.
|
||
- **Exclude:** cart, checkout, account, login, logout (it's a POST, but
|
||
exclude the path anyway), wishlist, `/islands` (future), links with
|
||
`rel~=nofollow`, links inside the Turbo Frame listing controls (filters,
|
||
sort, pagination: those load into the frame, not as a new page), and
|
||
anything marked `data-no-prerender`. Use `where` with `href_matches` /
|
||
`selector_matches`.
|
||
- Check that GA4 and the consent banner count a page view **only when the
|
||
prerendered page is actually shown** (DevTools → Application → Speculative
|
||
loads lets you inspect a prerendered page). If one doesn't, delay it on
|
||
`document.prerendering` / `prerenderingchange`.
|
||
- Until pages are cached, each prerender is a full PHP render with 8 FPM
|
||
workers. Mention it in the commit message so production FPM is watched
|
||
after the deploy.
|
||
- **Done when:** hovering a product or category link in Chrome prerenders it
|
||
(visible in DevTools), excluded links don't, and analytics counts are
|
||
unchanged.
|
||
|
||
### W1. Caddy instead of nginx (M)
|
||
|
||
- Today: `docker/nginx/default.conf` (dev) and `prod.conf` (prod, with the
|
||
FastCGI cache block), `nginx` service in `docker-compose.yml`.
|
||
- A Caddy image built with `xcaddy`, including the `caddy-ratelimit` module
|
||
(needed later for the search subdomain M3 and rate limits F7). Pin the
|
||
Caddy and module versions.
|
||
- Caddyfile: `php_fastcgi` to the app container, static assets from
|
||
`public/` with the same long cache headers nginx sends, compression
|
||
(zstd/gzip), the same security headers, the same upload size limit, the
|
||
`/up` health check. Copy each rule over deliberately; list anything you
|
||
drop and why.
|
||
- **No page cache in Caddy** and no FastCGI-style cache: the static page
|
||
cache comes later (P2).
|
||
- **TLS:** find out first how it ends today (a host proxy, Cloudflare, or
|
||
the container). Don't switch on Caddy's automatic TLS until that's clear;
|
||
ask if it isn't findable in the repo or Envoy.
|
||
- Dev stays usable (`docker compose up` works, Vite still proxied as today).
|
||
- Remove the nginx files and service once Caddy works. boboko-test and the
|
||
starter are separate repos: note them, don't edit them.
|
||
- **Done when:** dev and a production-like local run serve every page,
|
||
asset, upload and the admin panel through Caddy, response headers match
|
||
today's (compare `curl -I` on a few URLs before and after), and no nginx
|
||
config is left in this repo.
|
||
|
||
## Suggested order
|
||
|
||
1. A1 → A3 → A2 (small header/markup work, one commit each).
|
||
2. A6, A7, A8, A9 (small, independent; one commit each).
|
||
3. A4, then A5 (the test confirms A2–A4).
|
||
4. W1.
|
||
5. A0 only once core C0 is tagged.
|