# rborges89/react-slots-tools architecture

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

- Interactive diagram: https://gitdiagram.com/rborges89/react-slots-tools
- Repository: https://github.com/rborges89/react-slots-tools

## Overview

##### Project type and purpose
- This is an open-source React utility library (npm package) named `@burning89/react-slots-tools`.
- Its purpose is to provide a hook (`useSlots`) and components (`TemplateSlot`) that let React authors define and consume named “slots” in a type-safe, composable way—similar to slot patterns in Vue or Web Components.

##### File structure
- Top‐level build & config files:
- `tsup.config.ts` – defines bundling (CJS + ESM + .d.ts)
- `tsconfig.json` – TypeScript compiler options
- `vitest.config.ts` – test runner config
- `package.json` / `package-lock.json` – dependencies, scripts (`dev`, `build`, `test`)
- Source directory (`src/`):
- `useSlots.tsx` – core hook implementation
- `TemplateSlot.tsx` – component for slots with parameters
- `types.ts` – type definitions (`SlotWithParameters`, `NamedSlotsMap`, `UseSlotsResult`)
- `index.ts` – public API exports
- `useSlots.test.tsx` – unit tests against the hook
- Distribution directory (`dist/`):
- Bundled outputs in multiple module formats (`.mjs`, `.cjs`) and type declarations

##### README for additional insights
- Core API: `useSlots<T>(children)` returns `{ slots, get, has, list }`.
- Slot usage patterns: default vs named slots vs parameterized slots.
- Example consumer code shows how a React app imports and uses the library.
- Build & test commands reinforce that this is a pure-frontend library with no backend or external services.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Source Modules
    subgraph "Source Modules"
        US["useSlots.tsx"]:::source
        TS["TemplateSlot.tsx"]:::source
        TY["types.ts"]:::source
        IDX["index.ts"]:::source
    end

    %% Configuration & Tooling
    subgraph "Configuration & Tooling"
        TSC["tsconfig.json"]:::config
        TSUP["tsup.config.ts"]:::config
        VITE["vitest.config.ts"]:::config
        PKG["package.json"]:::config
    end

    %% Test Suite
    subgraph "Test Suite"
        TEST["useSlots.test.tsx"]:::test
    end

    %% Build Pipeline
    subgraph "Build Pipeline"
        BLD["Tsup Bundler"]:::build
    end

    %% Distribution Artifacts
    subgraph "Distribution Artifacts"
        CJS["index.cjs"]:::dist
        MJS["index.mjs"]:::dist
        DTS["index.d.ts"]:::dist
        MAP1["index.cjs.map"]:::dist
        MAP2["index.mjs.map"]:::dist
    end

    %% Consumer
    CON["Consumer React App"]:::consumer

    %% Relationships
    US -->|"compiles to"| BLD
    TS -->|"compiles to"| BLD
    TY -->|"compiles to"| BLD
    IDX -->|"compiles to"| BLD

    BLD -->|"outputs"| CJS
    BLD -->|"outputs"| MJS
    BLD -->|"outputs"| DTS
    BLD -->|"outputs"| MAP1
    BLD -->|"outputs"| MAP2

    TEST -->|"runs tests against"| US
    TEST -->|"runs tests against"| TS
    TEST -->|"runs tests against"| TY
    TEST -->|"runs tests against"| IDX

    TSC -->|"configures"| BLD
    TSUP -->|"bundler config"| BLD
    VITE -->|"test config"| TEST
    PKG -->|"scripts & deps"| BLD
    PKG -->|"scripts & deps"| TEST

    CON -.->|"npm import"| CJS
    CON -.->|"npm import"| MJS

    %% Click Events
    click US "https://github.com/rborges89/react-slots-tools/blob/main/src/useSlots.tsx"
    click TS "https://github.com/rborges89/react-slots-tools/blob/main/src/TemplateSlot.tsx"
    click TY "https://github.com/rborges89/react-slots-tools/blob/main/src/types.ts"
    click IDX "https://github.com/rborges89/react-slots-tools/blob/main/src/index.ts"
    click TEST "https://github.com/rborges89/react-slots-tools/blob/main/src/useSlots.test.tsx"
    click TSC "https://github.com/rborges89/react-slots-tools/blob/main/tsconfig.json"
    click TSUP "https://github.com/rborges89/react-slots-tools/blob/main/tsup.config.ts"
    click VITE "https://github.com/rborges89/react-slots-tools/blob/main/vitest.config.ts"
    click PKG "https://github.com/rborges89/react-slots-tools/blob/main/package.json"
    click CJS "https://github.com/rborges89/react-slots-tools/blob/main/dist/index.cjs"
    click MJS "https://github.com/rborges89/react-slots-tools/blob/main/dist/index.mjs"
    click DTS "https://github.com/rborges89/react-slots-tools/blob/main/dist/index.d.ts"
    click MAP1 "https://github.com/rborges89/react-slots-tools/blob/main/dist/index.cjs.map"
    click MAP2 "https://github.com/rborges89/react-slots-tools/blob/main/dist/index.mjs.map"

    %% Styles
    classDef source fill:#D0E7FF,stroke:#0366D6,stroke-width:2px;
    classDef config fill:#FFF4CC,stroke:#D4A017,stroke-width:2px;
    classDef test fill:#DFFFE0,stroke:#28A745,stroke-width:2px;
    classDef build fill:#FFE3D8,stroke:#F66A0A,stroke-width:2px;
    classDef dist fill:#E8D5FF,stroke:#6F42C1,stroke-width:2px;
    classDef consumer fill:#E0E0E0,stroke:#6A737D,stroke-width:2px;
```
