# maronato/vue-toastification architecture

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

- Interactive diagram: https://gitdiagram.com/maronato/vue-toastification
- Repository: https://github.com/maronato/vue-toastification

## Overview

##### Main System Components
- Vue Application Integration – Show that this plugin is designed to be registered into a Vue app via app.use(Toast, options) and can be used universally in the application.
- Plugin Core – Represent the main “Toast Plugin” module, which is responsible for handling the toast logic (registration, configuration, creation, update, and dismissal). This part includes:
- The plugin registration file (src/ts/plugin.ts) that wires up the plugin.
- A core module that handles default options, accessibility settings, and advanced configuration.
- Event Bus – The system uses an event bus (see src/ts/eventBus.ts) as the central messaging mechanism. This bus is used by the toast interfaces to dispatch events to the plugin instance.
- Toast Interface Composables – Illustrate the “useToast” composable (and other composables such as useDraggable, useFocusable, useHoverable) that provide application components with a simple API to create and manage toasts.
- Toast Container (VtToastContainer.vue): the parent container that holds one or multiple toast notifications.
- Toast Notification (VtToast.vue): the core visual representation of an individual toast.
- Sub-components such as VtCloseButton.vue, VtIcon.vue, VtProgressBar.vue, and VtTransition.vue.
- Styling and Animations – Create a module for the SCSS files and animation subdirectory (src/scss and src/scss/animations) that shows how styles, layouts, custom themes, and transitions (bounce, fade, slide, etc.) are defined and applied.

##### Interactions and Data Flow
- Registration and Initialization: Start with the Vue App integrating the plugin via the plugin registration file. Once the plugin is registered, the Event Bus is instantiated and configured.
- API Usage: Then illustrate the flow – a component calls the “useToast” composable, which internally dispatches a request (via the Event Bus) to create a new toast.

##### Architectural Patterns & Design Principles
- Component-Based Architecture: Emphasize that the plugin is split into small Vue components to encourage reusability.
- Separation of Concerns: Show a clear separation between plugin logic (event handling, default configuration, core toast creation) and presentation (UI components and styles).
- Configurability & Extensibility: The design supports numerous custom options via both global (plugin-level) and local (toast-specific) settings.
- Testability: Include an indication of the testing layer (tests/unit directory) which verifies the behavior of components, composables, and utilities.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Vue Integration"
        A["Vue App Integration (app.use(Toast, options))"]:::vueapp
    end

    subgraph "Plugin System"
        B["Plugin Core (Registration & Configuration)"]:::core
        C["Event Bus (Central Messaging)"]:::event
    end

    subgraph "Toast Interface Composables"
        D["useToast Composable"]:::comps
        E["useDraggable Composable"]:::comps
        F["useFocusable Composable"]:::comps
        G["useHoverable Composable"]:::comps
    end

    subgraph "UI Components"
        H["Toast Container (VtToastContainer.vue)"]:::ui
        I["Toast Notification (VtToast.vue)"]:::ui
        subgraph "Sub-components"
            J["Close Button (VtCloseButton.vue)"]:::ui
            K["Icon (VtIcon.vue)"]:::ui
            L["Progress Bar (VtProgressBar.vue)"]:::ui
            M["Transition (VtTransition.vue)"]:::ui
        end
        subgraph "Icon Components"
            N["Error Icon (VtErrorIcon.vue)"]:::ui
            O["Info Icon (VtInfoIcon.vue)"]:::ui
            P["Success Icon (VtSuccessIcon.vue)"]:::ui
            Q["Warning Icon (VtWarningIcon.vue)"]:::ui
        end
    end

    subgraph "Styling & Animations"
        R["SCSS Files"]:::styling
        S["Animations"]:::styling
    end

    T["Testing Suite (tests/unit)"]:::testing

    %% Data Flow Connections
    A -->|"app.use()"| B
    B -->|"initializes"| C
    D -->|"dispatches-events"| C
    E -->|"dispatches-events"| C
    F -->|"dispatches-events"| C
    G -->|"dispatches-events"| C
    C -->|"renders-toasts"| H
    H -->|"contains"| I
    I -->|"includes"| J
    I -->|"includes"| K
    I -->|"includes"| L
    I -->|"includes"| M
    I -->|"uses-icon"| N
    I -->|"uses-icon"| O
    I -->|"uses-icon"| P
    I -->|"uses-icon"| Q
    R -->|"defines"| S

    %% Click Events
    click A "https://github.com/maronato/vue-toastification/blob/next/demo/src/main.ts"
    click B "https://github.com/maronato/vue-toastification/blob/next/src/ts/plugin.ts"
    click C "https://github.com/maronato/vue-toastification/blob/next/src/ts/eventBus.ts"
    click D "https://github.com/maronato/vue-toastification/blob/next/src/ts/composables/useToast.ts"
    click E "https://github.com/maronato/vue-toastification/blob/next/src/ts/composables/useDraggable.ts"
    click F "https://github.com/maronato/vue-toastification/blob/next/src/ts/composables/useFocusable.ts"
    click G "https://github.com/maronato/vue-toastification/blob/next/src/ts/composables/useHoverable.ts"
    click H "https://github.com/maronato/vue-toastification/blob/next/src/components/VtToastContainer.vue"
    click I "https://github.com/maronato/vue-toastification/blob/next/src/components/VtToast.vue"
    click J "https://github.com/maronato/vue-toastification/blob/next/src/components/VtCloseButton.vue"
    click K "https://github.com/maronato/vue-toastification/blob/next/src/components/VtIcon.vue"
    click L "https://github.com/maronato/vue-toastification/blob/next/src/components/VtProgressBar.vue"
    click M "https://github.com/maronato/vue-toastification/blob/next/src/components/VtTransition.vue"
    click N "https://github.com/maronato/vue-toastification/blob/next/src/components/icons/VtErrorIcon.vue"
    click O "https://github.com/maronato/vue-toastification/blob/next/src/components/icons/VtInfoIcon.vue"
    click P "https://github.com/maronato/vue-toastification/blob/next/src/components/icons/VtSuccessIcon.vue"
    click Q "https://github.com/maronato/vue-toastification/blob/next/src/components/icons/VtWarningIcon.vue"
    click R "https://github.com/maronato/vue-toastification/tree/next/src/scss"
    click S "https://github.com/maronato/vue-toastification/tree/next/src/scss/animations"
    click T "https://github.com/maronato/vue-toastification/tree/next/tests/unit"

    %% Style Definitions
    classDef vueapp fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef core fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
    classDef event fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef comps fill:#D4EFDF,stroke:#1E8449,stroke-width:2px;
    classDef ui fill:#F9E79F,stroke:#B7950B,stroke-width:2px,rx:5,ry:5;
    classDef styling fill:#F5CBA7,stroke:#AF601A,stroke-width:2px;
    classDef testing fill:#FADBD8,stroke:#C0392B,stroke-width:2px;
```
