# 42angouleme/dioxus-tw-components architecture

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

- Interactive diagram: https://gitdiagram.com/42angouleme/dioxus-tw-components
- Repository: https://github.com/42angouleme/dioxus-tw-components

## Overview

##### Main Components of the System
- Dioxus Integration & Bootstrap:
- Bootstrap mechanism in src/bootstrap (and its use in the main app as shown in the README).
- How the library must be initialized in a Dioxus application (through DioxusTwComponentsBootstrap).
- Component Hierarchy:
- That there are three layers (Atoms, Molecules, Organisms) organized under src/components.
- Encompass additional component directories like templates, pages, hooks, and theme support.
- Custom Macros:
- Dioxus-tw-components-macro and dioxus-tw-components-sorttable-macro directories that extend or generate component code.
- Styling & CSS Integration:
- External connection with Tailwind’s compiler through specified CSS variables and import instructions.
- Build & Versioning:
- Cargo configuration (Cargo.toml at top-level and within the macros) as an integration point.
- Existence of GitHub workflows for CI (located in .github/workflows) that may interact with build/deploy pipelines.

##### Relationships and Interactions
- The bootstrap component (under src/bootstrap) initializes global settings to let the components work properly.
- The CSS and Tailwind configuration work side-by-side with the components to ensure styling is consistent and customizable.
- Custom macros are used to add compile-time functionality or generate code that extends basic component properties.
- The layout can be depicted in layers: Underlying integration, then core library (components, hooks, theme) and finally, the macros as extensions.

##### Architectural Patterns or Design Principles
- Modularity and Reusability: The code is organized into atoms, molecules, and organisms representing a design system hierarchy (inspired by atomic design).
- Separation of Concerns: Styling (CSS) is separated from component logic (Rust in src/components).
- Extensibility: Custom derive macros allow for extensibility in UI components.
- Declarative UI: Components are designed to be composable in a Dioxus/React-like manner.

##### Including Technologies, Frameworks, and Libraries
- Dioxus: The fundamental rendering and component system.
- TailwindCSS: The styling engine with its configuration and custom variable support.
- Rust & Cargo: For package management and compiling the components library.
- GitHub Actions (workflows): To ensure CI integration and testing.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Integration
    D1["Dioxus Application"]:::external
    D1 -->|"invokes"| B1["DioxusTwComponentsBootstrap"]:::bootstrap
    B1 -->|"initializes"| A["Atoms"]:::components

    %% Component Hierarchy Subgraph
    subgraph "Component Hierarchy"
        direction TB
        A["Atoms"]:::components
        A1["Button"]:::components
        A2["Icon"]:::components
        A -->|"contains"| A1
        A -->|"contains"| A2

        M["Molecules"]:::components
        M1["Accordion"]:::components
        M2["Dropdown"]:::components
        M3["Table"]:::components
        M -->|"contains"| M1
        M -->|"contains"| M2
        M -->|"contains"| M3

        O["Organisms"]:::components
        O1["Form Components"]:::components
        O -->|"contains"| O1

        T["Templates"]:::components
        P["Pages"]:::components
        H["Hooks"]:::components
        TH["Theme"]:::components
    end

    %% Bootstrap initializes all component categories
    B1 -->|"registers"| A
    B1 --> M
    B1 --> O
    B1 --> T
    B1 --> P
    B1 --> H
    B1 --> TH

    %% Styling & CSS Integration
    CSS["CSS/Tailwind"]:::styling
    CSS1["css/input.css"]:::styling
    CSS2["css/tailwind.config.js"]:::styling
    CSS --> CSS1
    CSS --> CSS2
    TH -->|"applies"| CSS

    %% Custom Macros
    CM["Custom Macros"]:::macros
    CM1["dioxus-tw-components-macro"]:::macros
    CM2["dioxus-tw-components-sorttable-macro"]:::macros
    CM --> CM1
    CM --> CM2
    CM -->|"expands"| M

    %% Build & Versioning
    BV["Build & Versioning"]:::build
    Cargo["Cargo.toml"]:::build
    GH["GitHub Workflows"]:::build
    BV --> Cargo
    BV --> GH

    %% Overall Dependency: Build system triggers bootstrap initialization
    BV -->|"triggers build"| B1

    %% Click Events
    click B1 "https://github.com/42angouleme/dioxus-tw-components/blob/main/src/bootstrap/mod.rs"
    click A "https://github.com/42angouleme/dioxus-tw-components/blob/main/src/components/atoms/mod.rs"
    click A1 "https://github.com/42angouleme/dioxus-tw-components/tree/main/src/components/atoms/button"
    click A2 "https://github.com/42angouleme/dioxus-tw-components/tree/main/src/components/atoms/icon"
    click M "https://github.com/42angouleme/dioxus-tw-components/blob/main/src/components/molecules/mod.rs"
    click M1 "https://github.com/42angouleme/dioxus-tw-components/tree/main/src/components/molecules/accordion"
    click M2 "https://github.com/42angouleme/dioxus-tw-components/tree/main/src/components/molecules/dropdown"
    click M3 "https://github.com/42angouleme/dioxus-tw-components/tree/main/src/components/molecules/table"
    click O "https://github.com/42angouleme/dioxus-tw-components/blob/main/src/components/organisms/mod.rs"
    click O1 "https://github.com/42angouleme/dioxus-tw-components/tree/main/src/components/organisms/form"
    click T "https://github.com/42angouleme/dioxus-tw-components/tree/main/src/components/templates"
    click P "https://github.com/42angouleme/dioxus-tw-components/blob/main/src/components/pages/mod.rs"
    click H "https://github.com/42angouleme/dioxus-tw-components/blob/main/src/hooks/mod.rs"
    click TH "https://github.com/42angouleme/dioxus-tw-components/tree/main/src/theme"
    click CM1 "https://github.com/42angouleme/dioxus-tw-components/tree/main/dioxus-tw-components-macro"
    click CM2 "https://github.com/42angouleme/dioxus-tw-components/tree/main/dioxus-tw-components-sorttable-macro"
    click CSS1 "https://github.com/42angouleme/dioxus-tw-components/blob/main/css/input.css"
    click CSS2 "https://github.com/42angouleme/dioxus-tw-components/blob/main/css/tailwind.config.js"
    click Cargo "https://github.com/42angouleme/dioxus-tw-components/blob/main/Cargo.toml"
    click GH "https://github.com/42angouleme/dioxus-tw-components/tree/main/.github/workflows"

    %% Styles
    classDef external fill:#e0f7fa,stroke:#333,stroke-width:2px;
    classDef bootstrap fill:#ffcc80,stroke:#333,stroke-width:2px;
    classDef components fill:#c5e1a5,stroke:#333,stroke-width:2px;
    classDef macros fill:#ce93d8,stroke:#333,stroke-width:2px;
    classDef styling fill:#90caf9,stroke:#333,stroke-width:2px;
    classDef build fill:#ffab91,stroke:#333,stroke-width:2px;
```
