# persianlabs/ui architecture

> Architecture diagram of the GitHub repository persianlabs/ui, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/persianlabs/ui
- Repository: https://github.com/persianlabs/ui

## Overview

#### 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: [`packages/ui/src/components`](https://github.com/persianlabs/ui/tree/main/packages/ui/src/components) (RTL component source), [`apps/web/app/layout.tsx`](https://github.com/persianlabs/ui/blob/main/apps/web/app/layout.tsx) (App shell), [`turbo.json`](https://github.com/persianlabs/ui/blob/main/turbo.json) (Turborepo pipeline), [`apps/web/registry.json`](https://github.com/persianlabs/ui/blob/main/apps/web/registry.json) (Registry definitions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Monorepo Tooling"]
  node_root["Bun workspace<br/>workspace manifest<br/>[package.json]"]
  node_turbo{{"Turborepo pipeline<br/>build orchestration<br/>[turbo.json]"}}
  node_shared_presets["Shared lint and TS presets<br/>configuration packages"]
end

subgraph group_ui["UI Source Library"]
  node_ui_components["RTL component source<br/>React TSX components"]
  node_date_picker["Date picker<br/>domain component<br/>[date-picker.tsx]"]
  node_persian_date["Persian date utilities<br/>domain utility<br/>[persian-date.ts]"]
  node_ui_styles["Global UI styles<br/>CSS styles<br/>[globals.css]"]
end

subgraph group_web["Next.js Docs Site"]
  node_web_package["Web application manifest<br/>Next.js package<br/>[package.json]"]
  node_app_shell["App shell<br/>App Router layout<br/>[layout.tsx]"]
  node_landing["Landing page<br/>App Router page<br/>[page.tsx]"]
  node_docs_shell["Docs shell<br/>documentation layout<br/>[layout.tsx]"]
  node_component_docs["Component docs pages<br/>dynamic documentation route"]
  node_examples["Rendered examples<br/>documentation demos"]
  node_doc_source["Documentation source resolver<br/>content service"]
  node_preview["Isolated preview route<br/>dynamic preview page<br/>[page.tsx]"]
  node_machine_docs["Markdown documentation APIs<br/>route handlers<br/>[route.ts]"]
  node_llms["LLMs and crawler endpoints<br/>discovery routes<br/>[route.ts]"]
  node_github["GitHub support<br/>external data integration<br/>[github.ts]"]
end

subgraph group_registry["Registry Distribution"]
  node_registry_index["Registry definitions<br/>shadcn registry index<br/>[registry.json]"]
  node_registry_source["Registry source<br/>distributable TSX source<br/>[city-selector.tsx]"]
  node_install_manifests["Install manifests<br/>static registry JSON<br/>[city-selector.json]"]
end

node_root -->|"runs"| node_turbo
node_turbo -->|"builds"| node_ui_components
node_turbo -->|"builds"| node_web_package
node_shared_presets -.->|"governs"| node_ui_components
node_shared_presets -.->|"governs"| node_web_package
node_date_picker -->|"uses"| node_persian_date
node_ui_components -->|"contains"| node_date_picker
node_ui_components -->|"uses"| node_ui_styles
node_web_package -->|"runs"| node_app_shell
node_app_shell -->|"frames"| node_landing
node_app_shell -->|"frames"| node_docs_shell
node_docs_shell -->|"hosts"| node_component_docs
node_component_docs -->|"renders"| node_examples
node_component_docs -->|"reads source through"| node_doc_source
node_preview -->|"renders in isolation"| node_examples
node_machine_docs -->|"uses"| node_doc_source
node_app_shell -.->|"publishes discovery"| node_llms
node_component_docs -.->|"uses"| node_github
node_registry_index -->|"defines entries for"| node_registry_source
node_registry_index -->|"publishes"| node_install_manifests
node_component_docs -->|"presents installation from"| node_registry_index
node_registry_source -.->|"mirrors distribution boundary"| node_ui_components

