Skip to documentation

Design system / Sources & standards

Current repository source

ADR-0031-frontend-component-taxonomy-and-product-instances.md

docs/decisions/ADR-0031-frontend-component-taxonomy-and-product-instances.md

This view contains the escaped source read during the deployment build. Code and policy text are unchanged. Markdown is shown as source, not rendered as a document. A new deployment refreshes the content.

# ADR-0031: Frontend component taxonomy and product instances

## Status

accepted

## Date

2026-07-14

## Context

CreativeXHub uses a tokenized Tailwind and shadcn/ui foundation, but it needs a durable way to decide where new UI belongs as the product grows. In particular, design primitives, shadcn-derived controls, product-specific compositions, templates, and route boundaries must not be conflated.

The codebase also needs a precise definition of a product "instance": a configured application surface built from an abstract component. Without that definition, visual structure, route behavior, and API transport tend to accumulate in the same component.

## Options considered

1. **Three practical component layers**
   - Use foundation, shared, and feature folders only.
   - Pros: few categories.
   - Cons: loses the composition vocabulary the team uses and provides weak placement guidance.

2. **Classic atomic design with feature ownership as an orthogonal concern (chosen)**
   - Use design foundations, atoms, molecules, organisms, templates, and pages/routes.
   - Treat feature ownership as a location and dependency concern, not an additional visual layer.
   - Pros: maps to the team mental model while retaining a clear boundary for feature code.
   - Cons: classification requires deliberate review.

3. **Classic atomic design without ownership rules**
   - Use visual layers only.
   - Pros: familiar terminology.
   - Cons: does not resolve where product-specific components and instances live.

## Decision

### Component taxonomy

- **Design foundations** are non-component inputs to visual language: tokens, typography, icon sources, motion, and layout rules. They are not UI atoms. `src/theming/` remains their home under ADR-0030.
- **Atoms** are indivisible, product-neutral controls or display elements with a focused API, such as `Button`, `Input`, `Badge`, and `Label`.
- **Molecules** combine atoms to complete one focused interaction or presentation concern, such as a labeled form field or search input.
- **Organisms** are reusable, bounded interface sections that coordinate multiple atoms and molecules, such as navigation, uploaders, and tables.
- **Templates** define page-level layout and slots without business data or product policy, such as `AppShell`.
- **Pages/routes** remain server and authorization boundaries. They fetch or receive authorized initial data, define rendering intent, and compose templates, instances, and feature UI.

Feature ownership is orthogonal to the taxonomy. A feature may contain its own atoms, molecules, organisms, hooks, and adapters under a feature-oriented directory. A component becomes shared only when it has a stable cross-feature contract.

### Foundation UI policy

`src/components/ui/` is the shadcn-derived foundation layer. It may contain either shadcn components or a custom component only when it is generic and product-neutral:

- It exposes no domain vocabulary, API paths, tenant assumptions, or business rules.
- Its API could plausibly be offered by shadcn.
- It follows shadcn conventions for accessibility, controlled state, variants, `cn()`, and semantic tokens.

Components that fail any of those tests belong with navigation or their feature, not in `components/ui`.

### Product instances

An instance is a named, application-specific adapter around an abstract atom, molecule, organism, or template. It may bind product copy, navigation, Context, domain-to-view adapters, and product-specific behavior hooks. It must not duplicate the abstract component's structural markup or visual styling, perform route authorization, or encode API transport directly.

Store a stable named instance beside its abstraction in an `instances/` directory when it represents a durable application surface or is shared by two or more routes. Keep route-specific assembly in the owning route or feature. Routes provide authorized initial data and callbacks/contracts; instances pass behavior through hooks rather than calling transport directly.

## Rationale

This separates the visual system from product behavior while preserving the team's atomic-design vocabulary. A change to the abstract component's structure or appearance reaches every instance, while an instance remains the explicit place to bind a named product surface to its contextual behavior.

## Consequences

- New and materially modified frontend work must declare its taxonomy and ownership during implementation or review.
- `components/ui` stays close to shadcn instead of becoming a general dumping ground.
- Existing components are migrated incrementally when they are touched or chosen as a targeted example; this ADR does not require a churn-only repository reorganization.
- Product instances may be stateful through hooks and Context consumption, but API transport and authorization remain outside them.

## References

- ADR-0010 - shadcn and Tailwind baseline policy
- ADR-0030 - Design token architecture for cxhub base theme
- `src/components/navigation/instances/`
All sources and standards
Current components and theme tokens. Fictional example data. Source views refresh on deployment; authors maintain contract notes.