# github-suriya/vanilla-toast-js architecture

> Architecture diagram of the GitHub repository github-suriya/vanilla-toast-js, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/github-suriya/vanilla-toast-js
- Repository: https://github.com/github-suriya/vanilla-toast-js

## Overview

Vanilla Toast is a framework-independent browser notification library. Its main workflow is an application calling the exported toast API, which delegates to the toaster to create and manage positioned DOM notifications; queue state, animation, theme, and gesture helpers support that runtime. Promise-based notifications, custom toasts, updates, dismissal, accessibility, and configuration are documented capabilities. Edges reflect the shown imports and calls; capabilities documented in the README but not individually visible in excerpts are represented at the API level.

Main entry points: [`src/toaster.ts`](https://github.com/github-suriya/vanilla-toast-js/blob/main/src/toaster.ts) (Toaster Engine), [`src/index.ts`](https://github.com/github-suriya/vanilla-toast-js/blob/main/src/index.ts) (Package Entry), [`src/utils.ts`](https://github.com/github-suriya/vanilla-toast-js/blob/main/src/utils.ts) (DOM Utilities), [`src/toast.ts`](https://github.com/github-suriya/vanilla-toast-js/blob/main/src/toast.ts) (Toast API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Public API"]
  node_entry["Package Entry<br/>[index.ts]"]
  node_api_impl["Toast API<br/>[toast.ts]"]
  node_types["API Types<br/>[types.ts]"]
end

subgraph group_runtime["Toast Runtime"]
  node_engine["Toaster Engine<br/>[toaster.ts]"]
  node_styles["Toast Styles<br/>[vanilla-toast.css]"]
end

subgraph group_helpers["Runtime Helpers"]
  node_queue["Toast Queue<br/>[queue.ts]"]
  node_animation["Stack Animation<br/>[animations.ts]"]
  node_gestures["Swipe Gestures<br/>[gestures.ts]"]
  node_theme["Theme Resolution<br/>[theme.ts]"]
  node_utils["DOM Utilities<br/>[utils.ts]"]
end

node_app(("Application"))

node_app -->|"imports or loads"| node_entry
node_entry -->|"exports and exposes"| node_api_impl
node_entry -->|"imports"| node_styles
node_api_impl -->|"delegates API calls"| node_engine
node_engine -->|"manages toast state"| node_queue
node_engine -->|"mounts and lays out"| node_animation
node_engine -->|"binds swipe"| node_gestures
node_engine -->|"applies theme"| node_theme
node_engine -->|"uses DOM helpers"| node_utils
node_animation -->|"uses position helpers"| node_utils
node_gestures -->|"clamps movement"| node_utils

click node_entry "https://github.com/github-suriya/vanilla-toast-js/blob/main/src/index.ts"
click node_api_impl "https://github.com/github-suriya/vanilla-toast-js/blob/main/src/toast.ts"
click node_engine "https://github.com/github-suriya/vanilla-toast-js/blob/main/src/toaster.ts"
click node_queue "https://github.com/github-suriya/vanilla-toast-js/blob/main/src/queue.ts"
click node_animation "https://github.com/github-suriya/vanilla-toast-js/blob/main/src/animations.ts"
click node_gestures "https://github.com/github-suriya/vanilla-toast-js/blob/main/src/gestures.ts"
click node_theme "https://github.com/github-suriya/vanilla-toast-js/blob/main/src/theme.ts"
click node_utils "https://github.com/github-suriya/vanilla-toast-js/blob/main/src/utils.ts"
click node_types "https://github.com/github-suriya/vanilla-toast-js/blob/main/src/types.ts"
click node_styles "https://github.com/github-suriya/vanilla-toast-js/blob/main/src/styles/vanilla-toast.css"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_api_impl,node_types toneBlue
class node_engine,node_styles toneAmber
class node_queue,node_animation,node_gestures,node_theme,node_utils toneMint
class node_app toneIndigo
```

## Components

### Public API

- [Package Entry](https://github.com/github-suriya/vanilla-toast-js/blob/main/src/index.ts): `src/index.ts`
- [Toast API](https://github.com/github-suriya/vanilla-toast-js/blob/main/src/toast.ts): `src/toast.ts`
- [API Types](https://github.com/github-suriya/vanilla-toast-js/blob/main/src/types.ts): `src/types.ts`

### Toast Runtime

- [Toaster Engine](https://github.com/github-suriya/vanilla-toast-js/blob/main/src/toaster.ts): `src/toaster.ts`
- [Toast Styles](https://github.com/github-suriya/vanilla-toast-js/blob/main/src/styles/vanilla-toast.css): `src/styles/vanilla-toast.css`

### Runtime Helpers

- [Toast Queue](https://github.com/github-suriya/vanilla-toast-js/blob/main/src/queue.ts): `src/queue.ts`
- [Stack Animation](https://github.com/github-suriya/vanilla-toast-js/blob/main/src/animations.ts): `src/animations.ts`
- [Swipe Gestures](https://github.com/github-suriya/vanilla-toast-js/blob/main/src/gestures.ts): `src/gestures.ts`
- [Theme Resolution](https://github.com/github-suriya/vanilla-toast-js/blob/main/src/theme.ts): `src/theme.ts`
- [DOM Utilities](https://github.com/github-suriya/vanilla-toast-js/blob/main/src/utils.ts): `src/utils.ts`

### Other components

- **Application**

## Connections

- Application → Package Entry: imports or loads (evidence: `README.md`)
- Package Entry → Toast API: exports and exposes (evidence: `src/index.ts`)
- Package Entry → Toast Styles: imports (evidence: `src/index.ts`)
- Toast API → Toaster Engine: delegates API calls (evidence: `src/toast.ts`)
- Toaster Engine → Toast Queue: manages toast state (evidence: `src/toaster.ts`)
- Toaster Engine → Stack Animation: mounts and lays out (evidence: `src/toaster.ts`)
- Toaster Engine → Swipe Gestures: binds swipe (evidence: `src/toaster.ts`)
- Toaster Engine → Theme Resolution: applies theme (evidence: `src/toaster.ts`)
- Toaster Engine → DOM Utilities: uses DOM helpers (evidence: `src/toaster.ts`)
- Stack Animation → DOM Utilities: uses position helpers (evidence: `src/animations.ts`)
- Swipe Gestures → DOM Utilities: clamps movement (evidence: `src/gestures.ts`)
