# sujithjr/exstasy-components architecture

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

- Interactive diagram: https://gitdiagram.com/sujithjr/exstasy-components
- Repository: https://github.com/sujithjr/exstasy-components

## Overview

Based on our analysis of the file tree and README, this project is a library of headless UI components for Vue 3 (written in TypeScript), inspired by Tailwind’s Headless UI. It is designed for developers to import individual components or register them globally in a Vue application. The architecture emphasizes modular, composable components, helper composables (for managing state, events, etc.), and utility functions that support the components' operation in a flexible, tree-shakeable way.

##### Main Components
- UI Components: The project is structured around many Vue components such as ExAutocomplete, ExAvatar, ExCard, ExDialog, ExDrawer, ExDropdown, ExPortal, and ExTooltip. Each of these has its own folder with key files (component definitions, types, composables, etc.).
- Composables & Hooks: The “src/composables” and “src/hooks” directories contain shared logic (e.g., useOutsideClick, useDocumentEvent) which support the UI components. They exemplify the use of Vue’s Composition API and are core to ensuring the components are headless and flexible.
- Utilities: In “src/utils”, helper functions (e.g., convertUnit, dom utilities) form the backbone for shared functionality that the components and composables rely upon.
- Playground/Demo: The “src/playground” directory hosts example Vue views (like AutocompleteExample.vue, DropdownExample.vue, TooltipExample.vue) that demonstrate the usage of the components in a live development setup.
- Configuration & Build: Files like vite.config.ts, package.json, tailwind.config.js, and bun configuration files lay out the build system and dependency management.

##### Relationships and Interactions
- UI components import and make use of their own composables and types (e.g., ExDialog uses useExDialogContext from its composables subdirectory), showing an encapsulated pattern.
- Many components and their composables share common utility functions from “src/utils.”
- The top-level “src/index.ts” (and main.ts) likely act as entry points that register and export all components, tying together the modular pieces of the library.
- The playground examples demonstrate how the components interact with Vue and how to use them within an actual application setup.

##### Key Architectural Patterns and Design Principles
- Modular Design and Tree Shaking: Each component is isolated in its own directory, enabling selective imports.
- Composability: Extensive use of composables (inside both individual component folders and globally in “src/composables”) enables reusability and separation of concerns.
- Headless UI Approach: The components are designed without enforced styling – they provide behavior and structure which can then be styled by the end user.
- Clear Separation of Core Functionality: The separation of UI components, composables, hooks, and utilities makes the system maintainable and extensible.

