# dayschedule/dayschedule-widget architecture

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

- Interactive diagram: https://gitdiagram.com/dayschedule/dayschedule-widget
- Repository: https://github.com/dayschedule/dayschedule-widget

## Overview

##### Project Type and Purpose
- This is an **open-source embeddable JavaScript/CSS widget** library (published on NPM and CDN).
- It provides two UI modes (popup and inline) for embedding a scheduling calendar on any website.
- It delegates actual booking logic to a remote Dayschedule.com backend and bridges third-party meeting integrations (Google Meet, Zoom, MS Teams).

##### Main Architectural Components
a. **Developer & CI Environment**
- Source Repository (GitHub)
- CI Workflows (.github/workflows/playwright.yml) running Playwright tests
- Local tests (`tests/popup.spec.ts`)
b. **Build & Distribution**
- Build tool (driven via package.json scripts) compiles/transpiles TS → JS & CSS
- Output artifacts in `/dist` (dayschedule-widget.js, dayschedule-popup.css, dayschedule-widget.css)
- Published to NPM registry and mirrored on CDNs (jsDelivr, unpkg)
c. **Consumer Integration (Host Website)**
- HTML page includes `<script src=".../dayschedule-widget.js">` and optional `<link href=".../dayschedule-popup.css">`
- Calls `daySchedule.initPopupWidget(...)` or uses `<dayschedule-widget>` custom element to render inline
d. **Browser-Side Widget Logic**
- Initializes on button click or DOM element detection
- Renders iframe or DOM widgets, applies CSS, listens to user events
- Makes REST/WebSocket calls to Dayschedule backend
e. **Remote Scheduling Service**
- Dayschedule.com API endpoints for availability, booking, user data
- Integrations with Google Meet, Zoom, MS Teams (OAuth and API calls)
f. **CDN / Hosting Infrastructure**
- Static assets served from Cloudflare/AWS CloudFront (250+ regions) for low-latency
- Gzip/br compression, WebP images for performance

##### Relationships & Data Flows
- **Developer → Build System:** commits trigger CI → runs tests → publishes artifacts
- **Build System → NPM/CDN:** dist artifacts are published & cached
- **Consumer Website → CDN:** browser fetches JS & CSS assets
- **Browser Widget → Dayschedule API:** data flow for schedule lookup and booking
- **Dayschedule Backend → Third-Party Services:** API calls to calendar/meeting providers
- Feedback loops: error logging or analytics can flow back to Dayschedule backend

##### Architectural Patterns & Design Principles
- **Modular widget**: host-agnostic, deferred initialization (lazy loading)
- **Separation of concerns**: UI rendering in widget, business logic on backend
- **Continuous integration**: Playwright E2E tests automate cross-browser validation
- **Edge-caching**: multi-region CDN for global performance

