# johanholmerin/style9 architecture

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

- Interactive diagram: https://gitdiagram.com/johanholmerin/style9
- Repository: https://github.com/johanholmerin/style9

## Overview

##### Main Components Identification

a) Compiler Core
- Main processing units from src/:
- process-css.js
- process-references.js
- plugin-utils.js

b) Input Processing Layer
- Supported file types (.js, .ts, .tsx)
- Transpilers (from src/transpilers/)
- To helper functions (src/helpers/)

c) Build Tool Integration Layer
- Integration with multiple bundlers:
- Webpack
- Rollup
- Vite
- Next.js
- Gatsby

d) Output Generation Layer
- CSS Output
- Optimized JavaScript
- Type Definitions

##### Component Relationships

**Input Files → Build Tool Plugin → Compiler Core → Output Files**
- ↓
- Style Processing
- ↓
- Atomic CSS Generation

##### Specific Implementation Details

Key features:
- Atomic CSS extraction process
- Style compilation pipeline
- TypeScript integration
- Zero-runtime optimization

##### Technical Elements to Highlight

- Style creation and processing
- CSS property minification
- Keyframe handling
- Nested styles processing
- Incremental classname generation

**┌─ Build Integration Layer ─┐**
- [Webpack] [Rollup] [Vite]│
- [Next.js] [Gatsby]       │
- ┬───────────────┘
- ↓
**┌─ Core Processing Layer ──┐**
- ┌─ Style Processor ─┐   │
- CSS Processing │   │
- AST Transform  │   │
- ┬─┘   │
- ↓         │     │
- ┌─ Optimization ─┐│     │
- Minification││     │
- Atomic CSS  ││     │
- ┘│     │
- ┬┴─────┘
- ↓
**┌─ Output Layer ──────────┐**
- [CSS Files]             │
- [Optimized JavaScript]  │
- [Type Definitions]      │
- ┘

##### Important Notes

- Clear separation between build-time and runtime components
- Zero-runtime nature of the solution
- Test integration points
- Configuration flow
- Where type definitions are generated and used

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        IF[Input Files]
        TS[".ts/.tsx Files"]
        JS[".js Files"]
    end

    subgraph "Build Tool Integration"
        WP["Webpack"]:::buildtool
        RP["Rollup"]:::buildtool
        VT["Vite"]:::buildtool
        NJ["Next.js"]:::buildtool
        GT["Gatsby"]:::buildtool
    end

    subgraph "Compiler Core"
        PC["Process CSS"]:::core
        PR["Process References"]:::core
        PU["Plugin Utils"]:::core
        SU["Style Utils"]:::utils
        AU["AST Utils"]:::utils
    end

    subgraph "Processing Layer"
        TP["Transpilers"]:::process
        HF["Helper Functions"]:::process
        SP["Style Processing"]:::process
        AP["AST Processing"]:::process
    end

    subgraph "Core Utilities"
        CN["Constants"]:::utils
        HP["Helpers"]:::utils
        IC["Incremental Classnames"]:::utils
    end

    subgraph "Type System"
        MT["Main Types"]:::types
        ST["Style Types"]:::types
        TS43["TypeScript 4.3 Support"]:::types
    end

    subgraph "Output"
        CSS["CSS Files"]:::output
        OJS["Optimized JavaScript"]:::output
        TD["Type Definitions"]:::output
    end

    IF --> TP
    TS --> TP
    JS --> TP

    TP --> PC
    PC --> PR
    PR --> PU

    PC --> SU
    PR --> AU

    WP --> PC
    RP --> PC
    VT --> PC
    NJ --> PC
    GT --> PC

    HF --> SP
    HF --> AP

    SP --> CSS
    AP --> OJS

    CN --> PC
    HP --> PC
    IC --> PC

    MT --> TD
    ST --> TD
    TS43 --> TD

    classDef core fill:#90EE90
    classDef buildtool fill:#87CEEB
    classDef process fill:#FFB6C1
    classDef utils fill:#FFA500
    classDef types fill:#DDA0DD
    classDef output fill:#F0E68C

    click PC "https://github.com/johanholmerin/style9/blob/master/src/process-css.js"
    click PR "https://github.com/johanholmerin/style9/blob/master/src/process-references.js"
    click PU "https://github.com/johanholmerin/style9/blob/master/src/plugin-utils.js"
    click SU "https://github.com/johanholmerin/style9/blob/master/src/utils/styles.js"
    click AU "https://github.com/johanholmerin/style9/blob/master/src/utils/ast.js"
    click TP "https://github.com/johanholmerin/style9/tree/master/src/transpilers"
    click HF "https://github.com/johanholmerin/style9/tree/master/src/helpers"
    click SP "https://github.com/johanholmerin/style9/blob/master/src/helpers/generate-styles.js"
    click AP "https://github.com/johanholmerin/style9/blob/master/src/helpers/mutate-ast.js"
    click WP "https://github.com/johanholmerin/style9/blob/master/webpack/index.js"
    click RP "https://github.com/johanholmerin/style9/blob/master/rollup.js"
    click VT "https://github.com/johanholmerin/style9/blob/master/vite.js"
    click NJ "https://github.com/johanholmerin/style9/blob/master/next.js"
    click GT "https://github.com/johanholmerin/style9/blob/master/gatsby/gatsby-node.js"
    click CN "https://github.com/johanholmerin/style9/blob/master/src/utils/constants.js"
    click HP "https://github.com/johanholmerin/style9/blob/master/src/utils/helpers.js"
    click IC "https://github.com/johanholmerin/style9/blob/master/src/utils/incremental-classnames.js"
    click MT "https://github.com/johanholmerin/style9/blob/master/types/index.d.ts"
    click ST "https://github.com/johanholmerin/style9/blob/master/types/Style.d.ts"
    click TS43 "https://github.com/johanholmerin/style9/blob/master/types/ts4.3/index.d.ts"
```
