Components Architecture
All UI components belong in TurboUI as pure components. The app bridges the
backend and TurboUI: it loads data, calls APIs, reads app contexts, and passes
data and callbacks as props.
TurboUI was introduced after much of the app UI was built. app/assets/js/components/
and UI components under app/assets/js/features/ are deprecated for new UI.
Non-UI code in app/assets/js/features/ (activity registration, API hooks,
loaders, model hooks) still belongs in the app.
For detailed examples and the canonical component selection map, see reference.md.
Architecture
Data flows down as props; user actions flow up as callbacks. The app
sits in the middle and talks to both sides.
| Layer | Location | Responsibility |
| ----- | -------- | -------------- |
| UI | turboui/src/ | Render UI; no API, routing, or app contexts |
| Bridge | app/assets/js/pages/ | Load data, call APIs, read contexts, build props, handle callbacks |
| Backend | Elixir/GraphQL | Persist and serve data |
Pure Components
TurboUI components must not:
- Import from
@/…app paths - Call
Api.*, use React Router hooks, or read app contexts (TimezoneContext,useMe, etc.) - Fetch data or perform server-side side effects
TurboUI components should:
- Accept display data and user preferences via props
- Use callbacks for actions (
onSave,onDelete,onTaskUpdate) - Keep local UI state only (open/closed, draft input) and notify the parent via callbacks
- Export from
turboui/src/index.tsx - Include Storybook stories
- Type props with
turboui/src/ApiTypes(same shapes asapp/assets/js/api/index.tsx) or a
component-specific type when the UI needs a different shape
Translated copy
Use the internationalization skill for copy changes and new-language registration.
Hardcoded system-authored, user-visible text is forbidden, including accessible labels, tooltips, empty states, and errors. Follow the internationalization guide and its language glossaries. Use useTranslation, the relative i18n plural helper, and the shared Translate adapter; keep user content literal and escaped. Every copy change must include translations for all supported languages and regenerated catalogs/resources in the same PR. Never edit generated JSON manually or introduce independent locale detection.
Data types
turboui/src/ApiTypes/index.ts mirrors the types in app/assets/js/api/index.tsx.
TurboUI components should expect those API shapes — the app fetches via TanStack
Query and passes data through with minimal mapping.
- Default: props use
ApiTypesdirectly (e.g.Project,Person,Task) - Custom prop type: when the UI needs a view-specific shape, define it in
the component's types.ts — re-export from ApiTypes where possible (see
turboui/src/ResourceHub/types.ts)
- Transform in TurboUI: when display logic applies to API data, do it inside
the TurboUI component rather than in the app bridge
Do not add new parse*ForTurboUi or prepare* helpers in the app for new
work. Legacy parsers still exist in older pages but are not the target pattern.
Component design
- Self-contained: manage UI state locally; notify parents via callbacks
- Generic callbacks: prefer
onTaskUpdate(id, updates)over many specific handlers (onAssigneeChange,onDueDateChange, …) - Callback shape:
(id: string, updates: Partial<Type>) => voidfor entity updates - No mock data in components: mock data belongs in Storybook stories only
- Reuse TurboUI primitives:
PrimaryButton, design-system colors (content-subtle,content-error), Tabler icons — checkturboui/src/Colors/Colors.stories.tsxandturboui/src/icons/index.tsxbefore adding new ones
Component reuse gate
Complete this before writing JSX for new or changed UI:
- List every required control and interaction pattern: forms, fields, buttons, links, selectors, modals, empty states, validation, and loading feedback.
- Search
turboui/src/index.tsx, relevant component directories, and existing usages for matching components. - Compose the UI from those components. Use raw interactive elements only when implementing a TurboUI primitive or when the inventory confirms that no suitable primitive exists.
- If a raw
<input>,<button>,<select>,<textarea>, dialog, link-like action, or validation message remains, document the reason in the implementation summary.
Use Forms.Form, Forms.FieldGroup, Forms.TextInput, and Forms.Submit as the default stack for new conventional forms. Use TextField for inline editing or existing surfaces already composed around it. Treat FormElements/Textfield as legacy and do not select it for new UI.
During code review, classify hand-rolled interactive UI that duplicates an existing TurboUI component as a P2 architecture issue.
File organization
turboui/src/ComponentName/
├── index.tsx # Main component (+ exported Props type)
├── index.stories.tsx # Storybook stories
├── mockData.ts # Mock data for stories (optional)
└── types.ts # Component-specific types (optional)
Storybook workflow
- Develop and test components in Storybook (
make turboui.storybook) - Create stories for empty, loading, error, and interactive states
- Before committing:
make turboui.build && make turboui.test
App Bridge
App pages own all backend interaction. Typical page layout:
app/assets/js/pages/SomePage/
├── index.tsx # Page module (loader + Page export)
├── loader.tsx # Data fetching
├── navigation.tsx # Breadcrumbs / nav props (optional)
└── page.tsx # Build props, render TurboUI component
Loaders and mutations use TanStack Query. Follow