##### Element Checklist
- Versioning & publishing flow from dev → NPM/CDN → browser
- External dependencies (Google Meet, Zoom, MS Teams)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer & CI Environment
    subgraph "Developer & CI Environment"
        GH["GitHub Repo"]:::dev
        CI["CI Workflows"]:::dev
        PW["playwright.config.ts"]:::dev
        TEST["tests/popup.spec.ts"]:::dev
        MD["README.md"]:::doc
        LIC["LICENSE"]:::doc
        GITIGN[".gitignore"]:::doc
    end

    %% Build & Distribution
    subgraph "Build & Distribution"
        BS["package.json"]:::build
        LOCK["package-lock.json"]:::build
        ARTJS["dist/dayschedule-widget.js"]:::build
        ARTCSS1["dist/dayschedule-popup.css"]:::build
        ARTCSS2["dist/dayschedule-widget.css"]:::build
    end

    %% CDN / Hosting Infrastructure
    subgraph "CDN / Hosting Infrastructure"
        CDN["CDN (Cloudflare/AWS CloudFront)"]:::cdn
        ALT["assets/"]:::cdn
    end

    %% Consumer Integration
    subgraph "Consumer Integration (Host Website)"
        EX1["examples/inline.html"]:::consumer
        EX2["examples/inline-calendar.html"]:::consumer
        EX3["examples/popup.html"]:::consumer
        EX4["examples/services.html"]:::consumer
    end

    %% Browser & Widget Logic
    Browser["Browser"]:::browser

    %% Remote Backend & Third-Party
    API["Dayschedule Backend API"]:::backend
    GP["Google Meet"]:::third
    ZM["Zoom"]:::third
    MS["MS Teams"]:::third

    %% Relationships
    GH -->|git push / CI trigger| CI
    CI -->|runs tests| TEST
    CI -->|uses config| PW
    CI -->|reads docs| MD
    CI -->|reads docs| LIC
    CI -->|reads config| GITIGN

    CI -->|npm run build| BS
    BS --> LOCK
    BS -->|compiles| ARTJS
    BS -->|compiles| ARTCSS1
    BS -->|compiles| ARTCSS2

    ARTJS -->|publish assets| CDN
    ARTCSS1 -->|publish assets| CDN
    ARTCSS2 -->|publish assets| CDN
    ALT -->|static assets| CDN

    EX1 -->|HTTP GET JS/CSS| CDN
    EX2 -->|HTTP GET JS/CSS| CDN
    EX3 -->|HTTP GET JS/CSS| CDN
    EX4 -->|HTTP GET JS/CSS| CDN

    CDN -->|serves files| Browser
    Browser -->|initPopupWidget / custom element| Browser
    Browser -->|REST API / JSON| API
    API -->|OAuth / Calendar API| GP
    API -->|OAuth / Calendar API| ZM
    API -->|OAuth / Calendar API| MS

    %% Click Events
    click CI "https://github.com/dayschedule/dayschedule-widget/blob/main/.github/workflows/playwright.yml"
    click PW "https://github.com/dayschedule/dayschedule-widget/blob/main/playwright.config.ts"
    click TEST "https://github.com/dayschedule/dayschedule-widget/blob/main/tests/popup.spec.ts"
    click BS "https://github.com/dayschedule/dayschedule-widget/blob/main/package.json"
    click LOCK "https://github.com/dayschedule/dayschedule-widget/blob/main/package-lock.json"
    click ARTJS "https://github.com/dayschedule/dayschedule-widget/blob/main/dist/dayschedule-widget.js"
    click ARTCSS1 "https://github.com/dayschedule/dayschedule-widget/blob/main/dist/dayschedule-popup.css"
    click ARTCSS2 "https://github.com/dayschedule/dayschedule-widget/blob/main/dist/dayschedule-widget.css"
    click EX1 "https://github.com/dayschedule/dayschedule-widget/blob/main/examples/inline.html"
    click EX2 "https://github.com/dayschedule/dayschedule-widget/blob/main/examples/inline-calendar.html"
    click EX3 "https://github.com/dayschedule/dayschedule-widget/blob/main/examples/popup.html"
    click EX4 "https://github.com/dayschedule/dayschedule-widget/blob/main/examples/services.html"
    click ALT "https://github.com/dayschedule/dayschedule-widget/tree/main/assets/"
    click MD "https://github.com/dayschedule/dayschedule-widget/blob/main/README.md"
    click LIC "https://github.com/dayschedule/dayschedule-widget/tree/main/LICENSE"
    click GITIGN "https://github.com/dayschedule/dayschedule-widget/blob/main/.gitignore"

    %% Styles
    classDef dev fill:#CCCCCC,stroke:#333,stroke-width:1px
    classDef build fill:#87CEFA,stroke:#333,stroke-width:1px
    classDef cdn fill:#98FB98,stroke:#333,stroke-width:1px
    classDef consumer fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef browser fill:#FFA500,stroke:#333,stroke-width:1px
    classDef backend fill:#9370DB,stroke:#333,stroke-width:1px
    classDef third fill:#FFB6C1,stroke:#333,stroke-width:1px
    classDef doc fill:#FFFF99,stroke:#333,stroke-width:1px
```
