# andreud/push-beam-widget-vuespa architecture

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

- Interactive diagram: https://gitdiagram.com/andreud/push-beam-widget-vuespa
- Repository: https://github.com/andreud/push-beam-widget-vuespa

## Overview

- Enable personalized notifications for specific users (via the BeamsAuthUser component) or
- Enable subscriptions to public interest groups (via the BeamsSubscribeInterest component).

##### Main Components
- Frontend Application:
- Represented by the Vue SPA contained in the “src” directory. This includes the main application file (App.vue), various Vue components (e.g., BeamsAuthUser.vue, BeamsSubscribeInterest.vue), composables (useBeamsClient.ts), and styling/assets.
- The entry point (index.html) loads the Vue app, with initialization in main.ts.
- Vite is used to bundle and build the application (as indicated by vite.config.ts and related tsconfig files).
- Service Worker (PWA-related):
- Located in “public/service-worker.js” to manage caching and possibly background tasks.
- Backend/Serverless Component:
- The project includes “netlify/functions/beamsauth.mts”, which is a Netlify serverless function to handle authentication logic for personalized notifications. This function acts as the backend API endpoint for the BeamsAuthUser component.
- Testing Infrastructure:

##### Architectural Patterns and Design Principles
- Separation of Concerns:
- The frontend is solely responsible for the UI and user interactions.
- All security-sensitive or authentication-related logic is encapsulated in the serverless function.
- Component-Based Architecture:
- Each widget (BeamsAuthUser and BeamsSubscribeInterest) is a self-contained component that encapsulates its own business logic, making the design modular and extensible.
- Use of a Build Tool and TypeScript:
- Vite and TypeScript configurations indicate a modern development stack that supports fast development cycles and typed code.

##### Technology Details
- Vue for building the user interface.
- Vite for bundling and development.
- TypeScript for type safety (as seen in multiple tsconfig files).
- Netlify functions for serverless backend logic.
- Playwright and Vitest for end-to-end and unit testing, respectively.
- Pusher Beams as the external notifications service.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Vue Frontend"
        F["Frontend Vue SPA"]:::frontend
        A["BeamsAuthUser Component"]:::frontend
        S["BeamsSubscribeInterest Component"]:::frontend
    end

    W["Service Worker"]:::service
    N["Netlify Serverless Function (beamsauth.mts)"]:::backend
    P["Pusher Beams Service"]:::external

    subgraph "Testing Infrastructure"
        T1["End-to-End Tests"]:::testing
        T2["Component Tests"]:::testing
    end

    A -->|"auth-request"| N
    A -->|"notification"| P
    S -->|"subscription"| P
    W -->|"caching/offline"| F

    click F "https://github.com/andreud/push-beam-widget-vuespa/tree/main/src/"
    click A "https://github.com/andreud/push-beam-widget-vuespa/blob/main/src/components/BeamsAuthUser.vue"
    click S "https://github.com/andreud/push-beam-widget-vuespa/blob/main/src/components/BeamsSubscribeInterest.vue"
    click W "https://github.com/andreud/push-beam-widget-vuespa/blob/main/public/service-worker.js"
    click N "https://github.com/andreud/push-beam-widget-vuespa/blob/main/netlify/functions/beamsauth.mts"
    click T1 "https://github.com/andreud/push-beam-widget-vuespa/tree/main/e2e/"
    click T2 "https://github.com/andreud/push-beam-widget-vuespa/tree/main/src/components/__tests__/"

    classDef frontend fill:#bbf,stroke:#000,stroke-width:2px;
    classDef backend fill:#bfb,stroke:#000,stroke-width:2px;
    classDef external fill:#fbb,stroke:#000,stroke-width:2px;
    classDef service fill:#d3f8e2,stroke:#000,stroke-width:2px;
    classDef testing fill:#ffd700,stroke:#000,stroke-width:2px;
```
