# lttb/taddy architecture

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

- Interactive diagram: https://gitdiagram.com/lttb/taddy
- Repository: https://github.com/lttb/taddy

## Overview

##### Main Components

a. Core Engine Layer:
- NameGenerator and static processing components
- Rule injection system (RuleInjector)

b. Framework Integration Layer:
- Next.js (@taddy/next-plugin)
- Vite (@taddy/vite-plugin)
- ESBuild (@taddy/esbuild-plugin)
- React Native support
- Vue integration
- Various framework examples (Astro, Nuxt, SvelteKit, etc.)

c. Build System Layer:
- Babel plugin system (@taddy/babel-plugin)
- Macro processing (taddy.macro)
- Compilation and optimization pipeline

##### Component Relationships

- Data flow from style definitions to processed CSS
- Compilation process flow
- Framework integration paths
- Runtime vs. build-time processes

##### Specific Implementation Details

a. Style Processing Pipeline:
**Style Definition → Babel Transform → Static Optimization → CSS Generation → Injection**

b. Framework Integration Points:
- How each framework plugin connects to the core
- Different entry points (macro, direct usage, plugin)

##### Key Technical Elements

- CSS rule injection system
- Static optimization engine
- Framework-specific transformers
- Development tools (playground, documentation)

##### Architecture Patterns

Highlight:
- Plugin architecture
- Framework adaptation layer
- Build-time optimization
- Runtime style injection

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core ["Core Processing Layer"]
        CoreEngine["@taddy/core"]
        NameGen["Name Generator"]
        RuleInject["Rule Injection System"]
        StaticProc["Static Processing"]
    end

    subgraph Build ["Build System Layer"]
        BabelPlugin["Babel Plugin"]
        MacroProc["Macro Processing"]
        StaticOpt["Static Optimization"]
        StyleProc["Style Processing"]
    end

    subgraph Frameworks ["Framework Integration Layer"]
        NextPlugin["Next.js Plugin"]
        VitePlugin["Vite Plugin"]
        ESBuildPlugin["ESBuild Plugin"]
        ReactNative["React Native"]
        VueInteg["Vue Integration"]
    end

    subgraph Examples ["Framework Examples"]
        NextExample["Next.js Example"]
        AstroExample["Astro Example"]
        NuxtExample["Nuxt Example"]
        SvelteExample["SvelteKit Example"]
        RNExample["React Native Example"]
    end

    subgraph DevTools ["Development Tools"]
        Playground["Playground"]
        LiveEditor["Live Editor"]
        Compiler["Compiler"]
    end

    %% Core Layer Relationships
    CoreEngine --> NameGen
    CoreEngine --> RuleInject
    CoreEngine --> StaticProc

    %% Build System Relationships
    CoreEngine --> BabelPlugin
    CoreEngine --> MacroProc
    BabelPlugin --> StaticOpt
    MacroProc --> StyleProc

    %% Framework Integration Relationships
    CoreEngine --> NextPlugin
    CoreEngine --> VitePlugin
    CoreEngine --> ESBuildPlugin
    CoreEngine --> ReactNative
    CoreEngine --> VueInteg

    %% Example Relationships
    NextPlugin --> NextExample
    VitePlugin --> AstroExample
    VitePlugin --> NuxtExample
    VitePlugin --> SvelteExample
    ReactNative --> RNExample

    %% Dev Tools Relationships
    CoreEngine --> Playground
    Playground --> LiveEditor
    Playground --> Compiler

    %% Styling
    classDef core fill:#a8dadc,stroke:#457b9d
    classDef build fill:#e9c46a,stroke:#f4a261
    classDef framework fill:#2a9d8f,stroke:#264653
    classDef example fill:#8ecae6,stroke:#219ebc
    classDef devtool fill:#ffafcc,stroke:#ff758f

    class CoreEngine,NameGen,RuleInject,StaticProc core
    class BabelPlugin,MacroProc,StaticOpt,StyleProc build
    class NextPlugin,VitePlugin,ESBuildPlugin,ReactNative,VueInteg framework
    class NextExample,AstroExample,NuxtExample,SvelteExample,RNExample example
    class Playground,LiveEditor,Compiler devtool

    %% Click Events
    click CoreEngine "https://github.com/lttb/taddy/blob/main/@taddy/core/index.ts"
    click NameGen "https://github.com/lttb/taddy/blob/main/@taddy/core/NameGenerator/index.ts"
    click RuleInject "https://github.com/lttb/taddy/blob/main/taddy/RuleInjector/index.ts"
    click NextPlugin "https://github.com/lttb/taddy/blob/main/@taddy/next-plugin/index.js"
    click VitePlugin "https://github.com/lttb/taddy/blob/main/@taddy/vite-plugin/index.js"
    click ESBuildPlugin "https://github.com/lttb/taddy/blob/main/@taddy/esbuild-plugin/index.js"
    click ReactNative "https://github.com/lttb/taddy/blob/main/taddy/react-native/processStyles.ts"
    click VueInteg "https://github.com/lttb/taddy/blob/main/taddy/vue/index.ts"
    click BabelPlugin "https://github.com/lttb/taddy/blob/main/@taddy/babel-plugin/src/plugin.ts"
    click MacroProc "https://github.com/lttb/taddy/blob/main/taddy.macro/index.ts"
    click StaticOpt "https://github.com/lttb/taddy/blob/main/@taddy/babel-plugin/src/helpers/optimizeStaticStyles.ts"
    click StyleProc "https://github.com/lttb/taddy/blob/main/@taddy/babel-plugin/src/Output.ts"
    click Playground "https://github.com/lttb/taddy/blob/main/@docs/website/components/playground/index.tsx"
    click LiveEditor "https://github.com/lttb/taddy/blob/main/@docs/website/components/playground/LiveEditor.tsx"
    click Compiler "https://github.com/lttb/taddy/blob/main/@docs/website/compiler/index.ts"
    click NextExample "https://github.com/lttb/taddy/tree/main/@examples/nextjs"
    click AstroExample "https://github.com/lttb/taddy/tree/main/@examples/astro"
    click NuxtExample "https://github.com/lttb/taddy/tree/main/@examples/nuxt"
    click SvelteExample "https://github.com/lttb/taddy/tree/main/@examples/svelte-kit"
    click RNExample "https://github.com/lttb/taddy/tree/main/@examples/react-native-expo"
```
