# tamagui/tamagui architecture

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

- Interactive diagram: https://gitdiagram.com/tamagui/tamagui
- Repository: https://github.com/tamagui/tamagui

## Overview

##### Main Components Overview
The system should be divided into three core layers:

**┌─────────────────────────────────────────────┐**
- Application Layer              │
- ┬─────────────────────────┘

**┌───────────────────▼─────────────────────────┐**
- Tamagui Core Layer             │
- ┬─────────────────────────┘

**┌───────────────────▼─────────────────────────┐**
- Compilation Layer                │
- ┘

##### Detailed Component Breakdown

a. Core Components:
**┌─────────────────────────────────────────┐**
- Tamagui Core                │
- ┤
- Style Engine                          │
- Theme System                          │
- Animation System                      │
- Component Framework                   │
- ┘

b. UI Components:
**┌─────────────────────────────────────────┐**
- UI Components               │
- ┤
- Buttons                              │
- Forms                                │
- Navigation                           │
- Layout                               │
- Media                                │
- ┘

c. Compiler System:
**┌─────────────────────────────────────────┐**
- Static Compiler               │
- ┤
- Style Optimization                    │
- Component Flattening                  │
- Platform-Specific Output              │
- ┘

##### Platform Integration
**┌─────────────────────┐    ┌─────────────────────┐**
- Web Output     │    │    Native Output    │
- ┤    ├─────────────────────┤
- Optimized CSS     │    │ - React Native      │
- Flattened HTML    │    │   Components        │
- ┘    └─────────────────────┘

##### Development Tools
**┌─────────────────────────────────────────┐**
- Development Tools             │
- ┤
- CLI Tools                            │
- Theme Builder                        │
- Debug Utilities                      │
- ┘

##### Data Flow
- Component composition flow
- Style compilation process
- Theme inheritance
- Platform-specific optimizations

##### Important Notes
- Clear separation between runtime and compile-time processes
- Optimization pipeline
- Cross-platform compatibility points
- Integration points with external tools
- Theme system flow

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef ui fill:#4CAF50,stroke:#2E7D32,color:white
    classDef compiler fill:#FF9800,stroke:#EF6C00,color:white
    classDef platform fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef tools fill:#757575,stroke:#424242,color:white

    %% Application Layer
    subgraph AppLayer["Application Layer"]
        App["Application Code"]
    end

    %% Core Layer
    subgraph CoreLayer["Tamagui Core Layer"]
        direction TB
        StyleEngine["Style Engine"]:::core
        ThemeSystem["Theme System"]:::core
        AnimationSystem["Animation System"]:::core
        CompFramework["Component Framework"]:::core

        subgraph UIComponents["UI Components"]
            direction TB
            Buttons["Buttons"]:::ui
            Forms["Forms"]:::ui
            Navigation["Navigation"]:::ui
            Layout["Layout"]:::ui
            Media["Media"]:::ui
        end
    end

    %% Compilation Layer
    subgraph CompLayer["Compilation Layer"]
        direction TB
        StaticCompiler["Static Compiler"]:::compiler
        
        subgraph Plugins["Platform Plugins"]
            BabelPlugin["Babel Plugin"]:::compiler
            MetroPlugin["Metro Plugin"]:::compiler
            NextPlugin["Next.js Plugin"]:::compiler
            VitePlugin["Vite Plugin"]:::compiler
        end
    end

    %% Platform Outputs
    subgraph Outputs["Platform Outputs"]
        WebOutput["Web Output"]:::platform
        NativeOutput["Native Output"]:::platform
    end

    %% Development Tools
    subgraph DevTools["Development Tools"]
        CLI["CLI Tools"]:::tools
        ThemeBuilder["Theme Builder"]:::tools
        DebugUtils["Debug Utilities"]:::tools
    end

    %% Connections
    App --> StyleEngine
    App --> ThemeSystem
    App --> AnimationSystem
    App --> UIComponents
    
    StyleEngine --> StaticCompiler
    ThemeSystem --> StaticCompiler
    AnimationSystem --> StaticCompiler
    UIComponents --> StaticCompiler
    
    StaticCompiler --> Plugins
    Plugins --> WebOutput
    Plugins --> NativeOutput

    %% Click Events
    click StyleEngine "https://github.com/tamagui/tamagui/tree/master/code/core/web/"
    click ThemeSystem "https://github.com/tamagui/tamagui/tree/master/code/core/theme/"
    click AnimationSystem "https://github.com/tamagui/tamagui/tree/master/code/core/animations-css/"
    click StaticCompiler "https://github.com/tamagui/tamagui/tree/master/code/compiler/static/"
    click BabelPlugin "https://github.com/tamagui/tamagui/tree/master/code/compiler/babel-plugin/"
    click MetroPlugin "https://github.com/tamagui/tamagui/tree/master/code/compiler/metro-plugin/"
    click NextPlugin "https://github.com/tamagui/tamagui/tree/master/code/compiler/next-plugin/"
    click VitePlugin "https://github.com/tamagui/tamagui/tree/master/code/compiler/vite-plugin/"
    click Buttons "https://github.com/tamagui/tamagui/tree/master/code/ui/button/"
    click Forms "https://github.com/tamagui/tamagui/tree/master/code/ui/form/"
    click Layout "https://github.com/tamagui/tamagui/tree/master/code/ui/stacks/"
    click CLI "https://github.com/tamagui/tamagui/tree/master/code/core/cli/"
    click ThemeBuilder "https://github.com/tamagui/tamagui/tree/master/code/core/theme-builder/"
    click DebugUtils "https://github.com/tamagui/tamagui/tree/master/code/core/core-test/"
```
