For a 40-engineer web admin console, how would you layer components from design-system primitives to pages, and where does the design system's edge sit?
answer
- primitives, composites, features, pages
- what each layer may know
- imports point downward only
- pages own the address
- wrap for defaults, never restyle internals
basics
~20 sFour layers, imports pointing down: design-system primitives know no domain, app-shared composites know app conventions, feature components know their domain and data, pages own routes and the URL. Wrap the system for real defaults; never restyle its internals.
solid answer
~50 sI'd name four layers and what each may know. Design-system primitives know the visual language and accessibility behaviour, nothing about orders or routes. App-shared composites such as the page header or a money cell know the app's conventions but no feature's data. Feature components such as the orders grid know their domain and data but not the address. Pages read routes and the URL and compose features. Imports only point downward, so a domain-aware visual like an order status badge lives in the orders feature, composing the system's badge. The system's edge is its public surface: the app wraps it only where it has a real default to set, such as a confirm dialog, and never targets its internal class names or forks it. If the console builds on a headless grid behaviour, it keeps the obligations: one tab stop, arrow-key navigation, `aria-sort` and `aria-selected`.
go deeper
Recall the four layers in order, from design-system primitives through app-shared composites and feature components to pages, and that imports only point downward.
Explain what each layer may and may not know, which layer reads the address, and where a domain-aware visual such as a status badge belongs.
Defend where the design system's edge sits: when a local wrapper is earned, why restyling internals breaks on upgrade, and what the app owns if it styles a headless grid.
Weigh the cost of layering against team size: indirection and some duplication versus a codebase where anything imports anything, and how many layers a smaller team actually needs.
## Four layers and what each may know In a web admin console built by around forty engineers, the components fall naturally into four layers. The point of naming them is to state **what each layer is allowed to know**, because that is what keeps reuse possible as features pile up. | Layer | Examples | May know | Must not know | |---|---|---|---| | **Design-system primitives** | button, dialog, badge, data-grid behaviour | visual language, accessibility behaviour | the app, its data, routes, domain | | **App-shared composites** | page header, empty state, money cell, confirm dialog with the app's copy | the app's conventions and formatting | any one feature's domain or data | | **Feature components** | orders grid, order side panel, order status badge | their feature's domain and data | routes and the address, other features' internals | | **Pages** | the orders page, the order detail page | routes, the URL, which features compose the screen | rendering details of primitives | ## The import rule: downward only - A layer may import from layers **below** it, never above. A primitive that imports an order type, or a composite that imports from the orders feature, has leaked the domain downward. - **Pages read the address and pass values down.** Feature components receive values and report changes, so they can appear on several pages or in a dialog without knowing which route they are on. - **Domain-aware visuals sit in the feature.** An order status badge maps order statuses to tones; it composes the system's badge primitive but lives with the orders feature, because the system must stay domain-free. ## Headless behaviour and styled layers in the app A data grid has two halves: **behaviour** (keyboard navigation, focus, sort and selection semantics) and **appearance**. If the console uses the design system's styled grid, both halves come together. If the console needs a look the styled grid cannot produce and builds on a headless behaviour layer instead, the app takes on the obligations the behaviour layer exists to carry. The WAI-ARIA grid pattern is a useful checklist: 1. Only **one** element of the grid is in the page's tab sequence; Tab enters the grid once. 2. **Arrow keys** move focus between cells. 3. A sortable column's header carries **`aria-sort`**. 4. A selected row carries **`aria-selected="true"`**. Restyling must keep these; a visually polished grid that drops arrow-key navigation is a regression, not a skin. ## Where the design system's edge sits The edge is the system's **public surface**: its components, their documented options and its tokens. On the app side of that edge: - **Wrap where the app has a real default to impose** — a confirm dialog with the app's standard labels and a telemetry event, a page header with breadcrumbs. One wrapper is one place to change when the system upgrades. - **Do not wrap everything.** A local copy of every primitive is a maintenance tax that drifts from the system and hides its upgrades. - **Never restyle the system's internals** — no descendant selectors aimed at its internal class names, no overriding its inner elements, no forked copy. Those break silently on the system's next release. - **When the system lacks something,** build a local composite from its primitives in the app-shared or feature layer. How such a composite is proposed back to the system is the system's governance process, not this design. ## What layering costs - Indirection: a new engineer must learn which layer a component belongs in. - Some duplication: two features may each build a similar composite before one is promoted. - Friction when the system moves slowly: a team waiting for an option is tempted to override internals. These costs are worth paying at forty engineers because the alternative — any component importing anything — makes every change a search through the whole codebase. On a three-person prototype, two layers (the system and the app) may be plenty. ## What to say in the round Name the four layers, the one-way import rule, which layer reads the URL, where a domain-aware visual goes, and the line the app never crosses into the system. Mention the headless option only with its obligations attached.
- Should the app wrap every design-system primitive in a local component?No. A wrapper per primitive is a maintenance tax that drifts from the system and hides its upgrades. Wrap where the app has a real default or seam to own, such as a confirm dialog with standard labels or a configured data grid, and import the rest directly.
- Where does an order status badge that maps statuses to tones belong?In the orders feature. It knows the domain, so it cannot go into the design system, which must stay domain-free, nor into app-shared composites, which know no feature's data. It composes the system's badge primitive. If billing needs it too, the orders feature exposes it on its public surface.
- The console builds its grid on a headless behaviour layer. What does the app now own?Everything the styled grid used to carry visually, without breaking the behaviour: one tab stop for the grid, arrow keys moving between cells, `aria-sort` on the sorted header and `aria-selected` on selected rows, plus visible focus. A restyle that loses any of these is an accessibility regression.
- Design-system primitives should accept order objects to save the app mapping code.
- Overriding the system's internal class names is fine if the mockup demands it.
- Wrap every primitive locally in case the design system changes.
- A domain-aware visual such as an order status badge belongs in the design system.
- A styled headless grid can drop arrow-key navigation if focus is visible.
- A lower layer may import a feature component when it saves duplication.