##### Elements
- A “Composables & Hooks” block including “src/composables” and “src/hooks” that are shared across components.
- A “Utilities” block for “src/utils”.
- A “Playground/Demo” section representing the demo application and example usage.
- A “Configuration & Build” block representing build scripts, Vite configuration, package managers (npm and Bun.js), and other tooling (ESLint, Tailwind, PostCSS).
- Logic helpers (composables and hooks, maybe rounded rectangles or circles),
- Utility libraries,
- and configuration/build tools (could be drawn with a distinct border style).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Dependencies
    Vue3["Vue 3"]:::external
    TailwindExt["Tailwind (styling)"]:::external

    %% UI Components
    subgraph "UI Components"
        ExAutocomplete["ExAutocomplete"]:::components
        ExAvatar["ExAvatar"]:::components
        ExCard["ExCard"]:::components
        ExDialog["ExDialog"]:::components
        ExDrawer["ExDrawer"]:::components
        ExDropdown["ExDropdown"]:::components
        ExPortal["ExPortal"]:::components
        ExTooltip["ExTooltip"]:::components
    end

    %% Composables & Hooks
    subgraph "Composables & Hooks"
        GlobalComposables["Global Composables"]:::composables
        GlobalHooks["Global Hooks"]:::composables
    end

    %% Utilities
    subgraph "Utilities"
        Utilities["Utilities"]:::utilities
    end

    %% Playground/Demo
    subgraph "Playground/Demo"
        Playground["Playground"]:::playground
    end

    %% Configuration & Build
    subgraph "Configuration & Build"
        ViteConfig["Vite Configuration"]:::config
        BuildScripts["Package Manager & Build Scripts"]:::config
        TailwindPostCSS["Tailwind & PostCSS"]:::config
    end

    %% Relationships
    %% External Dependencies linking to core parts
    Vue3 -->|"supports"| ExAutocomplete
    Vue3 -->|"supports"| GlobalComposables
    Vue3 -->|"supports"| GlobalHooks

    %% UI Components dependencies
    ExAutocomplete -->|"imports"| GlobalComposables
    ExAvatar -->|"imports"| GlobalHooks
    ExCard -->|"uses"| Utilities
    ExDialog -->|"imports"| GlobalComposables
    ExDialog -->|"uses"| Utilities
    ExDrawer -->|"imports"| GlobalComposables
    ExDropdown -->|"uses"| Utilities
    ExPortal -->|"imports"| GlobalHooks
    ExTooltip -->|"uses"| Utilities

    %% Composables using shared utilities
    GlobalComposables -->|"calls"| Utilities
    GlobalHooks -->|"calls"| Utilities

    %% Playground demonstrating usage
    Playground -->|"demonstratesUsage"| ExDropdown
    Playground -->|"demonstratesUsage"| GlobalComposables
    Playground -->|"demonstratesUsage"| GlobalHooks

    %% External Tailwind configuration link
    TailwindExt -->|"configures"| TailwindPostCSS

    %% Styles
    classDef components fill:#D6EAF8,stroke:#1B4F72,stroke-width:2px;
    classDef composables fill:#D5F5E3,stroke:#196F3D,stroke-width:2px;
    classDef utilities fill:#FCF3CF,stroke:#B7950B,stroke-width:2px;
    classDef playground fill:#EBDEF0,stroke:#7D3C98,stroke-width:2px;
    classDef config fill:#FADBD8,stroke:#C0392B,stroke-width:2px;
    classDef external fill:#E8F6F3,stroke:#117864,stroke-width:2px;

    %% Click Events for UI Components
    click ExAutocomplete "https://github.com/sujithjr/exstasy-components/tree/main/src/components/ExAutocomplete"
    click ExAvatar "https://github.com/sujithjr/exstasy-components/tree/main/src/components/ExAvatar"
    click ExCard "https://github.com/sujithjr/exstasy-components/tree/main/src/components/ExCard"
    click ExDialog "https://github.com/sujithjr/exstasy-components/tree/main/src/components/ExDialog"
    click ExDrawer "https://github.com/sujithjr/exstasy-components/tree/main/src/components/ExDrawer"
    click ExDropdown "https://github.com/sujithjr/exstasy-components/tree/main/src/components/ExDropdown"
    click ExPortal "https://github.com/sujithjr/exstasy-components/tree/main/src/components/ExPortal"
    click ExTooltip "https://github.com/sujithjr/exstasy-components/tree/main/src/components/ExTooltip"

    %% Click Events for Composables & Hooks
    click GlobalComposables "https://github.com/sujithjr/exstasy-components/tree/main/src/composables"
    click GlobalHooks "https://github.com/sujithjr/exstasy-components/tree/main/src/hooks"

    %% Click Event for Utilities
    click Utilities "https://github.com/sujithjr/exstasy-components/tree/main/src/utils"

    %% Click Event for Playground/Demo
    click Playground "https://github.com/sujithjr/exstasy-components/tree/main/src/playground"

    %% Click Events for Configuration & Build
    click ViteConfig "https://github.com/sujithjr/exstasy-components/blob/main/vite.config.ts"
    click BuildScripts "https://github.com/sujithjr/exstasy-components/blob/main/package.json"
    click TailwindPostCSS "https://github.com/sujithjr/exstasy-components/blob/main/tailwind.config.js"
```
