# reneaaron/lightning-widget architecture

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

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

## Overview

##### Project type and purpose
- This is a front-end widget library built with Vue.js that exposes a `<lightning-widget>` custom element.

##### File structure
- Top-level config and build files:
- `.eslintrc.js`, `babel.config.js`, `vue.config.js`, `package.json` → Vue CLI project, custom bundling and linting
- `public/index.html` → development HTML host page
- `src/main.js` → entry for mounting & registering the custom element / widget on the client
- `src/components/Widget.ce.vue` → the Vue single-file component defining the widget UI & logic
- `src/components/utils/helpers.js` → shared helper functions (e.g. formatting, validation)
- `src/server/main.js` → a small Node.js/Express (or similar) server to serve `app.js` and possibly proxy or handle invoice-creation calls during development
- `package-lock.json` → snapshot of installed dependencies

##### README for additional insights
- Confirms that end users embed `<script src="https://embed.twentyuno.net/js/app.js">` → this script is the bundled output of the Vue widget and registers the custom element
- Widget interacts client-side with Lightning Addresses or LNURL endpoints to generate invoices and complete payments
- No heavy backend API; relies on client-side calls or external payment endpoints

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Build Pipeline"
        CLI["Vue CLI & Build Configuration"]:::build
        Babel["Babel Transpilation Configuration"]:::build
        ESLint["ESLint Configuration"]:::build
        Package["Package Definitions & Dependencies"]:::build
        Lockfile["Lockfile Snapshot of Dependencies"]:::build
        CLI -->|uses| Babel
        CLI -->|uses| ESLint
        CLI -->|uses| Package
        CLI -->|uses| Lockfile
        Babel -->|outputs| BuildOutput["Bundled app.js"]:::build
    end

    subgraph "Deployment"
        AssetServer["Development/Asset Server"]:::server
        CDN["CDN"]:::server
        BuildOutput -->|deploy| AssetServer
        AssetServer -->|sync| CDN
    end

    subgraph "Runtime (Browser)"
        HostPage["Development Host Page"]:::client
        CDN -->|"GET /js/app.js"| HostPage
        Script["Embeddable Script (app.js)"]:::client
        HostPage -->|loads| Script
        Widget["<lightning-widget><br/>props: name,image,to,..."]:::client
        Script -->|registers| Widget
        Helper["Shared Helper Functions"]:::client
        Widget -->|uses| Helper
        Widget -->|"POST /invoice"| ExternalAPI["LNURL/Lightning Address Endpoint"]:::external
        ExternalAPI -->|"invoice"| Widget
        Widget -->|"WS/poll payment"| ExternalService["Lightning Node/WebSocket"]:::external
        Widget -->|"emit payment event"| HostPage
    end

    click CLI "https://github.com/reneaaron/lightning-widget/blob/master/vue.config.js"
    click Babel "https://github.com/reneaaron/lightning-widget/blob/master/babel.config.js"
    click ESLint "https://github.com/reneaaron/lightning-widget/blob/master/.eslintrc.js"
    click Package "https://github.com/reneaaron/lightning-widget/blob/master/package.json"
    click Lockfile "https://github.com/reneaaron/lightning-widget/blob/master/package-lock.json"
    click AssetServer "https://github.com/reneaaron/lightning-widget/blob/master/src/server/main.js"
    click HostPage "https://github.com/reneaaron/lightning-widget/blob/master/public/index.html"
    click Script "https://github.com/reneaaron/lightning-widget/blob/master/src/main.js"
    click Widget "https://github.com/reneaaron/lightning-widget/blob/master/src/components/Widget.ce.vue"
    click Helper "https://github.com/reneaaron/lightning-widget/blob/master/src/components/utils/helpers.js"

    classDef client fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef server fill:#d4edda,stroke:#333,stroke-width:1px
    classDef external fill:#fff3cd,stroke:#333,stroke-width:1px
    classDef build fill:#e2e3e5,stroke:#333,stroke-width:1px
```
