# vaadin/react-components architecture

> Architecture diagram of the GitHub repository vaadin/react-components, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vaadin/react-components
- Repository: https://github.com/vaadin/react-components

## Overview

##### Main Components
- Component Libraries:
- packages/react-components: Contains the base set of React wrappers.
- packages/react-components-pro: Contains a more advanced or “pro” set of React wrappers (and may include additional features controlled via separate build scripts and utilities).
- Development Environment:
- dev: Includes example/demo pages, such as the “kitchen-sink” and various sample pages (e.g., Button.tsx, ContextMenu.tsx) that demonstrate how the components are used.
- Vite Config: The vite.config.ts file is used with a custom plugin to allow local component testing within a Vaadin application.
- Build and Utility Scripts:
- scripts: Various build, package management, and code generation scripts that drive the package build/update process.
- Testing:
- test: Contains test files for various components (e.g., ComboBox.spec.tsx, Dialog.spec.tsx) and related utility functions for testing.
- CI/CD:
- .github/workflows: Contains GitHub actions (e.g., validation.yml) to automate build/validation processes.

##### Establish Relationships and Interactions
- The React component libraries (react-components and react-components-pro) are core. They are built using the build scripts and then imported into consumer projects.
- The dev directory provides demos and example usage, simulating how a Vaadin consumer application can integrate the libraries. The custom Vite plugin (with its configuration in the README) is an important bridge in this interaction.
- The Vite configuration file (vite.config.ts) incorporates the “useLocalReactComponents” plugin. This plugin allows a local Vaadin project to load these libraries from the local filesystem, emphasizing a local development/testing cycle.
- Build and testing scripts collaborate to validate the changes in the component libraries during development and before deployment.
- GitHub workflows (CI/CD) ensure that code quality checks, builds, and validations are automatically applied to changes.

##### Architectural Patterns and Design Principles
- Monorepo Architecture: The project structure is organized into separate packages sharing a common repository. This facilitates code reuse and coordinated versioning.
- Separation of Concerns: The distinct separation between the core component libraries, development demo applications, and build/test infrastructure illustrates clear boundaries and responsibilities.
- Plugin-Based Extensibility: The custom Vite plugin (as detailed in the README) demonstrates an architectural approach to extend configuration and integration seamlessly with Vaadin projects.
- Component-Driven Architecture: Both the base and “pro” packages are designed in a modular fashion, each exporting self-contained UI components that can be individually imported and tested.

##### Relevant Technologies and Frameworks
- React: The component libraries are React-based.
- Vaadin: The target is to provide React wrappers around Vaadin components.
- Vite: Used as the build tool and development server, enhanced with custom plugins.
- TypeScript: Evident from the file extensions (.ts, .tsx) and the presence of tsconfig files.
- Testing Frameworks: Likely using Jest or a similar testing library (given the .spec.tsx files and testing utilities).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Component Libraries"
        RC["React Components (Base)"]:::lib
        RCP["React Components Pro"]:::lib
    end

    subgraph "Development & Integration"
        DEV["Dev Environment (Example Usage & Demo)"]:::dev
        VITE["Vite Config & Local Plugin"]:::plugin
    end

    subgraph "Build & Infrastructure"
        SCRIPTS["Build & Utility Scripts"]:::build
        TEST["Testing Infrastructure"]:::build
        CICD["CI/CD Pipeline"]:::ci
    end

    %% Relationships: Component libraries to Development Environment
    RC -->|"usage"| DEV
    RCP -->|"usage"| DEV

    %% Relationships: Component libraries to Build Scripts
    RC -->|"build"| SCRIPTS
    RCP -->|"build"| SCRIPTS

    %% Build flow: Build Scripts to Testing and CI/CD
    SCRIPTS -->|"test"| TEST
    TEST -->|"validate"| CICD

    %% Vite plugin integration: Vite config connects to both libraries and development environment
    VITE -->|"integrates"| RC
    VITE -->|"integrates"| RCP
    VITE -->|"supports"| DEV

    %% Click Events
    click RC "https://github.com/vaadin/react-components/tree/main/packages/react-components"
    click RCP "https://github.com/vaadin/react-components/tree/main/packages/react-components-pro"
    click DEV "https://github.com/vaadin/react-components/tree/main/dev"
    click VITE "https://github.com/vaadin/react-components/blob/main/vite.config.ts"
    click SCRIPTS "https://github.com/vaadin/react-components/tree/main/scripts"
    click TEST "https://github.com/vaadin/react-components/tree/main/test"
    click CICD "https://github.com/vaadin/react-components/tree/main/.github/workflows"

    %% Styles
    classDef lib fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef dev fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef plugin fill:#DDA0DD,stroke:#000,stroke-width:2px;
    classDef build fill:#FFDAB9,stroke:#000,stroke-width:2px;
    classDef ci fill:#FFA07A,stroke:#000,stroke-width:2px;
```
