# add2cal/add-to-calendar-button architecture

> Architecture diagram of the GitHub repository add2cal/add-to-calendar-button, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/add2cal/add-to-calendar-button
- Repository: https://github.com/add2cal/add-to-calendar-button

## Overview

1. This repository is a browser-first JavaScript library that ships a custom element, `add-to-calendar-button`, plus a full documentation/demo site. The main product lives in `src/`; the Nuxt-based marketing/docs app lives in `demo/`; CSS themes and static assets are shared from `assets/`.

2. The core runtime is structured as a pipeline around the button component lifecycle:
   - `atcb-init.js` and `atcb-globals.js` handle bootstrapping and shared state.
   - `atcb-validate.js` checks the incoming attributes/configuration.
   - `atcb-generate.js`, `atcb-generate-rich-data.js`, and `atcb-generate-pro.js` produce the calendar outputs and metadata.
   - `atcb-event.js`, `atcb-control.js`, `atcb-decorate.js`, and `atcb-links.js` handle interaction, UI behavior, decoration, and outbound calendar targets.
   - `atcb-util.js`, `atcb-i18n.js`, and `atcb-validate.js` provide shared helpers, localization, and guardrails.

3. The primary data flow is attribute-driven: consumers place `<add-to-calendar-button ... />` in HTML, the component reads those attributes, validates them, normalizes dates/time zones, and then generates either calendar links, iCal/ICS outputs, or rich structured data. The README makes clear that the component is designed to work without any backend service.

4. Calendar generation is the core domain boundary. Supported targets include Google, Apple, Yahoo, Microsoft 365/Outlook/Teams, and generic iCal. The codebase also has explicit support for recurring events, dynamic dates, all-day/timed events, and time zone/DST handling, which is why `timezone` and recurrence-specific playground/test files exist.

5. UI behavior is separated from event generation. The component supports multiple presentation modes and themes, with CSS variants in `assets/css/` such as flat, round, 3D, neumorphism, text, date, and simple styles. That indicates a theming layer distinct from the event logic.

6. Localization is a first-class subsystem. `src/atcb-i18n.js` plus the demo’s `demo/i18n/` folder and locale JSON files show that labels, controls, and guidance are translated, including support for multiple languages and RTL scenarios mentioned in the README.

7. SEO and content metadata are treated as part of the product. `atcb-generate-rich-data.js` generates schema.org structured data so calendar buttons can also contribute rich snippets. This is an important boundary because it ties UI configuration to search/indexing behavior.

8. There is a clear PRO/free split. `atcb-generate-pro.js`, `no-pro/`, `no-pro-unstyle/`, and `index.d.ts`/variant type files suggest the package can ship different builds or entry points depending on licensing/features. The README also describes extra PRO capabilities such as hosted ICS generation, RSVPs, and advanced distribution options.

9. Packaging and release are handled as a library artifact, not just an app. `package.json`, `src/package.json`, `Gruntfile.js`, `grunt-wrapper/`, and the GitHub Actions workflows point to a build/publish pipeline that produces npm-ready bundles and a docs site. The presence of `npm-publish.yml` and `gh-pages.yml` shows separate deployment paths for package releases and the public site.

10. The `demo/` directory is a complete Nuxt application used as the live documentation, playground, and integration guide site. It contains pages for framework-specific usage, configuration, examples, legal/privacy pages, and UI components such as the playground controls, language switcher, theme switch, and code blocks. That app is the user-facing reference implementation for how the component should be consumed.

11. The demo app also demonstrates the integration boundary with host frameworks. Page files like `use-with-react.vue`, `use-with-vue.vue`, `use-with-nextjs.vue`, `use-with-angular.vue`, etc. indicate that the library is meant to be framework-agnostic and is showcased through framework-specific guidance rather than framework-specific implementations.

12. Testing is split between server-side initialization and browser/web-component behavior. `test/server-side-init.test.js` covers SSR/init behavior, while `test/wc-tests/` includes load and recurrence/time-zone tests, implying that correct behavior depends on both server-rendered and client-side execution paths.

