Grilling
Frontend Composition Layer Brainstorm Brief
Frontend Composition Layer Brainstorm Brief
Context
- Source: user
/brainstormdirection, 2026-10-22, T3 thread onfrontend-domain-structure. - User direction, verbatim: "we have a soup of weird mixed modules etc... when instead we should bring a proper strucutre of frontend code that tighlty follows our /frontend-domain-structure" and "we need the same kind of convention in frontend domain structure skill to enable the highest abastraction module layer, where we combine modules and features for stuff like shells, provider. in general compositions that go into actual pages".
- System under change:
wearedevpunks/skillsskills/agnostic/frontend/frontend-domain-structure/(SKILL.md,references/structure.md,references/react/structure.md) at21a3cac, plus a new managed lint asset for the frontend Pack inapps/cli. - Evidence repositories, read at latest
main:pegasus@bf896c7,apito@3b59cee,emera@b1e86e1,assolombarda@0da85a7,ci-app@973e1843.
Problem
The current skill places shells, layouts and providers in framework
composition (app/), and forbids modules from importing features. A shell or
provider that combines features therefore has no legal owner. Agents place it
in features/, components/ or a catch-all modules/.
| Repository | Composition today | Observed damage |
|---|---|---|
| pegasus | root/ + templates/{layout,pages} above features/; order in ARCHITECTURE.md, enforced by apps/web/src/architecture.test.ts | modules/ catch-all (staff login workflow, filterCatalog policy, shell UI, worst-case dev dataset loaded by production modules); templates deep-import features; test misses relative imports |
| apito | features/area-riservata/shell, 4 page-frame.tsx, dashboard/registry.tsx, components/providers.tsx | features import shell 24×, shell imports chat/session; company↔dashboard and company↔profilo cycles; site-remake-prototype is the live site and a data source |
| emera | portal/{delta,forms,shell,screens}, portal-provider, features/search/use-corpus | 15-file cycle; 64 peer-feature imports; 27 upward feature→shell/screens imports |
| assolombarda | shell intranet/home-prototype; components/providers.tsx imports features; 11 identical layout.tsx | mock/ owns real state machines; *-prototype dirs are production UI; 17 peer prototype imports |
| ci-app | fe-studio runtime → builtins → contents/features → modules; dashboard routes → root/layouts/page-templates → features → entities | layer exists under different names per app; few reverse edges; no frontend lint enforcement |
ci-app backend declares ... → platform → features → app → composition
(apps/backend/AGENTS.md:9); its architecture lint plugin exists but is not
enabled. Its abstractions/ is a bottom contract layer; the user scoped that
meaning out of this topic.
Accepted Shape
- Layer order:
app → composition → features → modules → integrations. Each layer imports only lower layers. - Routes in
app/import onlycomposition/. composition/owns app-wide providers, surface shells, page templates, and cross-feature registries and aggregators.- A surface is a subfolder of
composition/only (composition/site/,composition/admin/). Features stay flat. - Features never import peer features. The nearest composition that holds both connects them through props, slots or callbacks.
- A shell splits: what features consume (navigation registry, header slot, toast or assistant channel) is a module; the shell assembly is composition.
- Mock data, demo data and fake runtimes are integrations. Only composition or tests select them. No production UI lives in a folder named "prototype".
- Layer folder names are fixed; the skill drops "These labels may differ between projects".
- A custom lint rule enforcing the structure is mandatory and ships as a lint asset of the frontend Pack.
- Only the skill changes. Each repository migrates later by running the skill.
Rejected Shapes
- Top layer named
abstractions/orroot/+templates/: user chosecomposition/. - Features nested by surface (
features/<surface>/<feature>) and surface mini-apps: user chose surface folders insidecomposition/only. - Modules as the deepest layer without
integrations/: user reversed to keepintegrations/. - Routes importing module readers directly: user chose composition only.
- Recommended (not mandatory) enforcement; skill-shipped lint script.
Open Forks
- What the lint rule checks: layer order, peer-feature ban, public entrypoints only, relative imports, "prototype" folder names. Proposed default: all five.
- Where app-local shared presentation goes (pegasus
ui/) and at what level. Proposed default: no app-localui/; reusable primitives live in the shared UI package, app-specific presentation lives with its owner. - Where server code inside a Next app goes (pegasus
server/api,app/apihandlers). Proposed default: outside this layer model, governed byeffect-backend-structure;app/apihandlers import onlyserver/. - Route data under accepted shape 2:
notFound,generateMetadataand data readers come through composition entrypoints. Proposed default: accept. - Canonical glossary for Surface, Composition and the four layer names.
- Cross-skill ripple: contract test,
create-planarchitecture convergence,implement-specarchitecture conformance,ask-hireferences move with the skill.