# iobuhov/radix-kit architecture

> Architecture diagram of the GitHub repository iobuhov/radix-kit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/iobuhov/radix-kit
- Repository: https://github.com/iobuhov/radix-kit

## Overview

##### Main Components
- Core Modules: Identify the fundamental building blocks located in “modules/radix-kit”. This module includes configuration files (like YAML for design properties), scripts (tasks for widget generation and design property management), and core tooling logic.
- Packages:
- Gen-Widget: Found in “packages/gen-widget”, this package provides a generator tool that scaffolds widget projects (using Handlebars templates and turbo configurations).
- Radix UI Themes: Under “packages/radix-ui-themes”, you have a set of React-based theme components and utilities (including component props definitions, helper functions, and preview configurations).
- Task Utilities: “packages/task-utils” offers reusable scripts and utilities for running file inspections, logging, or other dev tasks.
- Project and Themesource: The “project” and “project/themesource” directories likely serve as demonstrative or sample projects where the library or generated widgets can be integrated and tested.
- Scripts/CLI: There are several CLI and setup scripts (e.g., “scripts/set-project.mts”) to manage project-level tasks like setting up environments or running dev commands.

##### Relationships and Interactions
- The development mode (triggered by “pnpm dev”) and widget generation (via “pnpm gen widget”) commands show that there is an integration between the command-line tooling (likely leveraging the “modules/radix-kit” and “packages/gen-widget”) and the overall component rendering.
- Radix UI Styles and Themes form the foundational design and theming system that widgets and eventual user interfaces rely upon. They are consumed by both the generated widgets and the sample projects.
- Task utilities and build scripts (such as those in “packages/task-utils” and “scripts”) provide support for continuous development, linting, and code consistency.
- The widget directories themselves demonstrate how each individual component is structured, possibly to be consumed in larger applications (illustrated by the “project” directory).

##### Architectural Patterns and Technologies
- Monorepo Structure: The project is organized as a monorepo managed by pnpm workspaces (pnpm-workspace.yaml), which implies that there is inter-package dependency management and a build system (turbo.json is present for TurboRepo).
- Component-Based Architecture: Individual widgets and UI components are separated into self-contained packages and directories, each including preview, configuration, and type-checking resources.
- Template-Based Generation: The use of Handlebars templates within “packages/gen-widget/turbo/generators/templates” indicates that new widget scaffolds can be generated consistently.
- Styling and Theming: SCSS modules with a clear token system, design properties, and theme provider components suggest a robust visual design architecture.
- Use of modern JavaScript/TypeScript tooling is evident (usage of .mts files, tsconfig.json, etc.).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "CLI Tools"
        CLI1["CLI Setup Script (set-project.mts)"]:::cli
        CLI2["Radix Kit CLI Scripts"]:::cli
    end

    subgraph "Core Infrastructure"
        M["Core Modules"]:::core
    end

    subgraph "Packages"
        G1["Widget Generator Engine"]:::generator
        S1["Radix UI Styles"]:::styles
        T1["Radix UI Themes"]:::themes
        U1["Task Utilities"]:::utilities
    end

    subgraph "Widgets"
        W["Widgets Collection"]:::widget
    end

    subgraph "Sample Projects"
        SP["Sample Project"]:::sample
        TS["Themesource"]:::sample
    end

    %% Connections from CLI Tools to Core Infrastructure and Packages
    CLI1 -->|"runs"| M
    CLI2 -->|"runs"| M
    CLI1 -->|"triggers"| G1

    %% Task Utilities support Core Modules and Widget Generation
    U1 -->|"supports"| M
    U1 -->|"supports"| G1

    %% Core Modules and Generator Engine feed Widgets
    M -->|"feeds"| W
    G1 -->|"generates"| W

    %% Styling and Theming Packages contribute to Widgets
    S1 -->|"styles"| W
    T1 -->|"themes"| W

    %% Widgets are integrated into Sample Projects
    W -->|"integrated_into"| SP
    W -->|"integrated_into"| TS

    %% Click Events
    click M "https://github.com/iobuhov/radix-kit/tree/main/modules/radix-kit"
    click G1 "https://github.com/iobuhov/radix-kit/tree/main/packages/gen-widget"
    click S1 "https://github.com/iobuhov/radix-kit/tree/main/packages/radix-ui-styles"
    click T1 "https://github.com/iobuhov/radix-kit/tree/main/packages/radix-ui-themes"
    click U1 "https://github.com/iobuhov/radix-kit/tree/main/packages/task-utils"
    click W "https://github.com/iobuhov/radix-kit/tree/main/widgets"
    click SP "https://github.com/iobuhov/radix-kit/tree/main/project"
    click TS "https://github.com/iobuhov/radix-kit/tree/main/project/themesource"
    click CLI1 "https://github.com/iobuhov/radix-kit/blob/main/scripts/set-project.mts"
    click CLI2 "https://github.com/iobuhov/radix-kit/tree/main/modules/radix-kit/scripts"

    %% Style Definitions
    classDef cli fill:#4A90E2,stroke:#333,stroke-width:2px,color:#fff;
    classDef core fill:#F5A623,stroke:#333,stroke-width:2px,color:#fff;
    classDef generator fill:#7ED321,stroke:#333,stroke-width:2px,color:#fff;
    classDef styles fill:#50E3C2,stroke:#333,stroke-width:2px,color:#fff;
    classDef themes fill:#BD10E0,stroke:#333,stroke-width:2px,color:#fff;
    classDef utilities fill:#9013FE,stroke:#333,stroke-width:2px,color:#fff;
    classDef widget fill:#F8E71C,stroke:#333,stroke-width:2px,color:#000;
    classDef sample fill:#D0021B,stroke:#333,stroke-width:2px,color:#fff;
```
