# npmirajkar/stenicljs-reactjs-lerna architecture

> Architecture diagram of the GitHub repository npmirajkar/stenicljs-reactjs-lerna, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/npmirajkar/stenicljs-reactjs-lerna
- Repository: https://github.com/npmirajkar/stenicljs-reactjs-lerna

## Overview

##### Project Type and Purpose
- This is a **monorepo-based design system** for UI components.
- It consists of three tightly-coupled packages managed with Lerna and npm workspaces:
- A framework-agnostic StencilJS component library (atoms → molecules → organisms)
- React wrapper components that proxy the StencilJS web components
- A sample React application that consumes those wrappers

##### High-Level Architecture Components
a. Root Monorepo (Lerna + npm workspaces)
b. Package #1: StencilJS Component Library
- Source: /packages/components/src/components/{atoms,molecules,organisms}
- Build outputs:
- Web Components (custom elements)
- React proxy definitions (via stencil's reactOutputTarget)
c. Package #2: React Components (wrappers)
- Source: /packages/react-components/src/components
- Input: generated stencil-proxy definitions
- Output: NPM package of ready-to-use React components
d. Package #3: React App (demo/consumer)
- Source: /packages/react-app/src
- Imports React wrappers from package #2
- Bundles with Vite, applies TailwindCSS

##### Architectural Patterns & Design Principles
- **Proxy Generation Pattern** (Stencil → React proxy generation).
- **Monorepo Management** (Lerna + npm workspaces) for dependency hoisting and inter-package linking.
- **Dev/Build Pipelines**:
- StencilJS build pipeline (TS → PostCSS/Tailwind → Web Components + proxies)
- React Components build (TS compilation)
- React App build (Vite, CSS processing)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Monorepo (Lerna + npm workspaces)"
        direction TB
        RootConfig1["lerna.json"]:::config
        RootConfig2["package.json"]:::config
        ViteConfig["vite.config.ts"]:::file
        TSConfig["tsconfig.json"]:::file
        PostCSS["postcss.config.js"]:::file
        RootTailwind["tailwind.config.js"]:::file
        ESLint["eslint.config.js"]:::file

        subgraph "StencilJS Component Library"
            direction TB
            style A fill:#D0E8FF,stroke:#0288D1
            subgraph "Atomic Design"
                direction TB
                Atoms["Atoms"]:::component
                Molecules["Molecules"]:::component
                Organisms["Organisms"]:::component
            end
            SCIndex["src/index.ts"]:::file
            SCStencilConfig["stencil.config.ts"]:::file
            SCTailwind["tailwind.config.js"]:::file
            BuildOutput["Build Output: Web Components + Proxies"]:::process
            StencilDev["Stencil Dev Server"]:::server
        end

        subgraph "React Components (Wrappers)"
            direction TB
            style B fill:#E0F2E9,stroke:#2E7D32
            RCIndex["src/index.ts"]:::file
            RCGenerated["src/components/stencil-generated/index.ts"]:::file
            RCComponents["src/components/index.ts"]:::file
            RCBuild["Build Output: React package"]:::process
        end

        subgraph "React App (Demo)"
            direction TB
            style C fill:#FFF3E0,stroke:#FB8C00
            RAIndexHTML["index.html"]:::file
            RATailwind["tailwind.config.js"]:::file
            RAMain["src/main.tsx"]:::file
            RAApp["src/App.tsx"]:::file
            RAComps["src/components"]:::dir
            RAPages["src/pages"]:::dir
            RABuild["Bundled by Vite + Tailwind"]:::process
            ReactDev["Vite Dev Server"]:::server
        end
    end

    RootConfig1 -->|"manages"| A
    RootConfig2 -->|"manages"| A
    RootConfig1 -->|"manages"| B
    RootConfig2 -->|"manages"| B
    RootConfig1 -->|"manages"| C
    RootConfig2 -->|"manages"| C

    A -->|"reactOutputTarget proxies"| B
    B -->|"import @design-system/react-components"| C

    DevWorkflow["npm run dev"]:::workflow
    DevWorkflow ---|runs| StencilDev
    DevWorkflow ---|runs| ReactDev

    classDef component fill:#BBDEFB,stroke:#0D47A1
    classDef file fill:#EEEEEE,stroke:#757575,stroke-dasharray: 2 2
    classDef dir fill:#E1F5FE,stroke:#0288D1,stroke-dasharray: 2 2
    classDef process fill:#C8E6C9,stroke:#388E3C
    classDef server fill:#FFECB3,stroke:#F57C00
    classDef workflow fill:#D1C4E9,stroke:#5E35B1
    classDef config fill:#F5F5F5,stroke:#9E9E9E

    click RootConfig1 "https://github.com/npmirajkar/stenicljs-reactjs-lerna/blob/main/lerna.json"
    click RootConfig2 "https://github.com/npmirajkar/stenicljs-reactjs-lerna/blob/main/package.json"
    click ViteConfig "https://github.com/npmirajkar/stenicljs-reactjs-lerna/blob/main/vite.config.ts"
    click TSConfig "https://github.com/npmirajkar/stenicljs-reactjs-lerna/blob/main/tsconfig.json"
    click PostCSS "https://github.com/npmirajkar/stenicljs-reactjs-lerna/blob/main/postcss.config.js"
    click RootTailwind "https://github.com/npmirajkar/stenicljs-reactjs-lerna/blob/main/tailwind.config.js"
    click ESLint "https://github.com/npmirajkar/stenicljs-reactjs-lerna/blob/main/eslint.config.js"
    click Atoms "https://github.com/npmirajkar/stenicljs-reactjs-lerna/tree/main/packages/components/src/components"
    click Molecules "https://github.com/npmirajkar/stenicljs-reactjs-lerna/tree/main/packages/components/src/components"
    click Organisms "https://github.com/npmirajkar/stenicljs-reactjs-lerna/tree/main/packages/components/src/components"
    click SCIndex "https://github.com/npmirajkar/stenicljs-reactjs-lerna/blob/main/packages/components/src/index.ts"
    click SCStencilConfig "https://github.com/npmirajkar/stenicljs-reactjs-lerna/blob/main/packages/components/stencil.config.ts"
    click SCTailwind "https://github.com/npmirajkar/stenicljs-reactjs-lerna/blob/main/packages/components/tailwind.config.js"
    click RCIndex "https://github.com/npmirajkar/stenicljs-reactjs-lerna/blob/main/packages/react-components/src/index.ts"
    click RCGenerated "https://github.com/npmirajkar/stenicljs-reactjs-lerna/blob/main/packages/react-components/src/components/stencil-generated/index.ts"
    click RCComponents "https://github.com/npmirajkar/stenicljs-reactjs-lerna/blob/main/packages/react-components/src/components/index.ts"
    click RAIndexHTML "https://github.com/npmirajkar/stenicljs-reactjs-lerna/blob/main/packages/react-app/index.html"
    click RATailwind "https://github.com/npmirajkar/stenicljs-reactjs-lerna/blob/main/packages/react-app/tailwind.config.js"
    click RAMain "https://github.com/npmirajkar/stenicljs-reactjs-lerna/blob/main/packages/react-app/src/main.tsx"
    click RAApp "https://github.com/npmirajkar/stenicljs-reactjs-lerna/blob/main/packages/react-app/src/App.tsx"
    click RAComps "https://github.com/npmirajkar/stenicljs-reactjs-lerna/tree/main/packages/react-app/src/components"
    click RAPages "https://github.com/npmirajkar/stenicljs-reactjs-lerna/tree/main/packages/react-app/src/pages"
```