13. Overall architecture: one reusable client-side component library at the center, surrounded by theme assets, localization, rich-data generation, and packaging variants; a separate Nuxt docs/demo site consuming the library; and CI/CD flows for testing, linting, docs publishing, and npm release.

Main entry points: [`src/atcb-generate.js`](https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-generate.js) (Generate), [`src/atcb-init.js`](https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-init.js) (Init), [`.github/workflows/tests.yml`](https://github.com/add2cal/add-to-calendar-button/blob/main/.github/workflows/tests.yml) (CI/CD), [`src/atcb-validate.js`](https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-validate.js) (Validate)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Core library"]
  node_src_init["Init<br/>bootstrap<br/>[atcb-init.js]"]
  node_src_globals["Globals<br/>state<br/>[atcb-globals.js]"]
  node_src_validate["Validate<br/>guardrails<br/>[atcb-validate.js]"]
  node_src_generate["Generate<br/>calendar core<br/>[atcb-generate.js]"]
  node_src_richdata["Rich data<br/>seo/meta"]
  node_src_pro["Pro features<br/>licensed output"]
  node_src_event["Events<br/>interaction<br/>[atcb-event.js]"]
  node_src_control["Control UI<br/>ui behavior<br/>[atcb-control.js]"]
  node_src_decorate["Decorate<br/>theming<br/>[atcb-decorate.js]"]
  node_src_links["Links<br/>targets<br/>[atcb-links.js]"]
  node_src_util["Utils<br/>shared helpers<br/>[atcb-util.js]"]
  node_src_i18n["I18n<br/>localization<br/>[atcb-i18n.js]"]
end

subgraph group_demo["Demo site"]
  node_demo_app["Nuxt app<br/>docs site<br/>[app.vue]"]
  node_demo_pages["Pages<br/>content routes<br/>[index.vue]"]
  node_demo_components["UI components<br/>site UI<br/>[header.vue]"]
  node_demo_i18n["Site i18n<br/>localization<br/>[i18n.config.ts]"]
end

subgraph group_delivery["Build & release"]
  node_build_pkg["Package<br/>npm artifact<br/>[package.json]"]
  node_build_grunt["Grunt build<br/>build tooling<br/>[Gruntfile.js]"]
  node_build_ci["CI/CD<br/>automation<br/>[tests.yml]"]
end

subgraph group_qa["Testing"]
  node_qa_ssr["SSR init test"]
  node_qa_wc["WC tests<br/>[wc-load.test.js]"]
end

subgraph group_assets["Themes & shared assets"]
  node_assets_css["Themes<br/>styles<br/>[atcb.css]"]
end

node_src_init -->|"bootstraps"| node_src_globals
node_src_init -->|"reads attrs"| node_src_validate
node_src_validate -->|"uses"| node_src_util
node_src_validate -->|"labels"| node_src_i18n
node_src_validate -->|"feeds"| node_src_generate
node_src_generate -->|"builds targets"| node_src_links
node_src_generate -->|"adds meta"| node_src_richdata
node_src_generate -->|"extends"| node_src_pro
node_src_generate -->|"updates ui"| node_src_control
node_src_event -->|"drives"| node_src_control
node_src_control -->|"styles"| node_src_decorate
node_src_decorate -->|"uses themes"| node_assets_css
node_src_event -->|"opens"| node_src_links
node_src_i18n -.->|"supports rtl"| node_assets_css
node_demo_app -->|"routes"| node_demo_pages
node_demo_app -->|"composes"| node_demo_components
node_demo_app -->|"loads"| node_demo_i18n
node_demo_pages -->|"demonstrates"| node_src_init
node_demo_components -->|"embeds"| node_src_init
node_demo_i18n -.->|"mirrors"| node_src_i18n
node_build_pkg -->|"scripts"| node_build_grunt
node_build_grunt -->|"bundles"| node_src_init
node_build_grunt -->|"ships"| node_assets_css
node_build_ci -->|"runs"| node_qa_ssr
node_build_ci -->|"runs"| node_qa_wc
node_build_ci -->|"deploys"| node_demo_app
node_build_ci -->|"releases"| node_build_pkg
node_qa_ssr -->|"verifies"| node_src_init
node_qa_wc -->|"verifies"| node_src_generate

click node_src_init "https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-init.js"
click node_src_globals "https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-globals.js"
click node_src_validate "https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-validate.js"
click node_src_generate "https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-generate.js"
click node_src_richdata "https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-generate-rich-data.js"
click node_src_pro "https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-generate-pro.js"
click node_src_event "https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-event.js"
click node_src_control "https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-control.js"
click node_src_decorate "https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-decorate.js"
click node_src_links "https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-links.js"
click node_src_util "https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-util.js"
click node_src_i18n "https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-i18n.js"
click node_demo_app "https://github.com/add2cal/add-to-calendar-button/blob/main/demo/app.vue"
click node_demo_pages "https://github.com/add2cal/add-to-calendar-button/blob/main/demo/pages/index.vue"
click node_demo_components "https://github.com/add2cal/add-to-calendar-button/blob/main/demo/components/header.vue"
click node_demo_i18n "https://github.com/add2cal/add-to-calendar-button/blob/main/demo/i18n/i18n.config.ts"
click node_assets_css "https://github.com/add2cal/add-to-calendar-button/blob/main/assets/css/atcb.css"
click node_build_pkg "https://github.com/add2cal/add-to-calendar-button/blob/main/package.json"
click node_build_grunt "https://github.com/add2cal/add-to-calendar-button/blob/main/Gruntfile.js"
click node_build_ci "https://github.com/add2cal/add-to-calendar-button/blob/main/.github/workflows/tests.yml"
click node_qa_ssr "https://github.com/add2cal/add-to-calendar-button/blob/main/test/server-side-init.test.js"
click node_qa_wc "https://github.com/add2cal/add-to-calendar-button/blob/main/test/wc-tests/wc-load.test.js"

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_src_init,node_src_globals,node_src_validate,node_src_generate,node_src_richdata,node_src_pro,node_src_event,node_src_control,node_src_decorate,node_src_links,node_src_util,node_src_i18n toneBlue
class node_demo_app,node_demo_pages,node_demo_components,node_demo_i18n toneAmber
class node_build_pkg,node_build_grunt,node_build_ci toneMint
class node_qa_ssr,node_qa_wc toneRose
class node_assets_css toneIndigo
```

## Components

### Core library

Browser-first custom element runtime and calendar generation pipeline.

- [Init](https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-init.js): bootstrap · Entry and lifecycle bootstrapping for the custom element. · `src/atcb-init.js`
- [Globals](https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-globals.js): state · Shared runtime state and cross-module configuration. · `src/atcb-globals.js`
- [Validate](https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-validate.js): guardrails · Attribute and configuration validation. · `src/atcb-validate.js`
- [Generate](https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-generate.js): calendar core · Primary calendar-link and output generation pipeline. · `src/atcb-generate.js`
- [Rich data](https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-generate-rich-data.js): seo/meta · schema.org structured data generation for search/indexing. · `src/atcb-generate-rich-data.js`
- [Pro features](https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-generate-pro.js): licensed output · PRO-only generation and distribution capabilities. · `src/atcb-generate-pro.js`
- [Events](https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-event.js): interaction · User interaction and event handling for the button. · `src/atcb-event.js`
- [Control UI](https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-control.js): ui behavior · Presentation state, controls, and component behavior. · `src/atcb-control.js`
- [Decorate](https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-decorate.js): theming · Visual decoration and mode-specific rendering tweaks. · `src/atcb-decorate.js`
- [Links](https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-links.js): targets · Outbound calendar target handling for vendors and formats. · `src/atcb-links.js`
- [Utils](https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-util.js): shared helpers · General-purpose helpers used across the runtime. · `src/atcb-util.js`
- [I18n](https://github.com/add2cal/add-to-calendar-button/blob/main/src/atcb-i18n.js): localization · Runtime translations and locale-aware labels. · `src/atcb-i18n.js`

### Demo site

Nuxt-based docs, playground, and integration guides.

- [Nuxt app](https://github.com/add2cal/add-to-calendar-button/blob/main/demo/app.vue): docs site · Complete documentation, playground, and marketing application. · `demo/app.vue`
- [Pages](https://github.com/add2cal/add-to-calendar-button/blob/main/demo/pages/index.vue): content routes · Docs, examples, integration guides, and legal pages. · `demo/pages/index.vue`
- [UI components](https://github.com/add2cal/add-to-calendar-button/blob/main/demo/components/header.vue): site UI · Reusable site components for navigation, controls, and playground. · `demo/components/header.vue`
- [Site i18n](https://github.com/add2cal/add-to-calendar-button/blob/main/demo/i18n/i18n.config.ts): localization · Demo-site locale config and translated strings. · `demo/i18n/i18n.config.ts`

### Build & release

Packaging, wrappers, and CI/CD workflows for publishing.

- [Package](https://github.com/add2cal/add-to-calendar-button/blob/main/package.json): npm artifact · Root package definition and library publishing metadata. · `package.json`
- [Grunt build](https://github.com/add2cal/add-to-calendar-button/blob/main/Gruntfile.js): build tooling · Library build orchestration and wrapper generation. · `Gruntfile.js`
- [CI/CD](https://github.com/add2cal/add-to-calendar-button/blob/main/.github/workflows/tests.yml): automation · Workflow automation for tests, docs deployment, and npm release. · `.github/workflows/tests.yml`

### Testing

Server-side and web-component test coverage.

- [SSR init test](https://github.com/add2cal/add-to-calendar-button/blob/main/test/server-side-init.test.js): test · Server-side initialization behavior coverage. · `test/server-side-init.test.js`
- [WC tests](https://github.com/add2cal/add-to-calendar-button/blob/main/test/wc-tests/wc-load.test.js): test · Web-component load, recurrence, and timezone behavior coverage. · `test/wc-tests/wc-load.test.js`

### Themes & shared assets

Shared styles and static assets used by the component and site.

- [Themes](https://github.com/add2cal/add-to-calendar-button/blob/main/assets/css/atcb.css): styles · Shared CSS themes and presentation variants. · `assets/css/atcb.css`

## Connections

- Init → Globals: bootstraps · Initializes shared runtime state.
- Init → Validate: reads attrs · Starts from attribute-driven configuration.
- Validate → Utils: uses · Validation relies on helper routines.
- Validate → I18n: labels · Validation and UI messaging use locale text.
- Validate → Generate: feeds · Validated config flows into generation.
- Generate → Links: builds targets · Produces calendar-specific outbound links and formats.
- Generate → Rich data: adds meta · Generates structured data alongside calendar outputs.
- Generate → Pro features: extends · PRO path adds licensed output variants.
- Generate → Control UI: updates ui · Generation results affect component controls and state.
- Events → Control UI: drives · User interaction changes visible behavior.
- Control UI → Decorate: styles · Control state determines presentation variants.
- Decorate → Themes: uses themes · Theme variants are sourced from shared CSS assets.
- Events → Links: opens · Interactions route users to calendar targets.
- I18n → Themes: supports rtl · Localization pairs with theme and layout handling.
- Nuxt app → Pages: routes · The Nuxt shell serves documentation pages.
- Nuxt app → UI components: composes · Site UI is assembled from shared components.
- Nuxt app → Site i18n: loads · The site uses its own locale layer.
- Pages → Init: demonstrates · Docs pages showcase the custom element API.
- UI components → Init: embeds · Playground and examples mount the component.
- Site i18n → I18n: mirrors · Site translations mirror component language support.
- Package → Grunt build: scripts · Package scripts orchestrate build steps.
- Grunt build → Init: bundles · Build pipeline packages the runtime modules.
- Grunt build → Themes: ships · Build includes distributable theme styles.
- CI/CD → SSR init test: runs · CI executes server-side checks.
- CI/CD → WC tests: runs · CI executes web-component checks.
- CI/CD → Nuxt app: deploys · Separate workflow publishes the docs site.
- CI/CD → Package: releases · Package publishing is handled in CI.
- SSR init test → Init: verifies · Tests SSR-safe initialization.
- WC tests → Generate: verifies · Tests cover generation behavior in the browser.