click node_root "https://github.com/persianlabs/ui/blob/main/package.json"
click node_turbo "https://github.com/persianlabs/ui/blob/main/turbo.json"
click node_ui_components "https://github.com/persianlabs/ui/tree/main/packages/ui/src/components"
click node_date_picker "https://github.com/persianlabs/ui/blob/main/packages/ui/src/components/date-picker.tsx"
click node_persian_date "https://github.com/persianlabs/ui/blob/main/packages/ui/src/lib/persian-date.ts"
click node_ui_styles "https://github.com/persianlabs/ui/blob/main/packages/ui/src/styles/globals.css"
click node_web_package "https://github.com/persianlabs/ui/blob/main/apps/web/package.json"
click node_app_shell "https://github.com/persianlabs/ui/blob/main/apps/web/app/layout.tsx"
click node_landing "https://github.com/persianlabs/ui/blob/main/apps/web/app/page.tsx"
click node_docs_shell "https://github.com/persianlabs/ui/blob/main/apps/web/app/docs/layout.tsx"
click node_examples "https://github.com/persianlabs/ui/blob/main/apps/web/components/examples/date-picker-demo.tsx"
click node_doc_source "https://github.com/persianlabs/ui/blob/main/apps/web/lib/component-source.ts"
click node_preview "https://github.com/persianlabs/ui/blob/main/apps/web/app/preview/c/%5Bcomponent%5D/%5Bexample%5D/page.tsx"
click node_machine_docs "https://github.com/persianlabs/ui/blob/main/apps/web/app/docs/markdown/route.ts"
click node_llms "https://github.com/persianlabs/ui/blob/main/apps/web/app/llms.txt/route.ts"
click node_github "https://github.com/persianlabs/ui/blob/main/apps/web/lib/github.ts"
click node_registry_index "https://github.com/persianlabs/ui/blob/main/apps/web/registry.json"
click node_registry_source "https://github.com/persianlabs/ui/blob/main/apps/web/registry/base/ui/city-selector.tsx"
click node_install_manifests "https://github.com/persianlabs/ui/blob/main/apps/web/public/r/city-selector.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_root,node_turbo,node_shared_presets toneBlue
class node_ui_components,node_date_picker,node_persian_date,node_ui_styles toneAmber
class node_web_package,node_app_shell,node_landing,node_docs_shell,node_component_docs,node_examples,node_doc_source,node_preview,node_machine_docs,node_llms,node_github toneMint
class node_registry_index,node_registry_source,node_install_manifests toneRose
```

## Components

### Monorepo Tooling

- [Bun workspace](https://github.com/persianlabs/ui/blob/main/package.json): workspace manifest · Coordinates monorepo scripts and dependencies. · `package.json`
- [Turborepo pipeline](https://github.com/persianlabs/ui/blob/main/turbo.json): build orchestration · `turbo.json`
- **Shared lint and TS presets**: configuration packages

### UI Source Library

- [RTL component source](https://github.com/persianlabs/ui/tree/main/packages/ui/src/components): React TSX components · Canonical copy-paste component implementations. · `packages/ui/src/components`
- [Date picker](https://github.com/persianlabs/ui/blob/main/packages/ui/src/components/date-picker.tsx): domain component · `packages/ui/src/components/date-picker.tsx`
- [Persian date utilities](https://github.com/persianlabs/ui/blob/main/packages/ui/src/lib/persian-date.ts): domain utility · Provides Jalali date behavior. · `packages/ui/src/lib/persian-date.ts`
- [Global UI styles](https://github.com/persianlabs/ui/blob/main/packages/ui/src/styles/globals.css): CSS styles · `packages/ui/src/styles/globals.css`

### Next.js Docs Site

- [Web application manifest](https://github.com/persianlabs/ui/blob/main/apps/web/package.json): Next.js package · `apps/web/package.json`
- [App shell](https://github.com/persianlabs/ui/blob/main/apps/web/app/layout.tsx): App Router layout · `apps/web/app/layout.tsx`
- [Landing page](https://github.com/persianlabs/ui/blob/main/apps/web/app/page.tsx): App Router page · `apps/web/app/page.tsx`
- [Docs shell](https://github.com/persianlabs/ui/blob/main/apps/web/app/docs/layout.tsx): documentation layout · `apps/web/app/docs/layout.tsx`
- **Component docs pages**: dynamic documentation route · Combines API metadata, examples, source, and installation guidance.
- [Rendered examples](https://github.com/persianlabs/ui/blob/main/apps/web/components/examples/date-picker-demo.tsx): documentation demos · `apps/web/components/examples/date-picker-demo.tsx`
- [Documentation source resolver](https://github.com/persianlabs/ui/blob/main/apps/web/lib/component-source.ts): content service · Resolves source, previews, highlighting, and markdown support. · `apps/web/lib/component-source.ts`
- [Isolated preview route](https://github.com/persianlabs/ui/blob/main/apps/web/app/preview/c/%5Bcomponent%5D/%5Bexample%5D/page.tsx): dynamic preview page · `apps/web/app/preview/c/[component]/[example]/page.tsx`
- [Markdown documentation APIs](https://github.com/persianlabs/ui/blob/main/apps/web/app/docs/markdown/route.ts): route handlers · Serves machine-readable docs and selected component or utility pages. · `apps/web/app/docs/markdown/route.ts`
- [LLMs and crawler endpoints](https://github.com/persianlabs/ui/blob/main/apps/web/app/llms.txt/route.ts): discovery routes · `apps/web/app/llms.txt/route.ts`
- [GitHub support](https://github.com/persianlabs/ui/blob/main/apps/web/lib/github.ts): external data integration · `apps/web/lib/github.ts`

### Registry Distribution

- [Registry definitions](https://github.com/persianlabs/ui/blob/main/apps/web/registry.json): shadcn registry index · `apps/web/registry.json`
- [Registry source](https://github.com/persianlabs/ui/blob/main/apps/web/registry/base/ui/city-selector.tsx): distributable TSX source · Separate copy-paste source organized by UI, hooks, and utilities. · `apps/web/registry/base/ui/city-selector.tsx`
- [Install manifests](https://github.com/persianlabs/ui/blob/main/apps/web/public/r/city-selector.json): static registry JSON · Addressed by component name through the shadcn registry protocol. · `apps/web/public/r/city-selector.json`

## Connections

- 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
