How persianlabs/ui works
Purpose and topology
PersianLabs/ui is an RTL-first, copy-paste React/Tailwind component system for Persian interfaces, with LTR support. It is a Bun/Turborepo monorepo containing the source library, a Next.js documentation/registry site, and shared lint/TypeScript presets. Primary public surfaces are the docs site and shadcn-compatible registry JSON.
• packages/ui/src/components
• apps/web/app/page.tsx
• apps/web/registry.json
Runtime entry points
The Next.js App Router application is the deployable runtime. Its root layout and landing page frame the site; /docs provides documentation, while metadata/discovery endpoints support crawlers and AI clients.
• apps/web/app/layout.tsx
• apps/web/app/docs/layout.tsx
• apps/web/app/llms.txt/route.ts
• apps/web/app/robots.ts
Component source boundary
packages/ui is the canonical reusable implementation layer: React TSX components, hooks, Persian-domain utilities, global styles, and types. It owns RTL-aware primitives and domain features such as Jalali dates, Iranian banks/provinces, holidays, digit normalization, and Toman display. Consumers are intended to receive source rather than install a versioned runtime package.
• packages/ui/src/components/date-picker.tsx
• packages/ui/src/lib/persian-date.ts
• packages/ui/src/styles/globals.css
Registry distribution layer
The site publishes shadcn registry definitions. apps/web/registry.json defines registry content, registry/base contains distributable source organized by UI/hooks/lib, and public/r/*.json are static install manifests addressed by component name. This is a deliberate distribution boundary separate from the package source.
• apps/web/registry.json
• apps/web/registry/base/ui/city-selector.tsx
• apps/web/public/r/city-selector.json
Documentation and example pipeline
Documentation is route-per-component/utility. Each page combines API metadata, rendered examples, source/installation affordances, and an Open Graph image. Shared documentation machinery resolves navigation, source, previews, syntax highlighting, and markdown; preview routes render individual examples in isolation.
• apps/web/app/docs/components/[slug]/page.tsx
• apps/web/components/examples/date-picker-demo.tsx
• apps/web/lib/component-source.ts
• apps/web/app/preview/c/[component]/[example]/page.tsx
Content APIs and machine-readable output
Route handlers expose markdown versions of broad docs and selected component/utility pages, complementing the root llms.txt endpoint. These are server-facing content boundaries rather than application business APIs.
• apps/web/app/docs/markdown/route.ts
• apps/web/app/docs/components/[slug]/markdown/route.ts
• apps/web/app/docs/utilities/persian-date/markdown/route.ts
Infrastructure and external integrations
Development/build orchestration uses Bun and Turborepo, with shared ESLint and TypeScript configuration packages. The web runtime is Next.js; Tailwind/PostCSS configuration is app/package scoped. External integration is primarily the shadcn registry protocol; the docs also include GitHub-oriented UI/data support.
• package.json
• turbo.json
• apps/web/package.json
• apps/web/lib/github.ts
Main entry points: components RTL component source · layout.tsx App shell · turbo.json Turborepo pipeline · registry.json Registry definitions
Components 21
Monorepo Tooling
- Bun workspace · Coordinates monorepo scripts and dependencies.
package.json - Turborepo pipeline
turbo.json - Shared lint and TS presets
UI Source Library
- RTL component source · Canonical copy-paste component implementations.
packages/ui/src/components - Date picker
packages/ui/src/components/date-picker.tsx - Persian date utilities · Provides Jalali date behavior.
packages/ui/src/lib/persian-date.ts - Global UI styles
packages/ui/src/styles/globals.css
Next.js Docs Site
- Web application manifest
apps/web/package.json - App shell
apps/web/app/layout.tsx - Landing page
apps/web/app/page.tsx - Docs shell
apps/web/app/docs/layout.tsx - Component docs pages · Combines API metadata, examples, source, and installation guidance.
- Rendered examples
apps/web/components/examples/date-picker-demo.tsx - Documentation source resolver · Resolves source, previews, highlighting, and markdown support.
apps/web/lib/component-source.ts - Isolated preview route
apps/web/app/preview/c/[component]/[example]/page.tsx - Markdown documentation APIs · Serves machine-readable docs and selected component or utility pages.
apps/web/app/docs/markdown/route.ts - LLMs and crawler endpoints
apps/web/app/llms.txt/route.ts - GitHub support
apps/web/lib/github.ts
Registry Distribution
- Registry definitions
apps/web/registry.json - Registry source · Separate copy-paste source organized by UI, hooks, and utilities.
apps/web/registry/base/ui/city-selector.tsx - Install manifests · Addressed by component name through the shadcn registry protocol.
apps/web/public/r/city-selector.json
Connections 22
- Bun workspace → Turborepo pipeline: runs
- Turborepo pipeline → RTL component source: builds
- Turborepo pipeline → Web application manifest: builds
- Shared lint and TS presets → RTL component source: governs
- Shared lint and TS presets → Web application manifest: governs
- Date picker → Persian date utilities: uses
- RTL component source → Date picker: contains
- RTL component source → Global UI styles: uses
- Web application manifest → App shell: runs
- App shell → Landing page: frames
- App shell → Docs shell: frames
- Docs shell → Component docs pages: hosts
- Component docs pages → Rendered examples: renders
- Component docs pages → Documentation source resolver: reads source through
- Isolated preview route → Rendered examples: renders in isolation
- Markdown documentation APIs → Documentation source resolver: uses
- App shell → LLMs and crawler endpoints: publishes discovery
- Component docs pages → GitHub support: uses
- Registry definitions → Registry source: defines entries for
- Registry definitions → Install manifests: publishes
- Component docs pages → Registry definitions: presents installation from
- Registry source → RTL component source: mirrors distribution boundary