docyrus-app-dev-react
Docyrus App Dev React
Build Docyrus React TypeScript applications end-to-end. This skill combines app architecture, authentication, data access, query patterns, and production-grade UI guidance in one place.
Tech Stack
- React 19 + TypeScript + Vite
- TanStack Router (code-based), TanStack Query (server state), TanStack Form
- Tailwind CSS v4, shadcn/ui components
@docyrus/api-client+@docyrus/signin+@docyrus/app-utils- Auto-generated collections from OpenAPI spec
- Preferred UI libraries: shadcn, diceui, animate-ui, docyrus-ui, reui
When to Use This Skill
Use this skill when you are:
- Building or modifying a Docyrus-backed React app
- Setting up authentication with
@docyrus/signin - Bootstrapping tenant-aware runtime utilities with
@docyrus/app-utils - Fetching or mutating data with generated collections or
@docyrus/api-client - Persisting app-level config or user-level config or saved grid views with
AppConfig,UserAppConfig, andDataViews - Building record sharing, role management, or ACL-driven UI flows
- Designing feature UIs such as dashboards, forms, tables, layouts, dialogs, analytics, or detail pages
- Selecting between shadcn, diceui, animate-ui, docyrus-ui, and reui components
- Implementing complete feature flows that combine data access and polished UI
End-to-End Feature Workflow
- Set up app auth, routing, and query providers.
- Bootstrap
TenantPreferences, date/number utilities, and shared app runtime helpers from@docyrus/app-utils. - Use generated Docyrus collection hooks or the REST client for data access.
- Define
columns, filters, formulas, child queries, and mutations correctly. - Use
AppConfigfor per-app persisted settings,UserAppConfigfor per-user per-app settings, andDataViewsfor saved grid views. - Check preferred UI components before building anything custom.
- Use Docyrus form and detail patterns for create, edit, item detail, and editable grid flows.
- Connect UI actions to TanStack Query mutations and invalidate relevant queries.
Quick Start: App Bootstrap
Root provider setup
import { DocyrusAuthProvider } from '@docyrus/signin'
<DocyrusAuthProvider
apiUrl={import.meta.env.VITE_API_BASE_URL}
clientId={import.meta.env.VITE_OAUTH2_CLIENT_ID}
redirectUri={import.meta.env.VITE_OAUTH2_REDIRECT_URI}
scopes={['offline_access', 'Read.All', 'DS.ReadWrite.All', 'Users.Read']}
callbackPath="/auth/callback"
>
<QueryClientProvider client={queryClient}>
<RouterProvider router={router} />
</QueryClientProvider>
</DocyrusAuthProvider>
Auth gate and current-user access
const { status, user, hasRole, hasPermission } = useDocyrusAuth()
if (status === 'loading') return <Spinner />
if (status === 'unauthenticated') return <SignInButton />
// user is auto-fetched from /v1/users/me after authentication
// hasRole('super_admin') — check role by slug or uid
// hasPermission('edit', dataSourceId) — check ACL permission on a data source
Tenant-aware app utilities
Use @docyrus/app-utils as the default runtime layer for tenant-level formatting and persisted app/grid preferences.
import {
createAppConfigClient,
createUserAppConfigClient,
createDataViewClient,
createDateUtils,
createNumberUtils,
getTenantPreferences,
} from '@docyrus/app-utils'
function useAppRuntime(appId: string) {
const client = useDocyrusClient()
const { getMyInfo } = useUsersCollection()
return useQuery({
queryKey: ['app-runtime', appId],
enabled: !!client && !!appId,
queryFn: async () => {
const [preferences, me] = await Promise.all([
getTenantPreferences(client!),
getMyInfo(),
])
return {
preferences,
me,
dateUtils: createDateUtils({
preferences,
userTimezone: me.timeZone?.id,
}),
numberUtils: createNumberUtils({ preferences }),
appConfig: createAppConfigClient(client!, appId),
userConfig: createUserAppConfigClient(client!, appId),
dataViews: createDataViewClient(client!, appId),
}
},
})
}
Use this runtime to:
- Format dates and datetimes with tenant format strings and the user's timezone.
- Format numbers, currency-like values, and decimals using tenant separators and precision.
- Read and upsert the app's single persisted
AppConfigdocument. - Read and upsert the current user's
UserAppConfigdocument (per-user per-app settings). - Read and persist saved grid views through
DataViews.
Data fetching with generated collections
const { list } = useBaseProjectCollection()
const { data: projects } = useQuery({
queryKey: ['projects'],
queryFn: () =>
list({
columns: ['name', 'status', 'record_owner(firstname,lastname)'],
filters: { rules: [{ field: 'status', operator: '!=', value: 'archived' }] },
orderBy: 'created_on DESC',
limit: 50,
}),
})
ACL, roles, and record sharing
Use direct useDocyrusClient() calls for ACL features. These routes may be hidden from generated OpenAPI output, so they are typically not available through generated collection hooks.
const client = useDocyrusClient()
const { data: roles } = useQuery({
queryKey: ['acl', 'roles'],
queryFn: () => client!.get('/v1/users/acl/roles'),
})
const replaceUserRoles = useMutation({
mutationFn: ({ userId, roleIds }: { userId: string; roleIds: string[] }) =>
client!.put(`/v1/users/acl/users/${userId}/roles`, { roleIds }),
})
const createRoleQuery = useMutation({
mutationFn: (payload: Record<string, unknown>) =>
client!.post('/v1/users/acl/role-queries', payload),
})
Prefer role uid values returned by the API when sending roleIds for user-role updates or role-query payloads.
Saved data grid views
Use DataGridViewSelect as the default saved-view UI for Docyrus grids, and persist those views with createDataViewClient(client, appId).
DataGridViewSelectis the default component for showing and editing saved grid views.- Pass the TanStack table instance via
tableso the selector/editor can read column definitions. - Pass
fieldswhen you want the built-in filter builder enabled in the editor. - Back
views,onViewCreate,onViewSave,onViewDelete,onViewHide, andonViewUnhidewithDataViewsCRUD. - Use
DataGridViewEditorseparately only when you need a standalone editor outside the selector.
Critical App/Data Rules
- Always send
columnsin.list()and.get()calls. Without it, onlyidis returned. - Collections are React hooks — call
useBaseProjectCollection(),useUsersCollection(), and similar hooks inside React components. - Data source endpoints are dynamic — they only exist if the data source is defined in the tenant OpenAPI spec.
- Use
idforcountcalculations. Use actual field slugs forsum,avg,min, andmax. - Child query keys must appear in
columns. - Formula keys must appear in
columns. - Use
useUsersCollection().getMyInfo()for current user profile instead of making a direct profile call. - Initialize
TenantPreferencesonce per app runtime and create shareddateUtils/numberUtilsinstances from@docyrus/app-utils. - Formatting functions from
@docyrus/app-utilsare regionalized — do not hardcode locale, date format, decimal separator, thousand separator, or decimal precision when tenant preferences should drive them. - Use
createAppConfigClient(client, appId)for the app's single persisted config document;upsertis the default write path. - Use
createUserAppConfigClient(client, appId)for the current user's persisted config document scoped to an app (e.g. theme, layout preferences, sidebar state);upsertis the default write path. - Use
createDataViewClient(client, appId)for saved grid-view CRUD. - Use
DataViewswithDataGridViewSelectto show, create, edit, reorder, hide, unhide, soft-delete, and hard-delete saved data grid views. DataGridViewSelectneeds a TanStack table instance and should receivefieldswhen you want the built-in filter builder/editor experience.- Data view creation requires
nameandtenant_data_source_id. - Use
dataViews.update(viewId, { archived: true })for soft-delete anddataViews.remove(viewId)only for irreversible hard-delete. - Regenerate collections after schema changes by rebuilding the tenant OpenAPI spec, downloading the latest
openapi.json, and re-running the collection generator. - ACL endpoints are usually raw-client integrations — use
useDocyrusClient()orRestApiClientfor roles, user-role assignments, role queries, record sharing, and ownership transfer. - Prefer role
uidvalues for ACL role writes, user-roleroleIds, and role-queryroleIds. - Treat
PUT /v1/users/acl/users/:userId/rolesas full replacement andPOST /v1/users/acl/users/:userId/rolesas additive. - Send role-query
queryas raw JSON and omittenantAppIdwhendataSourceIdis present; backend derives it. - After deleting a role, invalidate dependent app queries for role lists, user-role lists, role-query lists, and any UI that renders primary-role labels.
Critical UI/UX Rules
- Always check preferred components first before creating anything custom.
- Use
AwesomeCardfor dashboards unless the user explicitly wants a different card style. - Use animate-ui
Sidebarfor app layouts unless another layout is requested. - Prefer Recharts for charts. shadcn chart primitives are the default wrapper.
- Use icons in this order: hugeicons, then fontawesome light, then lucide.
- Use
AwesomeDialogfor item create forms.- Small/simple forms:
container="sheet"withside="right" - Long/complex forms:
container="modal"orcontainer="drawer"
- Small/simple forms:
- Choose detail containers based on item complexity.
- Large items: dedicated page
- Small items:
AwesomeDialogright sheet
- All forms must use TanStack Form + the Docyrus form system. Do not build feature forms with plain HTML forms or React Hook Form directly.
- Use
EditableRecordDetailfor inline editing in item detail views. - Always enable
trackChangesfor editable detail and grid experiences. - Use
DataGridViewSelectfor saved grid views and back it withDataViewsfrom@docyrus/app-utils. - Prefer
DataGridViewEditoronly when you need a standalone grid-view editor outside the selector component.
Default UI Choices
| Use Case | Default Component | Library |
|---|---|---|
| Item create form | AwesomeDialog |
docyrus |
| Quick record create | CreateRecordDialog |
docyrus |
| Item detail (small) | AwesomeDialog sheet right |
docyrus |
| Item detail (large) | Dedicated page | — |
| Inline editing | EditableRecordDetail |
docyrus |
| Dashboard card | AwesomeCard |
docyrus |
| Stat dashboards | AwesomeStats |
docyrus |
| App navigation | Sidebar |
animate-ui |
| Data table | DataTable |
diceui |
| Editable grid | Data Grid |
docyrus |
| Grid saved views | DataGridViewSelect + DataViews |
docyrus + @docyrus/app-utils |
| Forms | Docyrus form fields + TanStack Form | docyrus |
| Charts | shadcn chart + Recharts | shadcn |
| File upload | File Upload | diceui |
| Gantt/project scheduling | Gantt |
docyrus |
| Resource scheduling | ResourceSchedulerPanel |
docyrus |
| Team chat | TeamChatChannel |
docyrus |
| AI interface | DocyrusAgent |
docyrus |
| Pricing / quoting | PricingEnginePanel |
docyrus |
| Analytics / pivot | PivotGrid |
docyrus |
Quick UI Patterns
Item create form
<AwesomeDialog open={open} onOpenChange={setOpen} container="sheet" side="right" size="default">
<AwesomeDialogHeader title="Create Task" icon="far-plus" />
<AwesomeDialogBody>
<form.Field name="title">{(field) => <TextFormField field={field} label="Title" />}</form.Field>
<form.Field name="status">{(field) => <SelectFormField field={field} label="Status" />}</form.Field>
</AwesomeDialogBody>
<AwesomeDialogFooter>
<Button variant="outline" onClick={() => setOpen(false)}>Cancel</Button>
<Button onClick={handleSubmit}>Create</Button>
</AwesomeDialogFooter>
</AwesomeDialog>
Item detail with inline editing
<AwesomeDialog open={open} onOpenChange={setOpen} container="sheet" side="right" size="lg" fullscreenable>
<AwesomeDialogHeader
title="Task Detail"
description="Review and edit task fields inline"
headerButtons={<Button variant="outline" size="sm" onClick={switchToFullForm}>Edit All</Button>}
/>
<AwesomeDialogBody>
<EditableRecordDetail fields={fields} record={record} onSave={handleSave} trackChanges>
<EditableRecordDetailField slug="title" />
<EditableRecordDetailField slug="status" />
<EditableRecordDetailField slug="assignee" />
<EditableRecordDetailField slug="due_date" />
</EditableRecordDetail>
</AwesomeDialogBody>
</AwesomeDialog>
TanStack Query Pattern
function useProjects(params?: ICollectionListParams) {
const { list } = useBaseProjectCollection()
return useQuery({
queryKey: ['projects', 'list', params],
queryFn: () => list({ columns: PROJECT_COLUMNS, ...params }),
})
}
function useCreateProject() {
const { create } = useBaseProjectCollection()
const qc = useQueryClient()
return useMutation({
mutationFn: (data: Record<string, unknown>) => create(data),
onSuccess: () => {
void qc.invalidateQueries({ queryKey: ['projects'] })
},
})
}
Collection CRUD Methods
const { list, get, create, update, delete: deleteOne, deleteMany } = useBaseProjectCollection()
list(params?: ICollectionListParams)
get(id, { columns })
create(data)
update(id, data)
deleteOne(id)
deleteMany({ recordIds })
API endpoint pattern: /v1/apps/{appSlug}/data-sources/{slug}/items
Query Capabilities Summary
The .list() method supports:
columnsfiltersfilterKeywordorderBylimitandoffsetfullCountcalculationsformulaschildQueriespivotexpand
Component Installation Pattern
pnpm dlx shadcn@latest add button
pnpm dlx shadcn@latest add @diceui/data-table
pnpm dlx shadcn@latest add @animate-ui/sidebar
pnpm dlx @docyrus/cli add @docyrus/ui-awesome-card
pnpm dlx shadcn@latest add @reui/file-upload-default
References
For deep dives, read:
references/README.md— merged reference map for app development and UI designreferences/api-client-and-auth.mdreferences/collections-and-patterns.md../docyrus-api-dev/references/acl-endpoints-frontend.md../docyrus-api-dev/references/data-source-query-guide.md../docyrus-api-dev/references/formula-design-guide-llm.md../docyrus-api-dev/references/query-guide.mdreferences/preferred-components-catalog.mdreferences/component-selection-guide.mdreferences/icon-usage-guide.md