# gympass/yoga architecture

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

- Interactive diagram: https://gitdiagram.com/gympass/yoga
- Repository: https://github.com/gympass/yoga

## Overview

##### High-Level File Structure
- Top-level tooling and config: Lerna, Yarn workspaces, Babel, TypeScript, ESLint, Prettier, Jest, GitHub workflows, custom scripts.
- **packages/** (each a separately versioned npm package):
- yoga (main component library)
- system (style utility functions, theming engine)
- common (shared helpers)
- illustrations (SVG illustration library)
- helpers (runtime helper functions)
- labnative (RN example/app for mobile showcase)
- doc (Gatsby/MDX documentation site)
- **examples/** (Next.js usage examples)
- **scripts/** (CLI generators, build/publish helpers)
- **jest/** (test configs and mocks)

##### Key Architectural Insights from README
- Monorepo powered by Lerna & Yarn workspaces.
- Core theming via a single ThemeProvider that leverages tokens and system packages.
- Components live in **packages/yoga**, split into Web and Native entry points.
- Documentation site (**packages/doc**) renders MDX examples, building against the published packages.
- Mobile demonstration app (**packages/labnative**) consumes the same library packages to showcase components in a real RN environment.

##### Main Components & Their Relationships
- **Design Tokens** (packages/tokens) → consumed by → **Styling System** (packages/system) → consumed by → **Component Library** (packages/yoga)
- **Common Helpers** (packages/common, packages/helpers) → used by → system & yoga packages
- **Component Library** → packaged for →
- Web (React + styled-components)
- Native (React Native)
- **Documentation Site** (packages/doc) → imports → component library, tokens, system to auto-generate MDX docs
- **Mobile Demo App** (packages/labnative) → imports → component library, tokens, system for real-device previews
- **Examples** (examples/with-next) → demonstrates Web usage in a Next.js setup

##### Architectural Patterns & Technologies
- **Monorepo** (Lerna + Yarn workspaces) for cross-package versioning and dependency linking
- **Component-driven architecture**: all UI components live in a single package with separate web/native entry points
- **Theming**: Single source of truth via tokens + ThemeProvider (styled-components under the hood)
- **Documentation as Code**: Gatsby + MDX site consuming live components
- **CI/CD**: GitHub Actions for linting, testing, publishing

## Diagram (Mermaid)

```mermaid
graph TB
    %% Core Packages
    subgraph "Core Packages"
        direction TB
        Tokens["Design Tokens"]:::core
        System["Styling System"]:::core
        Common["Common Helpers"]:::core
        Helpers["Runtime Helpers"]:::core
    end

    %% Asset Libraries
    subgraph "Asset Libraries"
        direction TB
        Icons["Icons Library"]:::assets
        Illustrations["Illustrations Library"]:::assets
    end

    %% UI Library
    subgraph "UI Component Library"
        direction TB
        Yoga["Yoga (Component Library)"]:::ui
        subgraph "Theme Provider & Engine"
            direction TB
            ThemeProvider["ThemeProvider"]:::ui
            ThemeGen["themeGenerator"]:::ui
            ThemeRead["themeReader"]:::ui
        end
    end

    %% Deliverables
    subgraph "Deliverables"
        direction TB
        Doc["Documentation Site"]:::deliverable
        LabNative["Mobile Demo App"]:::deliverable
        Examples["Web Examples (Next.js)"]:::deliverable
    end

    %% Tooling
    subgraph "Tooling & CI/CD"
        direction TB
        Monorepo["Lerna & Yarn Workspaces"]:::tool
        BuildScripts["Build & Publish Scripts"]:::tool
        Testing["Jest Configurations"]:::tool
        CI["GitHub Actions"]:::tool
    end

    %% Dependencies
    Tokens -->|"used by"| System
    Common -->|"utilities for"| System
    Helpers -->|"runtime helpers for"| System
    System -->|"style utils imported by"| Yoga
    Common -->|"utilities for"| Yoga
    Helpers -->|"runtime helpers for"| Yoga
    Icons -->|"assets imported by"| Yoga
    Illustrations -->|"assets imported by"| Yoga

    ThemeProvider -->|"wraps components in"| Yoga
    ThemeGen -->|"generates theme from tokens"| Yoga
    ThemeRead -->|"reads theme values"| Yoga

    Yoga -->|"docs imports components"| Doc
    Yoga -->|"app imports components"| LabNative
    Yoga -->|"example imports components"| Examples
    System -->|"tokens are core to"| ThemeGen

    Monorepo -->|manages versions| Tokens
    Monorepo -->|manages versions| System
    Monorepo -->|manages versions| Common
    Monorepo -->|manages versions| Helpers
    Monorepo -->|manages versions| Icons
    Monorepo -->|manages versions| Illustrations
    Monorepo -->|manages versions| Yoga
    Monorepo -->|manages versions| Doc
    Monorepo -->|manages versions| LabNative
    Monorepo -->|manages versions| Examples

    BuildScripts -->|"build & publish packages"| Yoga
    BuildScripts -->|"build docs"| Doc

    Testing -->|"tests packages"| Yoga
    Testing -->|"tests packages"| System
    Testing -->|"tests packages"| Tokens

    CI -->|"runs lint/test/publish"| BuildScripts

    %% Click Events
    click Tokens "https://github.com/gympass/yoga/tree/master/packages/tokens/src"
    click System "https://github.com/gympass/yoga/tree/master/packages/system/src"
    click Common "https://github.com/gympass/yoga/tree/master/packages/common/src"
    click Helpers "https://github.com/gympass/yoga/tree/master/packages/helpers/src"
    click Icons "https://github.com/gympass/yoga/tree/master/packages/icons/src"
    click Icons "https://github.com/gympass/yoga/tree/master/packages/icons/src/svg"
    click Illustrations "https://github.com/gympass/yoga/tree/master/packages/illustrations/src"
    click Illustrations "https://github.com/gympass/yoga/tree/master/packages/illustrations/src/svg"
    click Yoga "https://github.com/gympass/yoga/tree/master/packages/yoga/src"
    click ThemeProvider "https://github.com/gympass/yoga/tree/master/packages/yoga/src/Theme/Provider"
    click ThemeGen "https://github.com/gympass/yoga/tree/master/packages/yoga/src/Theme/helpers/themeGenerator"
    click ThemeRead "https://github.com/gympass/yoga/tree/master/packages/yoga/src/Theme/helpers/themeReader"
    click Doc "https://github.com/gympass/yoga/tree/master/packages/doc"
    click LabNative "https://github.com/gympass/yoga/tree/master/packages/labnative"
    click Examples "https://github.com/gympass/yoga/tree/master/examples/with-next"
    click Monorepo "https://github.com/gympass/yoga/blob/master/lerna.json"
    click Monorepo "https://github.com/gympass/yoga/blob/master/package.json"
    click BuildScripts "https://github.com/gympass/yoga/tree/master/scripts"
    click Testing "https://github.com/gympass/yoga/tree/master/jest/config"
    click Testing "https://github.com/gympass/yoga/tree/master/jest/setup"
    click Testing "https://github.com/gympass/yoga/tree/master/jest/mock"

    %% Styles
    classDef core fill:#bbdefb,stroke:#0d47a1,stroke-width:1px
    classDef assets fill:#ffe0b2,stroke:#e65100,stroke-width:1px
    classDef ui fill:#c8e6c9,stroke:#1b5e20,stroke-width:1px
    classDef deliverable fill:#e1bee7,stroke:#4a148c,stroke-width:1px
    classDef tool fill:#eeeeee,stroke:#616161,stroke-width:1px
```
